Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DialTimeout the timeout of create connection DialTimeout = 5 * time.Second // BackoffMaxDelay provided maximum delay when backing off after failed connection attempts. BackoffMaxDelay = 3 * time.Second // KeepAliveTime 如此时长后客户端未收到响应则会 ping 服务端。 KeepAliveTime = time.Duration(10) * time.Second // KeepAliveTimeout 客户端 ping 服务端后,如此时长没响应会关闭连接。 KeepAliveTimeout = time.Duration(3) * time.Second // InitialWindowSize we set it 1GB is to provide system's throughput. InitialWindowSize = 1 << 30 // InitialConnWindowSize we set it 1GB is to provide system's throughput. InitialConnWindowSize = 1 << 30 // MaxSendMsgSize set max gRPC request message size sent to server. // If any request message size is larger than current value, an error will be reported from gRPC. MaxSendMsgSize = 4 << 30 // MaxRecvMsgSize set max gRPC receive message size received from server. // If any message size is larger than current value, an error will be reported from gRPC. MaxRecvMsgSize = 4 << 30 )
View Source
const ( // DftMaxIdle see options.MaxIdle DftMaxIdle = int(8) // DftMaxActive see options.MaxActive DftMaxActive = int(64) // DftMaxConcurrentStreams see options.MaxConcurrentStreams DftMaxConcurrentStreams = int(64) )
Variables ¶
View Source
var ErrClosed = errors.New("pool is closed")
ErrClosed is the error resulting if the pool is closed via pool.Close().
Functions ¶
Types ¶
type Conn ¶
type Conn interface { // Value return the actual grpc connection type *grpc.ClientConn. Value() *grpc.ClientConn // Close decrease the reference of grpc connection, instead of close it. // if the pool is full, just close it. Close() error }
Conn single grpc connection interface
type Option ¶
type Option func(o *options)
Option is an options setting function.
func Dial ¶
func Dial(factoryFn func(address string) (*grpc.ClientConn, error)) Option
Dial with factory function for *grpc.ClientConn
func MaxConcurrentStreams ¶
MaxConcurrentStreams with pool maxConcurrentStreams
type Pool ¶
type Pool interface { // Get returns a new connection from the pool. Closing the connections puts // it back to the Pool. Closing it when the pool is destroyed or full will // be counted as an error. we guarantee the conn.Value() isn't nil when conn isn't nil. Get() (Conn, error) // Close closes the pool and all its connections. After Close() the pool is // no longer usable. You can't make concurrent calls Close and Get method. // It will be cause panic. Close() // Status returns the current status of the pool. Status() string }
Pool interface describes a pool implementation. An ideal pool is thread-safe and easy to use.
Click to show internal directories.
Click to hide internal directories.