github.com/cloudwego/kitex@v0.9.0/pkg/remote/connpool/dummy.go (about)

     1  /*
     2   * Copyright 2021 CloudWeGo Authors
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  package connpool
    18  
    19  import (
    20  	"context"
    21  	"net"
    22  
    23  	"github.com/cloudwego/kitex/pkg/remote"
    24  )
    25  
    26  var (
    27  	_ remote.ConnPool     = &DummyPool{}
    28  	_ remote.LongConnPool = &DummyPool{}
    29  	_ Reporter            = &DummyReporter{}
    30  )
    31  
    32  // DummyPool is a dummy implementation of remote.ConnPool.
    33  type DummyPool struct{}
    34  
    35  // Get implements the remote.ConnPool interface.
    36  func (p *DummyPool) Get(ctx context.Context, network, address string, opt remote.ConnOption) (net.Conn, error) {
    37  	return nil, nil
    38  }
    39  
    40  // Put implements the remote.ConnPool interface.
    41  func (p *DummyPool) Put(conn net.Conn) error { return nil }
    42  
    43  // Discard implements the remote.ConnPool interface.
    44  func (p *DummyPool) Discard(conn net.Conn) error { return nil }
    45  
    46  // Clean implements the remote.LongConnPool interface.
    47  func (p *DummyPool) Clean(network, address string) {}
    48  
    49  // Close is to release resource of ConnPool, it is executed when client is closed.
    50  func (p *DummyPool) Close() error { return nil }
    51  
    52  // DummyReporter is a dummy implementation of Reporter.
    53  type DummyReporter struct{}
    54  
    55  // ConnSucceed implements the Reporter interface.
    56  func (dcm *DummyReporter) ConnSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr) {
    57  }
    58  
    59  // ConnFailed implements the Reporter interface.
    60  func (dcm *DummyReporter) ConnFailed(poolType ConnectionPoolType, serviceName string, addr net.Addr) {
    61  }
    62  
    63  // ReuseSucceed implements the Reporter interface.
    64  func (dcm *DummyReporter) ReuseSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr) {
    65  }