pluggable

package
v1.13.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 14 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 NewConverterFunc added in v1.10.0

func NewConverterFunc(errorsConverters MethodErrorConverter) func(error) error

NewConverterFunc returns a function that maps from any error to a business error. if the error is unknown it is kept as is, otherwise a converter function will be used.

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 ErrorConverter added in v1.10.0

type ErrorConverter func(status.Status) error

func (ErrorConverter) Compose added in v1.10.0

func (outer ErrorConverter) Compose(inner ErrorConverter) ErrorConverter

Compose together two errors converters by applying the inner first and if the error was not converted, then it applies to the outer.

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, opts ...grpc.DialOption) (*grpc.ClientConn, error)

func (GRPCConnectionDialer) WithOptions added in v1.10.0

func (g GRPCConnectionDialer) WithOptions(newOpts ...grpc.DialOption) GRPCConnectionDialer

WithOptions returns a new connection dialer that adds the new options to it.

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 file, using the default socket dialer.

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.

type MethodErrorConverter added in v1.10.0

type MethodErrorConverter map[codes.Code]ErrorConverter

MethodErrorConverter represents a simple map that maps from a grpc statuscode to a domain-level error.

func (MethodErrorConverter) Merge added in v1.10.0

Jump to

Keyboard shortcuts

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