Documentation ¶
Index ¶
- Constants
- Variables
- func AuthClientInterceptor(logger zerolog.Logger, url string, refreshInterval time.Duration, ...) (grpc.UnaryClientInterceptor, error)
- func ClientInterceptors(logger zerolog.Logger, additional ...grpc.UnaryClientInterceptor) grpc.DialOption
- func ClientInterceptorsWithTracing(logger zerolog.Logger, tracer opentracing.Tracer, ...) grpc.DialOption
- func ClientTracingInterceptor(logger zerolog.Logger, tracer opentracing.Tracer) grpc.UnaryClientInterceptor
- func ErrorLoggingServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
- func ErrorMarshallingClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
- func ErrorUnmarshallingServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
- func FromContextMetaData(ctx context.Context) (identity.Identity, error)
- func IdentityClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
- func IdentityServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
- func MapCodeToType(logger zerolog.Logger, code codes.Code) errorKit.Type
- func MapToCode(logger zerolog.Logger, kitError errorKit.Error) codes.Code
- func MapToStatus(logger zerolog.Logger, kitError errorKit.Error) (*status.Status, error)
- func RequestIDClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
- func RequestIDLoggerClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
- func RequestIDLoggerServerInterceptor(parentLogger zerolog.Logger) grpc.UnaryServerInterceptor
- func RequestIDServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
- func ServerInterceptors(logger zerolog.Logger, additional ...grpc.UnaryServerInterceptor) grpc.ServerOption
- func ServerInterceptorsWithTracing(logger zerolog.Logger, tracer opentracing.Tracer, ...) grpc.ServerOption
- func ServerTracingInterceptor(logger zerolog.Logger, tracer opentracing.Tracer) grpc.UnaryServerInterceptor
- type Client
- type ClientConnectionFactory
- type ClientMap
- type Registrar
- type Server
- type ServerOption
Constants ¶
const ( // CodeRPCError is a custom code to support the ErrTypeRPCError Type value CodeRPCError codes.Code = 1000 // CodeBadGateway is a custom code to indicate a failure further downstream to the dependency. CodeBadGateway codes.Code = 1001 // CodeUnprocessableEntity is a custom code to indicates that the server understands the content type of the request entity, // and the syntax of the request entity is correct, but it was unable to process the contained instructions. CodeUnprocessableEntity codes.Code = 1002 // CodeNotModified is a custom code to indicate that the resource has not been modified since the version requested. CodeNotModified codes.Code = 1003 // DomainRPC is a special reserved Domain for handling conversions across GRPC boundaries. DomainRPC errorKit.Domain = "Bread.RPC" // ErrTypeRPCError is a custom code specifically to report internal RPC translate ErrTypeRPCError errorKit.Type = 1000 // ReasonUnknownErrorType indicates the server side error type was not supported ReasonUnknownErrorType grpcInterceptorReason = "Unknown_Error_Type" )
Variables ¶
var EmptyClientConnectionFactory = func(ctx context.Context, serviceName string) (*grpc.ClientConn, error) { return nil, commonError.Error{ Err: fmt.Errorf("service not found %s", serviceName), Type: commonError.NotFound, Message: "error connecting to remote service", } }
Functions ¶
func AuthClientInterceptor ¶ added in v0.0.11
func ClientInterceptors ¶ added in v0.0.4
func ClientInterceptors(logger zerolog.Logger, additional ...grpc.UnaryClientInterceptor) grpc.DialOption
func ClientInterceptorsWithTracing ¶ added in v0.0.4
func ClientInterceptorsWithTracing(logger zerolog.Logger, tracer opentracing.Tracer, additional ...grpc.UnaryClientInterceptor) grpc.DialOption
func ClientTracingInterceptor ¶ added in v0.0.4
func ClientTracingInterceptor(logger zerolog.Logger, tracer opentracing.Tracer) grpc.UnaryClientInterceptor
ClientTracingInterceptor provides support for tracing gRPC client requests
func ErrorLoggingServerInterceptor ¶ added in v0.0.4
func ErrorLoggingServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
ErrorLoggingServerInterceptor logs all errors to the requestIDLogger if it's set, otherwise logs to the provided logger.
func ErrorMarshallingClientInterceptor ¶ added in v0.0.4
func ErrorMarshallingClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
ErrorMarshallingClientInterceptor is a client-side interceptor that ALWAYS returns a `gokit/errors.Error` type for easier consumption by service wrappers.
func ErrorUnmarshallingServerInterceptor ¶ added in v0.0.4
func ErrorUnmarshallingServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
ErrorUnmarshallingServerInterceptor is a server-side interceptor that attempts to always returns a Status with LocalizedMessage details for easier consumption by service clients.
func FromContextMetaData ¶ added in v0.0.11
func IdentityClientInterceptor ¶ added in v0.0.11
func IdentityClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
func IdentityServerInterceptor ¶ added in v0.0.11
func IdentityServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
func MapCodeToType ¶ added in v0.0.4
MapCodeToType takes a grpc error code and returns the appropriate gokit error type for it.
func MapToCode ¶ added in v0.0.4
MapToCode maps to gokit error to grpc code if it exists or else maps tp `codes.Unknown`
func MapToStatus ¶ added in v0.0.4
MapToStatus maps the kit error to grpc status
func RequestIDClientInterceptor ¶ added in v0.0.4
func RequestIDClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
RequestIDClientInterceptor sets an existing RequestID from the Go context onto the GRPC metadata for passing to the server.
func RequestIDLoggerClientInterceptor ¶ added in v0.0.4
func RequestIDLoggerClientInterceptor(logger zerolog.Logger) grpc.UnaryClientInterceptor
RequestIDLoggerClientInterceptor attempts to set the incoming context, the Logger returned from requestidlogger.FromContext.
func RequestIDLoggerServerInterceptor ¶ added in v0.0.4
func RequestIDLoggerServerInterceptor(parentLogger zerolog.Logger) grpc.UnaryServerInterceptor
RequestIDLoggerServerInterceptor uses the requestidlogger package and the provided parentLogger to set a new Child Logger on the context that has the RequestID on its context.
func RequestIDServerInterceptor ¶ added in v0.0.4
func RequestIDServerInterceptor(logger zerolog.Logger) grpc.UnaryServerInterceptor
RequestIDServerInterceptor sets an existing RequestID from the GRPC context metadata onto the context, and uses the new context on the provided UnaryHandler parameter. If there is no RequestID, a new one is generated, and an error is logged to the provided logger.
func ServerInterceptors ¶ added in v0.0.4
func ServerInterceptors(logger zerolog.Logger, additional ...grpc.UnaryServerInterceptor) grpc.ServerOption
func ServerInterceptorsWithTracing ¶ added in v0.0.4
func ServerInterceptorsWithTracing(logger zerolog.Logger, tracer opentracing.Tracer, additional ...grpc.UnaryServerInterceptor) grpc.ServerOption
func ServerTracingInterceptor ¶ added in v0.0.4
func ServerTracingInterceptor(logger zerolog.Logger, tracer opentracing.Tracer) grpc.UnaryServerInterceptor
ServerTracingInterceptor provides support for tracing gRPC server requests
Types ¶
type Client ¶ added in v0.0.8
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v0.0.8
func NewClient(register func(conn *grpc.ClientConn), address string, errors chan<- error, opt ...grpc.DialOption) *Client
func (*Client) Disconnect ¶ added in v0.0.8
type ClientConnectionFactory ¶ added in v0.0.8
type ClientMap ¶ added in v0.0.8
type ClientMap struct {
// contains filtered or unexported fields
}
func NewClientMap ¶ added in v0.0.8
func NewClientMap(configMap map[string]config.GRPCClient, opts ...grpc.DialOption) *ClientMap
func (*ClientMap) GetClientConnection ¶ added in v0.0.8
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewUnstartedServer ¶
func NewUnstartedServer(options ...ServerOption) *Server
func (*Server) RegisterService ¶
type ServerOption ¶
type ServerOption func(options *serverOptions)
func EnableTracing ¶
func EnableTracing(enabled bool) ServerOption
func GRPCOptions ¶
func GRPCOptions(grpcOptions ...grpc.ServerOption) ServerOption
func ShutdownTimeout ¶
func ShutdownTimeout(timeout time.Duration) ServerOption