interceptors

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrorRecorderInterceptor

func NewErrorRecorderInterceptor(registry ErrorRecorder) connect.UnaryInterceptorFunc

NewErrorRecorderInterceptor returns a ConnectRPC unary interceptor that records errors as OTel span events with the error message, first 5 stack frames, and RPC procedure name. It is safe to use when OTel is not configured (span.IsRecording() returns false and the span recording block is a no-op).

When registry is non-nil, every error is also persisted to SQLite via registry.Record for the /ListErrors and /AcknowledgeError RPCs.

func NewFeatureFlagInterceptor

func NewFeatureFlagInterceptor(flagName string, isEnabled func() bool) connect.UnaryInterceptorFunc

NewFeatureFlagInterceptor returns a ConnectRPC unary interceptor that returns connect.CodeNotFound when isEnabled reports false. Use this to gate an entire service handler behind a runtime feature flag so that unauthenticated API calls are rejected even if the caller bypasses the frontend redirect.

isEnabled is called on every request so flag changes are reflected immediately without a server restart. The recommended implementation is:

func() bool { return config.LoadConfig().GetFeatureFlag("backlog") }

Types

type ErrorRecorder

type ErrorRecorder interface {
	Record(ctx context.Context, err error, procedure string)
}

ErrorRecorder is the minimal interface the interceptor needs to persist errors. Implemented by *services.ErrorRegistry; using an interface avoids a circular import.

Jump to

Keyboard shortcuts

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