grpc_client

package
v0.0.0-...-8b3bf69 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SharedConnectionKey = "shared-grpc-connection"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallPropertiesProvider

type CallPropertiesProvider interface {
	CallOptions(context.Context) []grpc.CallOption
}

type Connection

type Connection struct {
	Tag        ConnectionTag
	Connection ConnectionDesc
	// contains filtered or unexported fields
}

NOTE: Mutex `mx` is used by value here, so no copying is allowed

func (*Connection) Disconnect

func (uc *Connection) Disconnect() error

func (*Connection) IsConnected

func (uc *Connection) IsConnected() bool

func (*Connection) String

func (uc *Connection) String() string

type ConnectionDesc

type ConnectionDesc = *grpc.ClientConn

type ConnectionPool

type ConnectionPool interface {
	GetStableConnection(context.Context) (*grpc.ClientConn, error)
	Reconnect(context.Context) (*grpc.ClientConn, error)
}

type ConnectionPropertiesProvider

type ConnectionPropertiesProvider interface {
	DialOptions(context.Context) ([]grpc.DialOption, error)
	Tag(context.Context) (ConnectionTag, error)
	Validate(*ConnectionTag, *ConnectionTag) bool
}

type ConnectionStatus

type ConnectionStatus struct {
	Kind    ConnectionStatusKind
	Attempt int
}

func (*ConnectionStatus) IsConnected

func (cs *ConnectionStatus) IsConnected() bool

func (*ConnectionStatus) IsConnecting

func (cs *ConnectionStatus) IsConnecting() bool

type ConnectionStatusKind

type ConnectionStatusKind string
const (
	Connected         ConnectionStatusKind = "connected"
	ConnectionAttempt ConnectionStatusKind = "connection-attempt"
)

type ConnectionTag

type ConnectionTag struct {
	Key      string
	UserData interface{}
}

type ConnectionsMap

type ConnectionsMap map[string]*Connection

type DefaultConnectionProps

type DefaultConnectionProps struct{}

NOTE: This struct implements `ConnectionPropertiesProvider`

func (*DefaultConnectionProps) DialOptions

func (dcp *DefaultConnectionProps) DialOptions(_ context.Context) ([]grpc.DialOption, error)

func (*DefaultConnectionProps) Tag

func (*DefaultConnectionProps) Validate

func (dcp *DefaultConnectionProps) Validate(prev, next *ConnectionTag) bool

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

func New

func (*GRPCClient) ConnStatusChannel

func (c *GRPCClient) ConnStatusChannel() *dllist.ListItem[StatusSub]

func (*GRPCClient) DialOptions

func (c *GRPCClient) DialOptions(ctx context.Context) ([]grpc.DialOption, error)

func (*GRPCClient) GetStableConnection

func (c *GRPCClient) GetStableConnection(ctx context.Context) (
	*grpc.ClientConn, error,
)

func (*GRPCClient) Reconnect

func (c *GRPCClient) Reconnect(ctx context.Context) (*grpc.ClientConn, error)

func (*GRPCClient) Tag

func (c *GRPCClient) Tag(ctx context.Context) (ConnectionTag, error)

func (*GRPCClient) Validate

func (c *GRPCClient) Validate(l, r *ConnectionTag) bool

type GRPCClientInterface

type GRPCClientInterface interface {
	ConnectionPropertiesProvider
	CallPropertiesProvider

	// NOTE: This method returns Droppable list item, making its clients able to
	// subscribe for connection related events
	ConnStatusChannel() *dllist.ListItem[StatusSub]
}

Jump to

Keyboard shortcuts

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