pluggable

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SocketFolderEnvVar = "DAPR_COMPONENTS_SOCKETS_FOLDER"
)

Variables

This section is empty.

Functions

func AddServiceDiscoveryCallback

func AddServiceDiscoveryCallback(serviceName string, callbackFunc func(name string, dialer GRPCConnectionDialer))

AddServiceDiscoveryCallback adds a callback function that should be called when the given service was discovered.

func Discover

func Discover(ctx context.Context) error

Discover discover the pluggable components and callback the service discovery with the given component name and grpc dialer.

func GetSocketFolderPath

func GetSocketFolderPath() string

GetSocketFolderPath returns the shared unix domain socket folder path

func SocketDial

func SocketDial(ctx context.Context, socket string, additionalOpts ...grpc.DialOption) (*grpc.ClientConn, error)

SocketDial creates a grpc connection using the given socket.

Types

type GRPCClient

type GRPCClient interface {
	// Ping is for liveness purposes.
	Ping(ctx context.Context, in *proto.PingRequest, opts ...grpc.CallOption) (*proto.PingResponse, error)
}

GRPCClient is any client that supports common pluggable grpc operations.

type GRPCConnectionDialer

type GRPCConnectionDialer = func(ctx context.Context, name string) (*grpc.ClientConn, error)

type GRPCConnector

type GRPCConnector[TClient GRPCClient] struct {
	// Context is the component shared context
	Context context.Context
	// Cancel is used for cancelling inflight requests
	Cancel context.CancelFunc
	// Client is the proto client.
	Client TClient
	// contains filtered or unexported fields
}

GRPCConnector is a connector that uses underlying gRPC protocol for common operations.

func NewGRPCConnector

func NewGRPCConnector[TClient GRPCClient](socket string, factory func(grpc.ClientConnInterface) TClient) *GRPCConnector[TClient]

NewGRPCConnector creates a new grpc connector for the given client factory and socket.

func NewGRPCConnectorWithDialer

func NewGRPCConnectorWithDialer[TClient GRPCClient](dialer GRPCConnectionDialer, factory func(grpc.ClientConnInterface) TClient) *GRPCConnector[TClient]

NewGRPCConnectorWithDialer creates a new grpc connector for the given client factory and dialer.

func (*GRPCConnector[TClient]) Close

func (g *GRPCConnector[TClient]) Close() error

Close closes the underlying gRPC connection and cancel all inflight requests.

func (*GRPCConnector[TClient]) Dial

func (g *GRPCConnector[TClient]) Dial(name string) error

Dial opens a grpcConnection and creates a new client instance.

func (*GRPCConnector[TClient]) Ping

func (g *GRPCConnector[TClient]) Ping() error

Ping pings the grpc component. It uses "WaitForReady" avoiding failing in transient failures.

Jump to

Keyboard shortcuts

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