grpc

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponseEncoder added in v0.6.0

func ErrorResponseEncoder(
	encoder kitgrpc.EncodeResponseFunc,
	errorEncoder EncodeErrorResponseFunc,
) kitgrpc.EncodeResponseFunc

ErrorResponseEncoder encodes the passed response object to a gRPC response or error.

func IsGRPCError added in v0.7.1

func IsGRPCError(err error) bool

IsGRPCError checks if an error is already encoded as a gRPC status.

func NewErrorEncoderHandler added in v0.11.0

func NewErrorEncoderHandler(handler kitgrpc.Handler, errorEncoder EncodeErrorResponseFunc) kitgrpc.Handler

NewErrorEncoderHandler wraps a gRPC handler and encodes the returned error using the error encoder (if necessary).

For example, a returned endpoint error might need additional encoding.

func ServerOptions added in v0.2.0

func ServerOptions(options []grpc.ServerOption) grpc.ServerOption

ServerOptions collects a list of ServerOptions into a single option. Useful to avoid variadic hells when passing lists of options around.

Types

type EncodeErrorResponseFunc added in v0.6.0

type EncodeErrorResponseFunc func(context.Context, error) error

EncodeErrorResponseFunc transforms the passed error to a gRPC code error. It's designed to be used in gRPC servers, for server-side endpoints.

func NewDefaultStatusErrorResponseEncoder added in v0.7.0

func NewDefaultStatusErrorResponseEncoder() EncodeErrorResponseFunc

NewDefaultStatusErrorResponseEncoder returns an error response encoder that encodes errors as gRPC Status errors.

The returned encoder encodes every error as Internal error.

func NewStatusErrorResponseEncoder added in v0.7.0

func NewStatusErrorResponseEncoder(statusConverter StatusConverter) EncodeErrorResponseFunc

NewStatusErrorResponseEncoder returns an error response encoder that encodes errors as gRPC Status errors.

type ServerFactory

type ServerFactory interface {
	// NewServer constructs a new server, which wraps the provided endpoint and implements the grpc.Handler interface.
	NewServer(
		e endpoint.Endpoint,
		dec grpc.DecodeRequestFunc,
		enc grpc.EncodeResponseFunc,
		options ...grpc.ServerOption,
	) *grpc.Server
}

ServerFactory constructs a new server, which wraps the provided endpoint and implements the grpc.Handler interface.

func NewServerFactory

func NewServerFactory(options ...grpc.ServerOption) ServerFactory

NewServerFactory returns a new ServerFactory.

type StatusConverter added in v0.7.0

type StatusConverter interface {
	// NewStatus creates a new gRPC Status from an error.
	NewStatus(ctx context.Context, err error) *status.Status
}

StatusConverter creates a new gRPC Status from an error.

Jump to

Keyboard shortcuts

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