Documentation ¶
Index ¶
- Constants
- func AddServiceDiscoveryCallback(serviceName string, ...)
- func Discover(ctx context.Context) error
- func GetSocketFolderPath() string
- func KitErrorFromGrpcError(err error) (error, bool)
- func KitErrorFromGrpcErrorIgnore(err error) error
- func KitErrorFromStatus(s *status.Status) (error, bool)
- func MustStatusErrorFromKitError(grpcCode codes.Code, httpCode int, message string, tag string, ...) error
- func NewConverterFunc(errorsConverters MethodErrorConverter) func(error) error
- func SocketDial(ctx context.Context, socket string, additionalOpts ...grpc.DialOption) (*grpc.ClientConn, error)
- func StatusFromKitError(grpcCode codes.Code, httpCode int, message string, tag string, ...) (*status.Status, error)
- type ErrorConverter
- type GRPCClient
- type GRPCConnectionDialer
- type GRPCConnector
- type MethodErrorConverter
Constants ¶
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 ¶
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 KitErrorFromGrpcError ¶
func NewConverterFunc ¶
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 ¶
func (ErrorConverter) Compose ¶
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 ¶
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 ¶
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 ¶
func (m MethodErrorConverter) Merge(other MethodErrorConverter) MethodErrorConverter