lazygrpc

package
v0.10.3-0...-843c1f5 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("lazy grpc conn closed")

Functions

This section is empty.

Types

type Conn

type Conn interface {
	// GetConn will block until the grpc.ClientConn is ready to use.
	// If the context is done, return immediately with the context.Canceled or Context.DeadlineExceeded error.
	// Return ErrClosed if the lazy grpc conn is closed.
	GetConn(ctx context.Context) (*grpc.ClientConn, error)

	// Close closes the lazy grpc conn.
	// Close the underlying grpc conn if it is already created.
	Close()
}

Conn is a lazy grpc conn implementation. grpc.Dial operation will block until new grpc conn is created at least once. Conn will dial the underlying grpc conn asynchronously to avoid dependency cycle of milvus component when create grpc client. TODO: Remove in future if we can refactor the dependency cycle.

func NewConn

func NewConn(dialer func(ctx context.Context) (*grpc.ClientConn, error)) Conn

NewConn creates a new lazy grpc conn.

type Service

type Service[T any] interface {
	Conn

	GetService(ctx context.Context) (T, error)
}

Service is a lazy grpc service.

func WithServiceCreator

func WithServiceCreator[T any](conn Conn, serviceCreator func(grpc.ClientConnInterface) T) Service[T]

WithServiceCreator creates a lazy grpc service with a service creator.

Jump to

Keyboard shortcuts

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