rpc

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestNewConn

func TestNewConn(t *testing.T, ctx context.Context, bufsize ...int) (listener net.Listener, connect func() *Conn)

Types

type Conn

type Conn struct {
	Conn *grpc.ClientConn
	// contains filtered or unexported fields
}

func NewBlockingConn

func NewBlockingConn(ctx context.Context, address string) (*Conn, error)

func NewConn

func NewConn(ctx context.Context, address string, opts ...grpc.DialOption) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close() (err error)

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]) Close

func (m *Manager[T]) Close() (err error)

Close closes all underlying connections managed by the Manager.

func (*Manager[T]) CloseClient

func (m *Manager[T]) CloseClient(id T) error

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.

func WithLogger

func WithLogger(logger *zap.Logger) ManagerOption

WithLogger sets a logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL