Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorHandler(ctx context.Context, mux *runtime.ServeMux, m runtime.Marshaler, ...)
- func FinishTrace(ctx context.Context, _ http.ResponseWriter, _ proto2.Message) error
- func HandleErr(ctx context.Context, logger *zap.Logger, err error) error
- func HandlerWithLogger(handler http.Handler, logger *zap.Logger) http.Handler
- func HandlerWithRecovery(handler http.Handler, logger *zap.Logger) http.Handler
- func LoggerFromContext(ctx context.Context) *zap.Logger
- func LoggerInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor
- func LoggerWithSpan(ctx context.Context, l *zap.Logger) *zap.Logger
- func PanicInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor
- func PanicStreamInterceptor(logger *zap.Logger) grpc.StreamServerInterceptor
- func RequestContextWithLogger(req *http.Request, logger *zap.Logger) *http.Request
- func SetHTTPStatus(ctx context.Context, w http.ResponseWriter, _ proto2.Message) error
- func SetHeader(ctx context.Context, code int)
- func SetSpanResource(ctx context.Context)
- type DefaultStoreLoader
- type ErrClient
- type Message
- type SpanValue
- type StoreLoadErr
- type StoreLoader
Constants ¶
View Source
const ( // ContextKeyCluster is the key used to put and retrieve // `*model.RequestCluster` into context. ContextKeyCluster contextKey = iota )
View Source
const (
StatusCodeKey = "koko-status-code"
)
Variables ¶
View Source
var LoggerKey loggerKey
View Source
var SpanKey spanKey
Functions ¶
func ErrorHandler ¶
func FinishTrace ¶
func HandlerWithLogger ¶
func HandlerWithRecovery ¶
HandlerWithRecovery is http handler middleware that gracefully handles panics by calling a deferred recover for all wrapped handlers. When a panic is encountered, a generic error message and response code 500 are returned to the client. More detailed error information is logged if the service log level is set to Error or higher.
func LoggerInterceptor ¶
func LoggerInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor
func PanicInterceptor ¶
func PanicInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor
PanicInterceptor wraps the panic recovery handler grpcRecoveryHandler for use as a UnaryServerInterceptor.
func PanicStreamInterceptor ¶
func PanicStreamInterceptor(logger *zap.Logger) grpc.StreamServerInterceptor
PanicStreamInterceptor wraps the panic recovery handler grpcRecoveryHandler for use as a StreamServerInterceptor.
func SetHTTPStatus ¶
func SetSpanResource ¶
Types ¶
type DefaultStoreLoader ¶
func (DefaultStoreLoader) Load ¶
func (d DefaultStoreLoader) Load(_ context.Context, _ *model.RequestCluster, ) (store.Store, error)
type StoreLoadErr ¶
func (StoreLoadErr) Error ¶
func (s StoreLoadErr) Error() string
type StoreLoader ¶
type StoreLoader interface { // Load returns the store to use for the request and cluster. // Cluster is derived from request and maybe nil. // Ctx is specific to request. It may be expanded in future to include // HTTP metadata as needed. // If err is of type StoreLoadErr, // corresponding GRPC status code and message are returned to the client. // For any other error, an internal error is returned to the client Load(ctx context.Context, cluster *model.RequestCluster) (store.Store, error) }
Click to show internal directories.
Click to hide internal directories.