Documentation
¶
Index ¶
- Constants
- Variables
- func GetLogMetadata(ctx context.Context) map[string]any
- func IsHTTPErrorWithStatus(err error, status int) bool
- func IsTwirpErrorCode(err error, code twirp.ErrorCode) bool
- func ListenAndServeContext(ctx context.Context, server *http.Server) error
- func LoggingHooks(logger *slog.Logger, scopesFunc func(context.Context) string) *twirp.ServerHooks
- func NewTwirpMetricsHooks(opts ...TwirpMetricOptionFunc) (*twirp.ServerHooks, error)
- func RHandleFunc(fn func(http.ResponseWriter, *http.Request, httprouter.Params) error) httprouter.Handle
- func ResolveParameter(ctx context.Context, c *cli.Context, src ParameterSource, name string) (string, error)
- func SetAuthInfo(ctx context.Context, info *AuthInfo) context.Context
- func SetLogMetadata(ctx context.Context, key string, value any)
- func SetUpLogger(logLevel string, w io.Writer) *slog.Logger
- func UnmarshalFile(path string, o interface{}) error
- func UnmarshalHTTPResource(resURL string, o interface{}) error
- func WithLogMetadata(ctx context.Context) context.Context
- type AuthInfo
- type GracefulShutdown
- func (gs *GracefulShutdown) CancelOnQuit(ctx context.Context) context.Context
- func (gs *GracefulShutdown) CancelOnStop(ctx context.Context) context.Context
- func (gs *GracefulShutdown) ShouldQuit() <-chan struct{}
- func (gs *GracefulShutdown) ShouldStop() <-chan struct{}
- func (gs *GracefulShutdown) Stop()
- type HTTPClientInstrumentation
- type HTTPError
- type HealthServer
- type JWTClaims
- type LazySSM
- type ParameterSource
- type ReadyFunc
- type ReadyResult
- type TwirpMetricOptionFunc
- type TwirpMetricsOptions
Constants ¶
View Source
const ( // LogKeyLogLevel is the log level that an application was configured // with. LogKeyLogLevel = "log_level" // LogKeyError is an error message. LogKeyError = "err" // LogKeyErrorCode is an error code. LogKeyErrorCode = "err_code" // LogKeyErrorMeta is a JSON object with error metadata. LogKeyErrorMeta = "err_meta" // LogKeyCountMetric was planned to be used to increment a given metric // when used. TODO: not implemented yet, should it be removed? LogKeyCountMetric = "count_metric" // LogKeyDocumentUUID is the UUID of a document. LogKeyDocumentUUID = "document_uuid" // LogKeyTransaction is the name of a transaction, usually used to // identify a transaction that has failed. LogKeyTransaction = "transaction" // LogKeyOCSource is used to identify a source document from OC by UUID. LogKeyOCSource = "oc_source" // LogKeyOCVersion is the version of the OC document. LogKeyOCVersion = "oc_version" // LogKeyOCEvent is the type of an OC event- or content-log event. LogKeyOCEvent = "oc_event" // LogKeyChannel identifies a notification channel. LogKeyChannel = "channel" // LogKeyMessage can be used to log a unexpected message. LogKeyMessage = "message" // LogKeyDelay can be used to communicate the delay when logging // information about retry attempts and backoff delays. LogKeyDelay = "delay" // LogKeyBucket is used to log a S3 bucket name. LogKeyBucket = "bucket" // LogKeyObjectKey is used to log a S3 object key. LogKeyObjectKey = "object_key" // LogKeyComponent is used to communicate what application subcomponent // the log entry is from. LogKeyComponent = "component" // LogKeyCount is used to communicate a count. LogKeyCount = "count" // LogKeyEventID is the ID of an event. LogKeyEventID = "event_id" // LogKeyEventType is the type of an event. LogKeyEventType = "event_type" // LogKeyJobLock is the name of a job lock. LogKeyJobLock = "job_lock" // LogKeyJobLockID is the ID of a job lock. LogKeyJobLockID = "job_lock_id" // LogKeyState is the name of a state, like "held", "lost" or "accepted". LogKeyState = "state" // LogKeyIndex is the name of a search index, like an Open Search index. LogKeyIndex = "index" // LogKeyRoute is used to name a route or path. LogKeyRoute = "route" // LogKeyService is used to specify an RPC service. LogKeyService = "service" // LogKeyMethod is used to specify an RPC method. LogKeyMethod = "method" // LogKeySubject is the sub of an authenticated client. LogKeySubject = "sub" // LogKeyScopes are the scopes of the authenticated client. LogKeyScopes = "scopes" // LogKeyStatusCode is the HTTP status code used for a response. LogKeyStatusCode = "status_code" )
Log attribute keys used throughout the application.
Variables ¶
View Source
var ErrNoAuthorization = errors.New("no authorization provided")
Functions ¶
func IsHTTPErrorWithStatus ¶
func ListenAndServeContext ¶
func LoggingHooks ¶ added in v0.5.0
func NewTwirpMetricsHooks ¶ added in v0.4.0
func NewTwirpMetricsHooks(opts ...TwirpMetricOptionFunc) (*twirp.ServerHooks, error)
NewTwirpMetricsHooks creates new twirp hooks enabling prometheus metrics.
func RHandleFunc ¶
func RHandleFunc( fn func(http.ResponseWriter, *http.Request, httprouter.Params) error, ) httprouter.Handle
func ResolveParameter ¶
func SetAuthInfo ¶ added in v0.6.0
func SetLogMetadata ¶ added in v0.5.0
func SetUpLogger ¶
SetUpLogger creates a default JSON logger and sets it as the global logger.
func UnmarshalFile ¶
func UnmarshalHTTPResource ¶
Types ¶
type AuthInfo ¶ added in v0.6.0
type AuthInfo struct {
Claims JWTClaims
}
func AuthInfoFromHeader ¶ added in v0.6.0
type GracefulShutdown ¶ added in v0.4.0
type GracefulShutdown struct {
// contains filtered or unexported fields
}
func NewGracefulShutdown ¶ added in v0.4.0
func NewGracefulShutdown(logger *slog.Logger, timeout time.Duration) *GracefulShutdown
func (*GracefulShutdown) CancelOnQuit ¶ added in v0.4.0
func (gs *GracefulShutdown) CancelOnQuit(ctx context.Context) context.Context
func (*GracefulShutdown) CancelOnStop ¶ added in v0.4.0
func (gs *GracefulShutdown) CancelOnStop(ctx context.Context) context.Context
func (*GracefulShutdown) ShouldQuit ¶ added in v0.4.0
func (gs *GracefulShutdown) ShouldQuit() <-chan struct{}
func (*GracefulShutdown) ShouldStop ¶ added in v0.4.0
func (gs *GracefulShutdown) ShouldStop() <-chan struct{}
func (*GracefulShutdown) Stop ¶ added in v0.4.0
func (gs *GracefulShutdown) Stop()
type HTTPClientInstrumentation ¶ added in v0.4.0
type HTTPClientInstrumentation struct {
// contains filtered or unexported fields
}
func NewHTTPClientIntrumentation ¶ added in v0.4.0
func NewHTTPClientIntrumentation( registerer prometheus.Registerer, ) (*HTTPClientInstrumentation, error)
type HealthServer ¶
type HealthServer struct {
// contains filtered or unexported fields
}
HealthServer exposes health endpoints, metrics, and PPROF endpoints.
func NewHealthServer ¶
func NewHealthServer(addr string) *HealthServer
func (*HealthServer) AddReadyFunction ¶
func (s *HealthServer) AddReadyFunction(name string, fn ReadyFunc)
func (*HealthServer) Close ¶
func (s *HealthServer) Close() error
func (*HealthServer) ListenAndServe ¶
func (s *HealthServer) ListenAndServe(ctx context.Context) error
type JWTClaims ¶ added in v0.6.0
type JWTClaims struct { jwt.RegisteredClaims Name string `json:"sub_name"` Scope string `json:"scope"` Units []string `json:"units,omitempty"` }
func (JWTClaims) HasAnyScope ¶ added in v0.6.0
type LazySSM ¶
type LazySSM struct {
// contains filtered or unexported fields
}
func NewLazySSM ¶
func NewLazySSM() *LazySSM
type ParameterSource ¶
type ParameterSource interface {
GetParameterValue(ctx context.Context, name string) (string, error)
}
func GetParameterSource ¶
func GetParameterSource(name string) (ParameterSource, error)
type ReadyResult ¶
type TwirpMetricOptionFunc ¶ added in v0.4.0
type TwirpMetricOptionFunc func(opts *TwirpMetricsOptions)
func WithTwirpMetricsRegisterer ¶ added in v0.4.0
func WithTwirpMetricsRegisterer(reg prometheus.Registerer) TwirpMetricOptionFunc
WithTwirpMetricsRegisterer uses a custom registerer for Twirp metrics.
func WithTwirpMetricsStaticTestLatency ¶ added in v0.4.0
func WithTwirpMetricsStaticTestLatency(latency time.Duration) TwirpMetricOptionFunc
WithTwirpMetricsStaticTestLatency configures the RPC metrics to report a static duration.
type TwirpMetricsOptions ¶ added in v0.4.0
type TwirpMetricsOptions struct {
// contains filtered or unexported fields
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.