Documentation
¶
Index ¶
- func CommandLogger(provider interfaces.LoggerProvider, module string) interfaces.Logger
- type Handler
- type HandlerOption
- func WithLogger[T command.Message](logger interfaces.Logger) HandlerOption[T]
- func WithMessageFields[T command.Message](extractor func(T) map[string]any) HandlerOption[T]
- func WithOperation[T command.Message](operation string) HandlerOption[T]
- func WithTelemetry[T command.Message](telemetry Telemetry[T]) HandlerOption[T]
- func WithTimeout[T command.Message](timeout time.Duration) HandlerOption[T]
- type Telemetry
- type TelemetryInfo
- type TelemetryStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandLogger ¶
func CommandLogger(provider interfaces.LoggerProvider, module string) interfaces.Logger
CommandLogger returns a module-scoped logger for command handlers, enriching it with consistent structured fields so command executions align with Phase 7 observability.
Types ¶
type Handler ¶
Handler wraps command execution with shared CMS concerns (context, logging, error tagging).
func NewHandler ¶
func NewHandler[T command.Message](fn command.CommandFunc[T], opts ...HandlerOption[T]) *Handler[T]
NewHandler creates a handler that satisfies go-command's Commander interface while applying CMS-specific concerns (validation, logging, timeout enforcement).
type HandlerOption ¶
HandlerOption configures a Handler instance.
func WithLogger ¶
func WithLogger[T command.Message](logger interfaces.Logger) HandlerOption[T]
WithLogger injects the logger used during execution. Defaults to a no-op logger.
func WithMessageFields ¶
func WithMessageFields[T command.Message](extractor func(T) map[string]any) HandlerOption[T]
WithMessageFields attaches message-derived fields to every log entry for the command.
func WithOperation ¶
func WithOperation[T command.Message](operation string) HandlerOption[T]
WithOperation sets a human-friendly operation name emitted with every log entry.
func WithTelemetry ¶
func WithTelemetry[T command.Message](telemetry Telemetry[T]) HandlerOption[T]
WithTelemetry registers an optional telemetry callback invoked after execution completes.
func WithTimeout ¶
func WithTimeout[T command.Message](timeout time.Duration) HandlerOption[T]
WithTimeout overrides the default execution timeout.
type Telemetry ¶
type Telemetry[T command.Message] func(ctx context.Context, msg T, info TelemetryInfo)
Telemetry represents an optional callback invoked after command execution.
func DefaultTelemetry ¶
func DefaultTelemetry[T command.Message](logger interfaces.Logger) Telemetry[T]
DefaultTelemetry returns a telemetry callback that logs command outcomes with the supplied logger.
type TelemetryInfo ¶
type TelemetryInfo struct {
Command string
Operation string
Fields map[string]any
Duration time.Duration
Error error
Status TelemetryStatus
Logger interfaces.Logger
}
TelemetryInfo describes a command execution outcome provided to telemetry callbacks.
type TelemetryStatus ¶
type TelemetryStatus string
TelemetryStatus captures the result category for command execution.
const ( // TelemetryStatusSuccess indicates the command completed without errors. TelemetryStatusSuccess TelemetryStatus = "success" // TelemetryStatusFailed indicates the command execution returned an error. TelemetryStatusFailed TelemetryStatus = "failed" // TelemetryStatusContextError indicates execution failed due to context cancellation or deadline. TelemetryStatusContextError TelemetryStatus = "context_error" )