Documentation ¶
Index ¶
- Variables
- func ExtractChannel(ctx context.Context) (string, error)
- func ExtractMSPID(ctx context.Context) (string, error)
- func GetLastError(ctx context.Context) error
- func GetRequestID(ctx context.Context) string
- func InterceptRequestID(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func InterceptStandaloneErrors(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func StreamServerLoggerInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func StreamServerRequestLogger(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func UnaryServerLoggerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func UnaryServerRequestLogger(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func WithChannel(ctx context.Context, channel string) context.Context
- func WithLastError(ctx context.Context, err error) context.Context
- type ChannelInterceptor
- type MSPIDInterceptor
- type RetryChecker
- type RetryInterceptor
Constants ¶
This section is empty.
Variables ¶
var ( // CtxMSPIDKey is the identifier of the MSPID in context. // Prefer the convenient ExtractMSPID method to retrieve the MSPID from context. CtxMSPIDKey = &ctxMSPIDMarker{} )
var IgnoredMethods = [...]string{
"grpc.health",
}
var RequestIDMarker = &requestIDMarker{}
RequestIDMarker is the identifier of the RequestID in context.
Functions ¶
func ExtractChannel ¶
ExtractChannel retrieves channel from request context channel is expected to be set by InterceptChannel
func ExtractMSPID ¶
ExtractMSPID retrieves MSPID from request context MSPID is expected to be set by InterceptMSPID
func GetLastError ¶
GetLastError returns the last error in a retry context
func GetRequestID ¶
GetRequestID extracts the request ID from context. Returns an empty string if context does not contain an ID.
func InterceptRequestID ¶
func InterceptRequestID(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
InterceptRequestID adds a unique identifier to the context. This identifier is retrieved from query header "reqid" and is generated if there is no such header.
func InterceptStandaloneErrors ¶
func InterceptStandaloneErrors(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
InterceptStandaloneErrors is a gRPC interceptor which converts orchestration errors into nice gRPC ones. This allows clients to properly take action based on the returned status.
func StreamServerLoggerInterceptor ¶
func StreamServerLoggerInterceptor( srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, ) error
StreamServerLoggerInterceptor adds a logger to the context.
func StreamServerRequestLogger ¶
func StreamServerRequestLogger( srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, ) error
StreamServerRequestLogger logs gRPC responses
func UnaryServerLoggerInterceptor ¶
func UnaryServerLoggerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerLoggerInterceptor adds a logger to the context.
func UnaryServerRequestLogger ¶
func UnaryServerRequestLogger(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerRequestLogger log every gRPC response
func WithChannel ¶
WithChannel add channel information to a context
Types ¶
type ChannelInterceptor ¶
type ChannelInterceptor struct {
// contains filtered or unexported fields
}
ChannelInterceptor intercepts gRPC requests and makes the channel from headers available to request context. It will return an error if a caller attempts to call the orchestrator for a channel it is not part of.
func NewChannelInterceptor ¶
func NewChannelInterceptor(config *common.OrchestratorConfiguration) *ChannelInterceptor
NewChannelInterceptor creates a ChannelInterceptor which will enforce organization & channel consistency. ChannelInterceptor MUST come after the mspid interceptor.
func (*ChannelInterceptor) StreamServerInterceptor ¶
func (i *ChannelInterceptor) StreamServerInterceptor( srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, ) error
StreamServerInterceptor will make the channel from headers available from the request context.
func (*ChannelInterceptor) UnaryServerInterceptor ¶
func (i *ChannelInterceptor) UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerInterceptor will make the channel from headers available from the request context.
type MSPIDInterceptor ¶
type MSPIDInterceptor struct {
// contains filtered or unexported fields
}
func NewMSPIDInterceptor ¶
func NewMSPIDInterceptor() (*MSPIDInterceptor, error)
NewMSPIDInterceptor instanciate a new interceptor
func (*MSPIDInterceptor) StreamServerInterceptor ¶
func (i *MSPIDInterceptor) StreamServerInterceptor( srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler, ) error
StreamServerInterceptor enforces MSPID presence in context
func (*MSPIDInterceptor) UnaryServerInterceptor ¶
func (i *MSPIDInterceptor) UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerInterceptor enforces MSPID presence in context
type RetryChecker ¶
RetryChecker determines if a request should be retried. It receives the returned error and elapsed time since first attempt.
type RetryInterceptor ¶
type RetryInterceptor struct {
// contains filtered or unexported fields
}
RetryInterceptor will retry a failed request according to its checker decision and time budget.
func NewRetryInterceptor ¶
func NewRetryInterceptor(retryBudget time.Duration, checker RetryChecker) *RetryInterceptor
func (*RetryInterceptor) UnaryServerInterceptor ¶
func (ri *RetryInterceptor) UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)