Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecodeRequestFunc ¶
DecodeRequestFunc extracts a user-domain request object from a gRPC request. It's designed to be used in gRPC servers, for server-side endpoints. One straightforward DecodeRequestFunc could be something that decodes from the gRPC request message to the concrete request type.
type EncodeResponseFunc ¶
EncodeResponseFunc encodes the passed response object to the gRPC response message. It's designed to be used in gRPC servers, for server-side endpoints. One straightforward EncodeResponseFunc could be something that encodes the object directly to the gRPC response message.
type Endpoint ¶
Endpoint is the fundamental building block of servers and clients. It represents a single RPC method.
func PrintRpcCall ¶
func PrintRpcCall(logger grpclog.DepthLoggerV2, e Endpoint) Endpoint
type ErrorHandler ¶
ErrorHandler receives a transport error to be processed for diagnostic purposes. Usually this means logging the error.
type ErrorHandlerFunc ¶
The ErrorHandlerFunc type is an adapter to allow the use of ordinary function as ErrorHandler. If f is a function with the appropriate signature, ErrorHandlerFunc(f) is a ErrorHandler that calls f.
type Handler ¶
type Handler interface {
ServeGRPC(ctx context.Context, request interface{}) (context.Context, interface{}, error)
}
Handler which should be called from the gRPC binding of the service implementation. The incoming request parameter, and returned response parameter, are both gRPC types, not user-domain.
type LogErrorHandler ¶
type LogErrorHandler struct {
// contains filtered or unexported fields
}
LogErrorHandler is a transport error handler implementation which logs an error.
func NewLogErrorHandler ¶
func NewLogErrorHandler(com string) *LogErrorHandler
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps an endpoint and implements grpc.Handler.
func NewHandler ¶
func NewHandler(svc Service, options ...ServerOption) *Server
func NewServer ¶
func NewServer( e Endpoint, dec DecodeRequestFunc, enc EncodeResponseFunc, options ...ServerOption, ) *Server
NewServer constructs a new server, which implements wraps the provided endpoint and implements the Handler interface. Consumers should write bindings that adapt the concrete gRPC methods from their compiled protobuf definitions to individual handlers. Request and response objects are from the caller business domain, not gRPC request and reply types.
type ServerFinalizerFunc ¶
ServerFinalizerFunc can be used to perform work at the end of an gRPC request, after the response has been written to the client.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption sets an optional parameter for servers.
func ServerAfter ¶
func ServerAfter(after ...ServerResponseFunc) ServerOption
ServerAfter functions are executed on the gRPC response writer after the endpoint is invoked, but before anything is written to the client.
func ServerBefore ¶
func ServerBefore(before ...ServerRequestFunc) ServerOption
ServerBefore functions are executed on the gRPC request object before the request is decoded.
type ServerRequestFunc ¶
ServerRequestFunc may take information from the received metadata header and use it to place items in the request scoped context. ServerRequestFuncs are executed prior to invoking the endpoint.
type ServerResponseFunc ¶
type ServerResponseFunc func(ctx context.Context, header *metadata.MD, trailer *metadata.MD) context.Context
ServerResponseFunc may take information from a request context and use it to manipulate the gRPC response metadata headers and trailers. ResponseFuncs are only executed in servers, after invoking the endpoint but prior to writing a response.
type Service ¶
type Service interface { Endpoint() Endpoint DecodeRequest(ctx context.Context, req interface{}) (interface{}, error) EncodeResponse(ctx context.Context, resp interface{}) (interface{}, error) ServerBefore() ServerOption ServerAfter() ServerOption GetLogger() grpclog.DepthLoggerV2 Name() string }