box

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TracerName = "github.com/jan-xyz/box"

Functions

This section is empty.

Types

type Endpoint

type Endpoint[TIn, TOut any] func(ctx context.Context, req TIn) (TOut, error)

Endpoint is the generic representation of any endpoint which takes a request and returns a reponse.

type Middleware

type Middleware[TIn, TOut any] func(next Endpoint[TIn, TOut]) Endpoint[TIn, TOut]

Middleware is an Endpoint middleware which can be used to wrap around endpoints and decorate them with auxillary functionality, like request logging, instrumentation, context enrichment etc.

func Chain

func Chain[TIn, TOut any](outer Middleware[TIn, TOut], others ...Middleware[TIn, TOut]) Middleware[TIn, TOut]

Chain is a convenience function to chain multiple [Middleware]s together and finally wraps an Endpoint.

func EndpointLogging added in v0.2.0

func EndpointLogging[TIn, TOut any]() Middleware[TIn, TOut]

EndpointLogging logs the requests and response and errors.

func EndpointMetrics added in v0.2.2

func EndpointMetrics[TIn, TOut any](mp metric.MeterProvider) Middleware[TIn, TOut]

EndpointMetrics records RED metrics for your Endpoint. It adds an Endpoint dimension to it. the default dimension value is "Endpoint".

func EndpointTracing added in v0.2.0

func EndpointTracing[TIn, TOut any](tp trace.TracerProvider) Middleware[TIn, TOut]

EndpointTracing adds tracing for the endpoint. The Span name defaults to "Endpoint".

Directories

Path Synopsis
example
strsvc Module
handler

Jump to

Keyboard shortcuts

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