Documentation ¶
Index ¶
- Constants
- Variables
- func ExecuteWithRetry(f func() (interface{}, error), initBackoff float64, maxBackoff float64, ...) (interface{}, error)
- func Listen(netAddr dfnet.NetAddr) (net.Listener, error)
- func ListenWithPortRange(listen string, startPort, endPort int) (net.Listener, int, error)
- type Closer
- type ConnOption
- func WithConnExpireTime(duration time.Duration) ConnOption
- func WithDialOption(opts []grpc.DialOption) ConnOption
- func WithDialTimeout(dialTimeout time.Duration) ConnOption
- func WithGcConnInterval(gcConnInterval time.Duration) ConnOption
- func WithGcConnTimeout(gcConnTimeout time.Duration) ConnOption
- type ConnStatus
- type Connection
- func (conn *Connection) AddServerNodes(addrs []dfnet.NetAddr) error
- func (conn *Connection) Close() error
- func (conn *Connection) CorrectKey2NodeRelation(tmpHashKey, realHashKey string)
- func (conn *Connection) GetClientConn(hashKey string, stick bool) (clientConn *grpc.ClientConn, err error)
- func (conn *Connection) GetClientConnByTarget(node string) (*grpc.ClientConn, error)
- func (conn *Connection) GetServerNode(hashKey string) (string, bool)
- func (conn *Connection) TryMigrate(key string, cause error, exclusiveNodes []string) (preNode string, err error)
- func (conn *Connection) UpdateAccessNodeMapByHashKey(key string)
- func (conn *Connection) UpdateAccessNodeMapByServerNode(serverNode string)
- func (conn *Connection) UpdateState(addrs []dfnet.NetAddr)
- type RetryMeta
Constants ¶
View Source
const ( // Identifier of message transmitted or received. RPCMessageIDKey = attribute.Key("message.id") // The uncompressed size of the message transmitted or received in // bytes. RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") )
Variables ¶
View Source
var DefaultServerOptions = []grpc.ServerOption{ grpc.ConnectionTimeout(10 * time.Second), grpc.InitialConnWindowSize(8 * 1024 * 1024), grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ MinTime: 30 * time.Second, }), grpc.KeepaliveParams(keepalive.ServerParameters{ MaxConnectionIdle: 5 * time.Minute, }), grpc.MaxConcurrentStreams(100), grpc.StreamInterceptor(grpc_middleware.ChainStreamServer( streamServerInterceptor, grpc_prometheus.StreamServerInterceptor, grpc_zap.StreamServerInterceptor(logger.GrpcLogger.Desugar()), grpc_validator.StreamServerInterceptor(), )), grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer( unaryServerInterceptor, grpc_prometheus.UnaryServerInterceptor, grpc_zap.UnaryServerInterceptor(logger.GrpcLogger.Desugar()), grpc_validator.UnaryServerInterceptor(), )), }
Functions ¶
func ExecuteWithRetry ¶
func Listen ¶
Listen wraps net.Listen with dfnet.NetAddr Example:
Listen(dfnet.NetAddr{Type: dfnet.UNIX, Addr: "/var/run/df.sock"}) Listen(dfnet.NetAddr{Type: dfnet.TCP, Addr: ":12345"})
func ListenWithPortRange ¶
ListenWithPortRange tries to listen a port between startPort and endPort, return net.Listener and listen port Example:
ListenWithPortRange("0.0.0.0", 12345, 23456) ListenWithPortRange("192.168.0.1", 12345, 23456) ListenWithPortRange("192.168.0.1", 0, 0) // random port
Types ¶
type ConnOption ¶
type ConnOption interface {
// contains filtered or unexported methods
}
func WithConnExpireTime ¶
func WithConnExpireTime(duration time.Duration) ConnOption
func WithDialOption ¶
func WithDialOption(opts []grpc.DialOption) ConnOption
func WithDialTimeout ¶
func WithDialTimeout(dialTimeout time.Duration) ConnOption
func WithGcConnInterval ¶
func WithGcConnInterval(gcConnInterval time.Duration) ConnOption
func WithGcConnTimeout ¶
func WithGcConnTimeout(gcConnTimeout time.Duration) ConnOption
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(ctx context.Context, name string, addrs []dfnet.NetAddr, connOpts []ConnOption) *Connection
func (*Connection) AddServerNodes ¶
func (conn *Connection) AddServerNodes(addrs []dfnet.NetAddr) error
func (*Connection) Close ¶
func (conn *Connection) Close() error
func (*Connection) CorrectKey2NodeRelation ¶
func (conn *Connection) CorrectKey2NodeRelation(tmpHashKey, realHashKey string)
func (*Connection) GetClientConn ¶
func (conn *Connection) GetClientConn(hashKey string, stick bool) (clientConn *grpc.ClientConn, err error)
GetClientConn get conn or bind hashKey to candidate node, don't do the migrate action stick whether hash key need already associated with specify node
func (*Connection) GetClientConnByTarget ¶
func (conn *Connection) GetClientConnByTarget(node string) (*grpc.ClientConn, error)
func (*Connection) GetServerNode ¶
func (conn *Connection) GetServerNode(hashKey string) (string, bool)
GetServerNode
func (*Connection) TryMigrate ¶
func (conn *Connection) TryMigrate(key string, cause error, exclusiveNodes []string) (preNode string, err error)
TryMigrate migrate key to another hash node other than exclusiveNodes preNode node before the migration
func (*Connection) UpdateAccessNodeMapByHashKey ¶
func (conn *Connection) UpdateAccessNodeMapByHashKey(key string)
func (*Connection) UpdateAccessNodeMapByServerNode ¶
func (conn *Connection) UpdateAccessNodeMapByServerNode(serverNode string)
func (*Connection) UpdateState ¶
func (conn *Connection) UpdateState(addrs []dfnet.NetAddr)
Directories ¶
Path | Synopsis |
---|---|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
server/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
cdnsystem/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
client/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
server/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
client/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
client/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.