Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn struct { Conn *grpc.ClientConn // contains filtered or unexported fields }
type Manager ¶
type Manager[T comparable] struct { // contains filtered or unexported fields }
Manager keeps RPC connections for each target. Type parameter T should be a comparable type that identifies the target peer, for instance, types.StorageNodeID and types.NodeID. Manager can be shared by multiple clients.
func NewManager ¶
func NewManager[T comparable](opts ...ManagerOption) (*Manager[T], error)
NewManager creates a Manager.
func (*Manager[T]) CloseClient ¶
CloseClient closes a connection identified by the argument id and removes the connection from the manager. It returns nil if the connection does not exist.
func (*Manager[T]) GetOrConnect ¶
func (m *Manager[T]) GetOrConnect(ctx context.Context, id T, addr string, grpcDialOptions ...grpc.DialOption) (*Conn, error)
GetOrConnect returns an RPC connection that is cached or established if not exist.
type ManagerOption ¶
type ManagerOption interface {
// contains filtered or unexported methods
}
ManagerOptions is a type for options of Manager.
func WithDefaultGRPCDialOptions ¶
func WithDefaultGRPCDialOptions(defaultGRPCDialOptions ...grpc.DialOption) ManagerOption
WithDefaultGRPCDialOptions sets default GRPC DialOptions.
Click to show internal directories.
Click to hide internal directories.