Documentation ¶
Index ¶
- Constants
- Variables
- func SetLog(l logger.Logger)
- type GrpcConn
- type GrpcConnState
- type GrpcPool
- func (gp *GrpcPool) Closed()
- func (gp *GrpcPool) GetGrpcPoolState() *GrpcPoolState
- func (gp *GrpcPool) GetTotalUse() int
- func (gp *GrpcPool) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, ...) error
- func (gp *GrpcPool) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, ...) (grpc.ClientStream, error)
- type GrpcPoolState
- type Option
- type ScaleOption
Constants ¶
View Source
const ( // KeepAliveTime is the duration of time after which if the client doesn't see // any activity it pings the server to see if the transport is still alive. KeepAliveTime = time.Duration(10) * time.Second // KeepAliveTimeout is the duration of time for which the client waits after having // pinged for keepalive check and if no activity is seen even after that the connection // is closed. KeepAliveTimeout = time.Duration(3) * time.Second // InitialWindowSize we set it 256M is to provide system's throughput. InitialWindowSize = 1 << 28 // InitialConnWindowSize we set it 256M is to provide system's throughput. InitialConnWindowSize = 1 << 28 // MaxSendMsgSize set max gRPC request message poolSize sent to server. // If any request message poolSize is larger than current value, an error will be reported from gRPC. MaxSendMsgSize = 1 << 30 // MaxRecvMsgSize set max gRPC receive message poolSize received from server. // If any message poolSize is larger than current value, an error will be reported from gRPC. MaxRecvMsgSize = 1 << 30 )
Variables ¶
View Source
var DefaultDialOpts = []grpc.DialOption{ grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), grpc.WithInitialWindowSize(InitialWindowSize), grpc.WithInitialConnWindowSize(InitialConnWindowSize), grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(MaxSendMsgSize)), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(MaxRecvMsgSize)), grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: KeepAliveTime, Timeout: KeepAliveTimeout, PermitWithoutStream: true, }), }
View Source
var DefaultDialTimeout = 3 * time.Second
View Source
var DefaultScaleOption = &ScaleOption{ Enable: true, ScalePeriod: time.Second * 30, MaxConn: 300, DesireMaxStream: 80, }
Functions ¶
Types ¶
type GrpcConnState ¶
type GrpcConnState struct {
// contains filtered or unexported fields
}
type GrpcPool ¶
func (*GrpcPool) GetGrpcPoolState ¶
func (gp *GrpcPool) GetGrpcPoolState() *GrpcPoolState
func (*GrpcPool) GetTotalUse ¶
func (*GrpcPool) NewStream ¶
func (gp *GrpcPool) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
type GrpcPoolState ¶
type GrpcPoolState struct { ConnStates []GrpcConnState ReserveSize int Target string ScaleOption ScaleOption IsClosed bool }
type Option ¶
type Option func(*GrpcPool)
func WithDialOptions ¶
func WithDialOptions(dialOptions []grpc.DialOption) Option
func WithPoolSize ¶
func WithScaleOption ¶
func WithScaleOption(scaleOption *ScaleOption) Option
Click to show internal directories.
Click to hide internal directories.