Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServer ¶ added in v0.16.0
func NewServer(opts ...grpc.ServerOption) *grpc.Server
NewServer calls grpc.NewServer function. The package github.com/kakao/varlog/pkg/rpc registers the gogoproto codec to the gRPC. Therefore calling this method rather than grpc.NewServer makes the application server use the gogoproto codec instead of the regular proto codec.
Types ¶
type Conn ¶
type Conn struct { Conn *grpc.ClientConn // contains filtered or unexported fields }
func NewConn ¶
NewConn creates a new gRPC connection to the specified address using google.golang.org/grpc.NewClient. Note that this method does not perform any I/O, meaning the connection is not immediately established. If the server is unavailable, this method will not return an error. The connection is established automatically when an RPC is made using the returned Conn. DialOptions such as WithBlock, WithTimeout, and WithReturnConnectionError are not considered. Ensure to close the returned Conn after usage to avoid resource leaks.
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.