Documentation
¶
Index ¶
- Constants
- Variables
- func CanonicalCommandID(msg any) (string, error)
- func Checkpoint(ctx context.Context, checkpoint string, opts ...ProgressOption)
- func CloneCommandRunMetadata(metadata map[string]any) map[string]any
- func CommandRunRevisionFromContext(ctx context.Context) (uint64, bool)
- func ContextWithCommandProgressReporter(ctx context.Context, reporter CommandProgressReporter) context.Context
- func ContextWithCommandRunAttempt(ctx context.Context, attempt CommandRunAttempt) context.Context
- func ContextWithCommandRunAttemptTracker(ctx context.Context) context.Context
- func ContextWithCommandRunRevision(ctx context.Context, last uint64) context.Context
- func ContextWithDispatchOptions(ctx context.Context, opts DispatchOptions) context.Context
- func ContextWithDispatchProvenance(ctx context.Context, provenance DispatchProvenance) context.Context
- func ContextWithDispatchRun(ctx context.Context, run DispatchRunContext) context.Context
- func ContextWithForcedLocalDispatch(ctx context.Context) context.Context
- func ContextWithResult[T any](ctx context.Context, result *Result[T]) context.Context
- func DefaultPanicLogger(funcName string, err any, stack []byte, fields ...map[string]any)
- func ForcedLocalDispatchFromContext(ctx context.Context) bool
- func GetGoroutineID() uint64
- func GetMessageType(msg any) string
- func IsNilMessage(msg any) bool
- func MakePanicHandler(logger PanicLogger) func(funcName string, fields ...map[string]any)
- func NewDispatchRejectedError(commandID string, receipt DispatchReceipt) *errors.Error
- func NewDynamicMessageTypeMismatchError(reg MessageRegistration, actual any) *errors.Error
- func NewDynamicResultMissingError(reg MessageRegistration) *errors.Error
- func NewDynamicResultTypeMismatchError(reg MessageRegistration, actual any) *errors.Error
- func NewInvalidDispatchRouteError(route DispatchRoute) *errors.Error
- func NewLocalInvocationRequiredError(reg MessageRegistration) *errors.Error
- func NewPlacementResolutionError(reg MessageRegistration, source error) *errors.Error
- func NewQueueMultiHandlerUnsupportedError(commandID string, handlerCount int) *errors.Error
- func NewRegistrationConflictError(kind HandlerKind, key string) *errors.Error
- func NewRegistrationInvalidError(message string, metadata map[string]any) *errors.Error
- func NewRegistrationNotFoundError(kind HandlerKind, key string) *errors.Error
- func NewRegistrationProviderNotConfiguredError() *errors.Error
- func NewRemoteDispatcherNotConfiguredError(reg MessageRegistration, route DispatchRoute) *errors.Error
- func NextCommandRunRevision(ctx context.Context) uint64
- func NilCronRegister(opts HandlerConfig, handler any) error
- func NilRPCRegister(opts RPCConfig, handler any, meta CommandMeta) error
- func Progress(ctx context.Context, current, total int64, opts ...ProgressOption)
- func RecordCommandRunAttempt(ctx context.Context, attempt CommandRunAttempt)
- func ValidateCommandDispatchRequest(req CommandDispatchRequest) error
- func ValidateCommandDispatchResponse(resp CommandDispatchResponse) error
- func ValidateDedupPolicy(policy DedupPolicy) error
- func ValidateDispatchOptions(effectiveMode ExecutionMode, opts DispatchOptions) error
- func ValidateDispatchReceipt(receipt DispatchReceipt) error
- func ValidateDispatchRoute(route DispatchRoute) error
- func ValidateExecutionMode(mode ExecutionMode) error
- func ValidateMessage(msg any) error
- func ValidatePolicyCommandIDs(knownIDs []string, configuredIDs []string) error
- type CLICommand
- type CLIConfig
- type CLIGroup
- type CatalogDescriber
- type CatalogProvider
- type CommandDescriptor
- type CommandDispatchRequest
- type CommandDispatchResponse
- type CommandDispatchValidationError
- type CommandExposure
- type CommandFunc
- type CommandInputField
- type CommandInputSchema
- type CommandInputSchemaProvider
- type CommandMeta
- type CommandOption
- type CommandOptionProvider
- type CommandOptionRequest
- type CommandOptionSourceRef
- type CommandProgressCheckpoint
- type CommandProgressDescriber
- type CommandProgressDescriptor
- type CommandProgressReporter
- type CommandProgressReporterFunc
- type CommandResultDescriptor
- type CommandRunAttempt
- type CommandRunEvent
- type CommandRunMetadataSanitizer
- type CommandRunObserver
- type CommandRunObserverFunc
- type CommandRunPhase
- type CommandRunStatsRecorder
- type CommandRunStatsRecorderFunc
- type CommandRunStore
- type CommandRunStoreFunc
- type Commander
- type CronCommand
- type DedupPolicy
- type DispatchOptions
- type DispatchOutcome
- type DispatchProvenance
- type DispatchReceipt
- type DispatchRoute
- type DispatchRunContext
- type DispatchTarget
- type DynamicResultSink
- type ExecutionMode
- type ExposableCommand
- type HTTPCommand
- type HandlerConfig
- type HandlerKind
- type LocalInvoker
- type Message
- type MessageFactory
- type MessageRegistration
- type MessageRegistrationIndex
- func (i *MessageRegistrationIndex) RegistrationByID(kind HandlerKind, stableID string) (MessageRegistration, bool)
- func (i *MessageRegistrationIndex) RegistrationByMessageType(kind HandlerKind, messageType string) (MessageRegistration, bool)
- func (i *MessageRegistrationIndex) Registrations() []MessageRegistration
- func (i *MessageRegistrationIndex) Replace(registrations []MessageRegistration) error
- type PanicLogger
- type PlacementPoliciesProvider
- type PlacementPolicy
- type PlacementResolver
- type ProgressAwareCommander
- type ProgressOption
- type ProgressUpdate
- type Querier
- type QueryFunc
- type RPCCommand
- type RPCConfig
- type RPCDescriber
- type RPCDescription
- type RegistrationProvider
- type Registry
- func (r *Registry) AddResolver(key string, res Resolver) error
- func (r *Registry) CatalogDescriptor(commandID string) (CommandDescriptor, bool)
- func (r *Registry) CatalogDescriptors() []CommandDescriptor
- func (r *Registry) CatalogDescriptorsByExposure(exposed bool) []CommandDescriptor
- func (r *Registry) CatalogDescriptorsByTag(tags ...string) []CommandDescriptor
- func (r *Registry) GetCLIOptions() ([]kong.Option, error)
- func (r *Registry) HasResolver(key string) bool
- func (r *Registry) Initialize() error
- func (r *Registry) RegisterCatalogDescriptor(descriptor CommandDescriptor) error
- func (r *Registry) RegisterCommand(cmd any) error
- func (r *Registry) RegistrationByID(kind HandlerKind, stableID string) (MessageRegistration, bool)
- func (r *Registry) RegistrationByMessageType(kind HandlerKind, messageType string) (MessageRegistration, bool)
- func (r *Registry) Registrations() []MessageRegistration
- func (r *Registry) SetCronRegister(fn func(opts HandlerConfig, handler any) error) *Registry
- func (r *Registry) SetRPCRegister(fn func(opts RPCConfig, handler any, meta CommandMeta) error) *Registry
- type RemoteDispatcher
- type Resolver
- type Result
- func (r *Result[T]) Error() error
- func (r *Result[T]) GetMetadata(key string) (any, bool)
- func (r *Result[T]) Load() (T, bool)
- func (r *Result[T]) ResultType() reflect.Type
- func (r *Result[T]) Store(value T)
- func (r *Result[T]) StoreDynamic(value any) error
- func (r *Result[T]) StoreError(err error)
- func (r *Result[T]) StoreWithMeta(value T, meta map[string]any)
- type ResultKey
Constants ¶
const ( TextCodeInvalidExecutionMode = "INVALID_EXECUTION_MODE" TextCodeInvalidDedupPolicy = "INVALID_DEDUP_POLICY" TextCodeDispatchOptionsInvalid = "DISPATCH_OPTIONS_INVALID" TextCodeDispatchReceiptInvalid = "DISPATCH_RECEIPT_INVALID" TextCodeUnknownCommandPolicyKey = "UNKNOWN_COMMAND_POLICY_KEY" TextCodeInvalidCommandID = "INVALID_COMMAND_ID" TextCodeQueueMultiHandlerUnsupported = "QUEUE_MULTI_HANDLER_UNSUPPORTED" TextCodeDispatchRequestInvalid = "DISPATCH_REQUEST_INVALID" TextCodeDispatchResponseInvalid = "DISPATCH_RESPONSE_INVALID" )
const ( TextCodeRegistrationNotFound = "REGISTRATION_NOT_FOUND" TextCodeRegistrationConflict = "REGISTRATION_CONFLICT" TextCodeRegistrationInvalid = "REGISTRATION_INVALID" TextCodeRegistrationProviderNotConfigured = "REGISTRATION_PROVIDER_NOT_CONFIGURED" TextCodeDynamicMessageTypeMismatch = "DYNAMIC_MESSAGE_TYPE_MISMATCH" TextCodeDynamicResultTypeMismatch = "DYNAMIC_RESULT_TYPE_MISMATCH" TextCodeDynamicResultMissing = "DYNAMIC_RESULT_MISSING" TextCodePlacementResolutionFailed = "PLACEMENT_RESOLUTION_FAILED" TextCodeInvalidDispatchRoute = "INVALID_DISPATCH_ROUTE" TextCodeRemoteDispatcherNotConfigured = "REMOTE_DISPATCHER_NOT_CONFIGURED" TextCodeLocalInvocationRequired = "LOCAL_INVOCATION_REQUIRED" TextCodeDispatchRejected = "DISPATCH_REJECTED" )
Variables ¶
var ErrValidation = errors.New("validation error", errors.CategoryValidation).
WithTextCode("VALIDATION_FAILED")
ErrValidation is a sentinel error used to mark validation failures. Wrappers can compare errors with errors.Is(err, ErrValidation) to propagate validation intent through additional layers.
Functions ¶
func CanonicalCommandID ¶ added in v0.17.0
CanonicalCommandID resolves a stable command id for policy/dedup paths. It requires an explicit Type() implementation and does not allow reflection-only fallback ids.
func Checkpoint ¶ added in v0.22.0
func Checkpoint(ctx context.Context, checkpoint string, opts ...ProgressOption)
Checkpoint reports a named checkpoint when the context has a reporter.
func CloneCommandRunMetadata ¶ added in v0.22.0
CloneCommandRunMetadata shallow-clones event, run, and progress metadata.
func CommandRunRevisionFromContext ¶ added in v0.24.0
CommandRunRevisionFromContext returns the latest reserved revision.
func ContextWithCommandProgressReporter ¶ added in v0.22.0
func ContextWithCommandProgressReporter(ctx context.Context, reporter CommandProgressReporter) context.Context
ContextWithCommandProgressReporter stores a progress reporter in context.
func ContextWithCommandRunAttempt ¶ added in v0.22.0
func ContextWithCommandRunAttempt(ctx context.Context, attempt CommandRunAttempt) context.Context
ContextWithCommandRunAttempt stores the current attempt for command code.
func ContextWithCommandRunAttemptTracker ¶ added in v0.22.0
ContextWithCommandRunAttemptTracker lets dispatch code read the latest attempt summary after runner execution.
func ContextWithCommandRunRevision ¶ added in v0.24.0
ContextWithCommandRunRevision starts a process-local sequencer from the last revision persisted with a dispatch run. The state is shared by derived contexts so progress reporters and lifecycle emitters allocate one sequence.
func ContextWithDispatchOptions ¶ added in v0.17.0
func ContextWithDispatchOptions(ctx context.Context, opts DispatchOptions) context.Context
func ContextWithDispatchProvenance ¶ added in v0.23.0
func ContextWithDispatchProvenance(ctx context.Context, provenance DispatchProvenance) context.Context
func ContextWithDispatchRun ¶ added in v0.22.0
func ContextWithDispatchRun(ctx context.Context, run DispatchRunContext) context.Context
ContextWithDispatchRun stores command run identity in context.
func ContextWithForcedLocalDispatch ¶ added in v0.23.0
ContextWithForcedLocalDispatch marks a trusted ingress call so nested compatibility APIs execute locally instead of resolving placement again.
func ContextWithResult ¶ added in v0.3.0
Context helpers
func DefaultPanicLogger ¶ added in v0.2.0
func ForcedLocalDispatchFromContext ¶ added in v0.23.0
ForcedLocalDispatchFromContext reports the transport-neutral ingress guard. Payload fields and dispatch metadata cannot create this marker.
func GetGoroutineID ¶ added in v0.2.0
func GetGoroutineID() uint64
func GetMessageType ¶ added in v0.3.0
func IsNilMessage ¶
func MakePanicHandler ¶ added in v0.2.0
func MakePanicHandler(logger PanicLogger) func(funcName string, fields ...map[string]any)
func NewDispatchRejectedError ¶ added in v0.23.3
func NewDispatchRejectedError(commandID string, receipt DispatchReceipt) *errors.Error
NewDispatchRejectedError reports a structurally valid receipt that did not accept the command. APIs that cannot return receipts still surface rejection as a classified error rather than silently reporting success.
func NewDynamicMessageTypeMismatchError ¶ added in v0.23.0
func NewDynamicMessageTypeMismatchError(reg MessageRegistration, actual any) *errors.Error
func NewDynamicResultMissingError ¶ added in v0.23.0
func NewDynamicResultMissingError(reg MessageRegistration) *errors.Error
func NewDynamicResultTypeMismatchError ¶ added in v0.23.0
func NewDynamicResultTypeMismatchError(reg MessageRegistration, actual any) *errors.Error
func NewInvalidDispatchRouteError ¶ added in v0.23.0
func NewInvalidDispatchRouteError(route DispatchRoute) *errors.Error
func NewLocalInvocationRequiredError ¶ added in v0.23.0
func NewLocalInvocationRequiredError(reg MessageRegistration) *errors.Error
func NewPlacementResolutionError ¶ added in v0.23.0
func NewPlacementResolutionError(reg MessageRegistration, source error) *errors.Error
NewPlacementResolutionError classifies resolver failures while retaining structured source metadata when the resolver already returned go-errors.
func NewQueueMultiHandlerUnsupportedError ¶ added in v0.17.0
TODO(BKG_CMD phase 2): enforce this via DispatchWith in queued routing paths.
func NewRegistrationConflictError ¶ added in v0.23.0
func NewRegistrationConflictError(kind HandlerKind, key string) *errors.Error
func NewRegistrationInvalidError ¶ added in v0.23.0
func NewRegistrationNotFoundError ¶ added in v0.23.0
func NewRegistrationNotFoundError(kind HandlerKind, key string) *errors.Error
func NewRegistrationProviderNotConfiguredError ¶ added in v0.23.0
func NewRemoteDispatcherNotConfiguredError ¶ added in v0.23.0
func NewRemoteDispatcherNotConfiguredError(reg MessageRegistration, route DispatchRoute) *errors.Error
func NextCommandRunRevision ¶ added in v0.24.0
NextCommandRunRevision atomically reserves the next lifecycle revision.
func NilCronRegister ¶ added in v0.3.0
func NilCronRegister(opts HandlerConfig, handler any) error
func NilRPCRegister ¶ added in v0.15.0
func NilRPCRegister(opts RPCConfig, handler any, meta CommandMeta) error
NilRPCRegister is a noop RPC registration function.
func Progress ¶ added in v0.22.0
func Progress(ctx context.Context, current, total int64, opts ...ProgressOption)
Progress reports current and total counts when the context has a reporter.
func RecordCommandRunAttempt ¶ added in v0.22.0
func RecordCommandRunAttempt(ctx context.Context, attempt CommandRunAttempt)
RecordCommandRunAttempt records the latest runner attempt when a tracker is present in context.
func ValidateCommandDispatchRequest ¶ added in v0.21.0
func ValidateCommandDispatchRequest(req CommandDispatchRequest) error
ValidateCommandDispatchRequest checks the reusable dispatch payload shape.
func ValidateCommandDispatchResponse ¶ added in v0.21.0
func ValidateCommandDispatchResponse(resp CommandDispatchResponse) error
ValidateCommandDispatchResponse checks reusable response and field error shapes without assuming a specific renderer.
func ValidateDedupPolicy ¶ added in v0.17.0
func ValidateDedupPolicy(policy DedupPolicy) error
func ValidateDispatchOptions ¶ added in v0.17.0
func ValidateDispatchOptions(effectiveMode ExecutionMode, opts DispatchOptions) error
func ValidateDispatchReceipt ¶ added in v0.17.0
func ValidateDispatchReceipt(receipt DispatchReceipt) error
func ValidateDispatchRoute ¶ added in v0.23.0
func ValidateDispatchRoute(route DispatchRoute) error
func ValidateExecutionMode ¶ added in v0.17.0
func ValidateExecutionMode(mode ExecutionMode) error
func ValidateMessage ¶ added in v0.3.0
func ValidatePolicyCommandIDs ¶ added in v0.17.0
Types ¶
type CLICommand ¶ added in v0.3.0
type CLIConfig ¶ added in v0.3.0
type CatalogDescriber ¶ added in v0.21.0
type CatalogDescriber interface {
CommandDescriptor() CommandDescriptor
}
CatalogDescriber lets a command provide its own descriptor.
type CatalogProvider ¶ added in v0.21.0
type CatalogProvider interface {
CommandDescriptors() []CommandDescriptor
}
CatalogProvider lets hosts provide descriptors externally.
type CommandDescriptor ¶ added in v0.21.0
type CommandDescriptor struct {
ID string `json:"id"`
MessageType string `json:"message_type,omitempty"`
Label string `json:"label,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Domain string `json:"domain,omitempty"`
Group string `json:"group,omitempty"`
Tags []string `json:"tags,omitempty"`
ExposeInAdmin bool `json:"expose_in_admin,omitempty"`
Mutating bool `json:"mutating,omitempty"`
ExecutionMode ExecutionMode `json:"execution_mode,omitempty"`
Permissions []string `json:"permissions,omitempty"`
Roles []string `json:"roles,omitempty"`
Exposure CommandExposure `json:"exposure,omitempty"`
RPC RPCConfig `json:"rpc,omitempty"`
Input CommandInputSchema `json:"input,omitempty"`
Result CommandResultDescriptor `json:"result,omitempty"`
Progress *CommandProgressDescriptor `json:"progress,omitempty"`
DisplayHints map[string]any `json:"display_hints,omitempty"`
RedactionHints []string `json:"redaction_hints,omitempty"`
}
CommandDescriptor is the reusable command catalog contract. It describes an intentionally exposed command without importing an admin UI or transport.
func DescriptorForCommand ¶ added in v0.21.0
func DescriptorForCommand(cmd any, meta CommandMeta) (CommandDescriptor, bool)
DescriptorForCommand returns the merged descriptor for an exposed command.
func MergeCommandDescriptor ¶ added in v0.21.0
func MergeCommandDescriptor(meta CommandMeta, exposure CommandExposure, rpcConfig RPCConfig, explicit CommandDescriptor) CommandDescriptor
MergeCommandDescriptor composes message, exposure, RPC, and explicit descriptor metadata. Explicit descriptor fields take precedence.
type CommandDispatchRequest ¶ added in v0.21.0
type CommandDispatchRequest struct {
CommandID string `json:"command_id,omitempty"`
Name string `json:"name,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
IDs []string `json:"ids,omitempty"`
Options DispatchOptions `json:"options,omitempty"`
}
CommandDispatchRequest is the canonical generic command dispatch payload. Transports should wrap this in rpc.RequestEnvelope.
func (CommandDispatchRequest) ResolvedCommandID ¶ added in v0.21.0
func (r CommandDispatchRequest) ResolvedCommandID() string
ResolvedCommandID returns the stable command id, accepting Name only as a compatibility alias for older admin dispatch callers.
type CommandDispatchResponse ¶ added in v0.21.0
type CommandDispatchResponse struct {
Receipt DispatchReceipt `json:"receipt"`
Result any `json:"result,omitempty"`
StatusReference string `json:"status_reference,omitempty"`
ValidationErrors []CommandDispatchValidationError `json:"validation_errors,omitempty"`
}
CommandDispatchResponse is the canonical generic command dispatch response. Transports should wrap this in rpc.ResponseEnvelope.
type CommandDispatchValidationError ¶ added in v0.21.0
type CommandDispatchValidationError struct {
Path string `json:"path,omitempty"`
Code string `json:"code,omitempty"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
CommandDispatchValidationError is safe for browser display and preserves a payload path so renderers can map validation failures to fields.
type CommandExposure ¶ added in v0.13.0
type CommandExposure struct {
// ExposeInAdmin signals this command can be listed in go-admin UI/REPL.
ExposeInAdmin bool
// Tags for grouping/filtering in UI (e.g. "debug", "ops").
Tags []string
// Permissions required to execute (admin will enforce).
// If empty, consumers should derive defaults from Mutates.
Permissions []string
// Roles allowed to execute (optional).
Roles []string
// Mutates signals side effects; false implies read-only.
Mutates bool
}
CommandExposure declares optional UI/REPL exposure metadata. The zero value is safe: ExposeInAdmin is false and Mutates is read-only.
func ExposureOf ¶ added in v0.13.0
func ExposureOf(cmd any) (CommandExposure, bool)
ExposureOf returns exposure metadata if cmd implements ExposableCommand.
type CommandFunc ¶
CommandFunc is an adapter that lets you use a function as a CommandHandler[T]
type CommandInputField ¶ added in v0.21.0
type CommandInputField struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path"`
Label string `json:"label,omitempty"`
Kind string `json:"kind,omitempty"`
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Required bool `json:"required,omitempty"`
Default any `json:"default,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Description string `json:"description,omitempty"`
Help string `json:"help,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
StaticOptions []CommandOption `json:"static_options,omitempty"`
OptionSource *CommandOptionSourceRef `json:"option_source,omitempty"`
Validation map[string]any `json:"validation,omitempty"`
DisplayHints map[string]any `json:"display_hints,omitempty"`
}
CommandInputField describes one stable payload target.
type CommandInputSchema ¶ added in v0.21.0
type CommandInputSchema struct {
Type string `json:"type,omitempty"`
Fields []CommandInputField `json:"fields,omitempty"`
Required []string `json:"required,omitempty"`
JSONSchema map[string]any `json:"json_schema,omitempty"`
Extensions map[string]any `json:"extensions,omitempty"`
NoInput bool `json:"no_input,omitempty"`
}
CommandInputSchema is a renderer-neutral, JSON Schema/OpenAPI-compatible payload description. Consumers can translate it to go-formgen or another UI.
func CommandInputSchemaFromMessage ¶ added in v0.21.0
func CommandInputSchemaFromMessage(msg any) CommandInputSchema
CommandInputSchemaFromMessage derives a minimal payload schema from exported struct fields. Sensitive fields marked with catalog:"sensitive" or command:"sensitive" are intentionally skipped.
type CommandInputSchemaProvider ¶ added in v0.21.0
type CommandInputSchemaProvider interface {
CommandInputSchema() CommandInputSchema
}
CommandInputSchemaProvider lets a command provide late-bound schema metadata without coupling to a renderer.
type CommandMeta ¶ added in v0.11.0
func MessageTypeForCommand ¶ added in v0.11.0
func MessageTypeForCommand(cmd any) CommandMeta
type CommandOption ¶ added in v0.21.0
type CommandOption struct {
Value string `json:"value"`
Label string `json:"label,omitempty"`
Description string `json:"description,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CommandOption is a safe static option value.
type CommandOptionProvider ¶ added in v0.21.0
type CommandOptionProvider interface {
CommandOptions(context.Context, CommandOptionRequest) ([]CommandOption, error)
}
CommandOptionProvider resolves request-scoped option values without coupling go-command descriptors to an admin UI or transport.
type CommandOptionRequest ¶ added in v0.21.0
type CommandOptionRequest struct {
CommandID string `json:"command_id"`
FieldID string `json:"field_id,omitempty"`
FieldName string `json:"field_name,omitempty"`
FieldPath string `json:"field_path,omitempty"`
Source CommandOptionSourceRef `json:"source"`
Payload map[string]any `json:"payload,omitempty"`
}
CommandOptionRequest identifies one request-scoped option lookup. Consumers authorize discovery before invoking a provider.
type CommandOptionSourceRef ¶ added in v0.21.0
type CommandOptionSourceRef struct {
ID string `json:"id"`
Label string `json:"label,omitempty"`
Dynamic bool `json:"dynamic,omitempty"`
CacheScope string `json:"cache_scope,omitempty"`
RedactionHint string `json:"redaction_hint,omitempty"`
Params map[string]any `json:"params,omitempty"`
}
CommandOptionSourceRef references request-scoped dynamic options without serializing the option values in the descriptor.
type CommandProgressCheckpoint ¶ added in v0.22.0
type CommandProgressCheckpoint struct {
ID string `json:"id"`
Label string `json:"label,omitempty"`
Description string `json:"description,omitempty"`
Order int `json:"order,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CommandProgressCheckpoint describes a named checkpoint that a command may report.
type CommandProgressDescriber ¶ added in v0.22.0
type CommandProgressDescriber interface {
CommandProgressDescriptor() CommandProgressDescriptor
}
CommandProgressDescriber lets a command provide optional progress metadata.
type CommandProgressDescriptor ¶ added in v0.22.0
type CommandProgressDescriptor struct {
Units string `json:"units,omitempty"`
Total int64 `json:"total,omitempty"`
Checkpoints []CommandProgressCheckpoint `json:"checkpoints,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CommandProgressDescriptor describes optional, safe progress metadata for a command catalog entry.
type CommandProgressReporter ¶ added in v0.22.0
type CommandProgressReporter interface {
ReportProgress(context.Context, ProgressUpdate)
}
CommandProgressReporter receives cooperative progress updates from commands.
func CommandProgressReporterFromContext ¶ added in v0.22.0
func CommandProgressReporterFromContext(ctx context.Context) (CommandProgressReporter, bool)
CommandProgressReporterFromContext returns the progress reporter, if present.
type CommandProgressReporterFunc ¶ added in v0.22.0
type CommandProgressReporterFunc func(context.Context, ProgressUpdate)
CommandProgressReporterFunc adapts a function into a CommandProgressReporter.
func (CommandProgressReporterFunc) ReportProgress ¶ added in v0.22.0
func (f CommandProgressReporterFunc) ReportProgress(ctx context.Context, update ProgressUpdate)
type CommandResultDescriptor ¶ added in v0.21.0
type CommandResultDescriptor struct {
Inline bool `json:"inline,omitempty"`
Queued bool `json:"queued,omitempty"`
StatusReference string `json:"status_reference,omitempty"`
ReceiptExpected bool `json:"receipt_expected,omitempty"`
ResultSchema map[string]any `json:"result_schema,omitempty"`
RedactionHints []string `json:"redaction_hints,omitempty"`
DisplayHints map[string]any `json:"display_hints,omitempty"`
}
CommandResultDescriptor declares the safe result/receipt expectations.
type CommandRunAttempt ¶ added in v0.22.0
CommandRunAttempt describes the current or final runner attempt.
func CommandRunAttemptFromContext ¶ added in v0.22.0
func CommandRunAttemptFromContext(ctx context.Context) (CommandRunAttempt, bool)
CommandRunAttemptFromContext returns current attempt metadata, if present.
type CommandRunEvent ¶ added in v0.22.0
type CommandRunEvent struct {
RunID string
Revision uint64
DispatchID string
CommandID string
Handler string
HandlerKind HandlerKind
DispatchTarget DispatchTarget
Route string
ExecutionMode ExecutionMode
Phase CommandRunPhase
Checkpoint string
Message string
Current int64
Total int64
CorrelationID string
IdempotencyKey string
Attempt int
MaxAttempts int
OccurredAt time.Time
StartedAt time.Time
Duration time.Duration
Receipt DispatchReceipt
Provenance DispatchProvenance
FailureCategory string
Metadata map[string]any
Error error
}
CommandRunEvent is the transport-neutral event emitted for command run lifecycle and cooperative progress updates.
func (CommandRunEvent) Clone ¶ added in v0.22.0
func (e CommandRunEvent) Clone() CommandRunEvent
Clone returns an event copy with isolated metadata.
type CommandRunMetadataSanitizer ¶ added in v0.22.0
CommandRunMetadataSanitizer transforms safe metadata before forwarding.
type CommandRunObserver ¶ added in v0.22.0
type CommandRunObserver interface {
OnCommandRunEvent(context.Context, CommandRunEvent) error
}
CommandRunObserver receives command run events. Implementations should return errors for host diagnostics only; dispatchers treat observers as fail-open.
func CommandRunStatsObserver ¶ added in v0.22.0
func CommandRunStatsObserver(recorder CommandRunStatsRecorder) CommandRunObserver
CommandRunStatsObserver adapts a stats recorder into a fail-open observer.
func CommandRunStoreObserver ¶ added in v0.22.0
func CommandRunStoreObserver(store CommandRunStore) CommandRunObserver
CommandRunStoreObserver adapts a run store into a fail-open observer.
func SanitizingCommandRunObserver ¶ added in v0.22.0
func SanitizingCommandRunObserver(inner CommandRunObserver, sanitizer CommandRunMetadataSanitizer) CommandRunObserver
SanitizingCommandRunObserver clones and sanitizes metadata before forwarding an event to another observer.
type CommandRunObserverFunc ¶ added in v0.22.0
type CommandRunObserverFunc func(context.Context, CommandRunEvent) error
CommandRunObserverFunc adapts a function into a CommandRunObserver.
func (CommandRunObserverFunc) OnCommandRunEvent ¶ added in v0.22.0
func (f CommandRunObserverFunc) OnCommandRunEvent(ctx context.Context, event CommandRunEvent) error
type CommandRunPhase ¶ added in v0.22.0
type CommandRunPhase string
CommandRunPhase identifies a lifecycle or cooperative progress event.
const ( CommandRunPhaseSubmitted CommandRunPhase = "submitted" CommandRunPhaseStarted CommandRunPhase = "started" CommandRunPhaseCheckpoint CommandRunPhase = "checkpoint" CommandRunPhaseProgress CommandRunPhase = "progress" CommandRunPhaseSucceeded CommandRunPhase = "succeeded" CommandRunPhaseFailed CommandRunPhase = "failed" CommandRunPhaseCanceled CommandRunPhase = "canceled" CommandRunPhaseRejected CommandRunPhase = "rejected" )
type CommandRunStatsRecorder ¶ added in v0.22.0
type CommandRunStatsRecorder interface {
RecordCommandRunEvent(context.Context, CommandRunEvent) error
}
CommandRunStatsRecorder is a small adapter target for counters and metrics.
type CommandRunStatsRecorderFunc ¶ added in v0.22.0
type CommandRunStatsRecorderFunc func(context.Context, CommandRunEvent) error
CommandRunStatsRecorderFunc adapts a function into a stats recorder.
func (CommandRunStatsRecorderFunc) RecordCommandRunEvent ¶ added in v0.22.0
func (f CommandRunStatsRecorderFunc) RecordCommandRunEvent(ctx context.Context, event CommandRunEvent) error
type CommandRunStore ¶ added in v0.22.0
type CommandRunStore interface {
StoreCommandRunEvent(context.Context, CommandRunEvent) error
}
CommandRunStore is a small adapter target for durable or in-memory run stores.
type CommandRunStoreFunc ¶ added in v0.22.0
type CommandRunStoreFunc func(context.Context, CommandRunEvent) error
CommandRunStoreFunc adapts a function into a run store.
func (CommandRunStoreFunc) StoreCommandRunEvent ¶ added in v0.22.0
func (f CommandRunStoreFunc) StoreCommandRunEvent(ctx context.Context, event CommandRunEvent) error
type CronCommand ¶ added in v0.3.0
type CronCommand interface {
CronHandler() func() error
CronOptions() HandlerConfig
}
type DedupPolicy ¶ added in v0.17.0
type DedupPolicy string
const ( DedupPolicyIgnore DedupPolicy = "ignore" DedupPolicyDrop DedupPolicy = "drop" DedupPolicyMerge DedupPolicy = "merge" DedupPolicyReplace DedupPolicy = "replace" )
func NormalizeDedupPolicy ¶ added in v0.17.0
func NormalizeDedupPolicy(policy DedupPolicy) DedupPolicy
func ParseDedupPolicy ¶ added in v0.17.0
func ParseDedupPolicy(raw string) (DedupPolicy, error)
type DispatchOptions ¶ added in v0.17.0
type DispatchOptions struct {
Mode ExecutionMode
IdempotencyKey string
DedupPolicy DedupPolicy
Delay time.Duration
RunAt *time.Time
CorrelationID string
Metadata map[string]any
}
func DispatchOptionsFromContext ¶ added in v0.17.0
func DispatchOptionsFromContext(ctx context.Context) (DispatchOptions, bool)
type DispatchOutcome ¶ added in v0.23.0
type DispatchOutcome struct {
Receipt DispatchReceipt
Target DispatchTarget
Route string
Result any
ResultPresent bool
StatusReference string
}
DispatchOutcome is the transport-neutral result of local or remote execution. ResultPresent distinguishes a valid zero/nil result from no result.
type DispatchProvenance ¶ added in v0.23.0
type DispatchProvenance struct {
IngressKind string
Route string
DeliveryID string
Attempt int
CorrelationID string
CausationID string
}
DispatchProvenance carries transport-neutral ingress identity without exposing broker envelopes or payloads.
func DispatchProvenanceFromContext ¶ added in v0.23.0
func DispatchProvenanceFromContext(ctx context.Context) (DispatchProvenance, bool)
type DispatchReceipt ¶ added in v0.17.0
type DispatchRoute ¶ added in v0.23.0
type DispatchRoute struct {
Target DispatchTarget
Name string
}
DispatchRoute is a logical placement decision. Name is adapter-owned and is intentionally not a broker destination or transport URL.
func NormalizeDispatchRoute ¶ added in v0.23.3
func NormalizeDispatchRoute(route DispatchRoute) DispatchRoute
NormalizeDispatchRoute returns the canonical logical route representation used for validation, adapter invocation, outcomes, and lifecycle events.
type DispatchRunContext ¶ added in v0.22.0
type DispatchRunContext struct {
RunID string
// Revision is the last lifecycle revision reserved by the process handing
// this run to another executor. Persist it with queued work so a worker can
// continue the same monotonic sequence in another process.
Revision uint64
DispatchID string
CommandID string
Handler string
HandlerKind HandlerKind
DispatchTarget DispatchTarget
Route string
ExecutionMode ExecutionMode
CorrelationID string
IdempotencyKey string
Attempt int
MaxAttempts int
StartedAt time.Time
Receipt DispatchReceipt
Provenance DispatchProvenance
Metadata map[string]any
}
DispatchRunContext carries safe run identity and dispatch metadata through a command execution context.
func DispatchRunFromContext ¶ added in v0.22.0
func DispatchRunFromContext(ctx context.Context) (DispatchRunContext, bool)
DispatchRunFromContext returns command run identity, if present.
type DispatchTarget ¶ added in v0.23.0
type DispatchTarget string
DispatchTarget identifies whether a registration executes in this process or through an installed remote dispatcher.
const ( DispatchTargetLocal DispatchTarget = "local" DispatchTargetRemote DispatchTarget = "remote" )
type DynamicResultSink ¶ added in v0.23.0
DynamicResultSink is the type-reporting bridge used when a runtime receives a result without compile-time access to T.
func DynamicResultSinkFromContext ¶ added in v0.23.0
func DynamicResultSinkFromContext(ctx context.Context) (DynamicResultSink, bool)
DynamicResultSinkFromContext returns the untyped view installed by ContextWithResult. Typed callers should continue using ResultFromContext.
type ExecutionMode ¶ added in v0.17.0
type ExecutionMode string
const ( ExecutionModeInline ExecutionMode = "inline" ExecutionModeQueued ExecutionMode = "queued" )
func NormalizeExecutionMode ¶ added in v0.17.0
func NormalizeExecutionMode(mode ExecutionMode) ExecutionMode
func ParseExecutionMode ¶ added in v0.17.0
func ParseExecutionMode(raw string) (ExecutionMode, error)
type ExposableCommand ¶ added in v0.13.0
type ExposableCommand interface {
Exposure() CommandExposure
}
ExposableCommand can be implemented by CLICommand (or any Command/Query). Opt-in is explicit: consumers should ignore commands that do not implement it or return ExposeInAdmin=false.
type HTTPCommand ¶ added in v0.3.0
type HTTPCommand interface {
HTTPHandler()
}
type HandlerConfig ¶ added in v0.3.0
type HandlerKind ¶ added in v0.23.0
type HandlerKind string
HandlerKind identifies which handler capability a registration represents. A concrete handler may expose both command and query registrations.
const ( HandlerKindCommand HandlerKind = "command" HandlerKindQuery HandlerKind = "query" )
type LocalInvoker ¶ added in v0.23.0
type LocalInvoker interface {
InvokeLocal(context.Context, MessageRegistration, any, DispatchOptions) (DispatchOutcome, error)
}
LocalInvoker executes an already-resolved registration in this process.
type Message ¶
type Message interface {
Type() string
}
Message is the interface command and queries messages must implement
type MessageFactory ¶ added in v0.11.0
type MessageFactory interface {
MessageValue() any
}
MessageFactory provides a concrete message value for interface-based commands.
type MessageRegistration ¶ added in v0.23.0
type MessageRegistration interface {
ID() string
MessageType() string
Kind() HandlerKind
NewMessage() any
RequestType() reflect.Type
ResultType() reflect.Type
}
MessageRegistration is immutable metadata for one kind-qualified message. Implementations must return a fresh message from NewMessage.
func MessageRegistrationsForCommand ¶ added in v0.23.0
func MessageRegistrationsForCommand(cmd any) ([]MessageRegistration, error)
MessageRegistrationsForCommand discovers command and query capabilities independently. The legacy MessageTypeForCommand helper intentionally remains query-first for source compatibility.
type MessageRegistrationIndex ¶ added in v0.23.0
type MessageRegistrationIndex struct {
// contains filtered or unexported fields
}
MessageRegistrationIndex atomically publishes complete immutable registration generations.
func NewMessageRegistrationIndex ¶ added in v0.23.0
func NewMessageRegistrationIndex(registrations ...MessageRegistration) (*MessageRegistrationIndex, error)
func (*MessageRegistrationIndex) RegistrationByID ¶ added in v0.23.0
func (i *MessageRegistrationIndex) RegistrationByID(kind HandlerKind, stableID string) (MessageRegistration, bool)
func (*MessageRegistrationIndex) RegistrationByMessageType ¶ added in v0.23.0
func (i *MessageRegistrationIndex) RegistrationByMessageType(kind HandlerKind, messageType string) (MessageRegistration, bool)
func (*MessageRegistrationIndex) Registrations ¶ added in v0.23.0
func (i *MessageRegistrationIndex) Registrations() []MessageRegistration
func (*MessageRegistrationIndex) Replace ¶ added in v0.23.0
func (i *MessageRegistrationIndex) Replace(registrations []MessageRegistration) error
Replace validates a complete generation before publishing it. A failed replacement leaves the previous snapshot active.
type PanicLogger ¶ added in v0.2.0
type PlacementPoliciesProvider ¶ added in v0.23.0
type PlacementPoliciesProvider interface {
PlacementResolver
PlacementPolicies() []PlacementPolicy
}
PlacementPoliciesProvider exposes copied policies so a runtime can validate them against a replacement registration generation.
func NewPlacementPolicySnapshot ¶ added in v0.23.0
func NewPlacementPolicySnapshot(provider RegistrationProvider, policies ...PlacementPolicy) (PlacementPoliciesProvider, error)
type PlacementPolicy ¶ added in v0.23.0
type PlacementPolicy struct {
Kind HandlerKind
RegistrationID string
Route DispatchRoute
}
PlacementPolicy binds one kind-qualified registration ID to a logical route.
type PlacementResolver ¶ added in v0.23.0
type PlacementResolver interface {
ResolvePlacement(context.Context, MessageRegistration, DispatchOptions) (route DispatchRoute, found bool, err error)
}
PlacementResolver selects a logical route for a registration. found=false selects the local default.
type ProgressAwareCommander ¶ added in v0.22.0
type ProgressAwareCommander[T any] interface { ExecuteWithProgress(context.Context, T, CommandProgressReporter) error }
ProgressAwareCommander can receive an explicit reporter while still supporting the ordinary Commander Execute method for compatibility.
type ProgressOption ¶ added in v0.22.0
type ProgressOption func(*ProgressUpdate)
ProgressOption customizes a checkpoint or progress update.
func WithProgressMessage ¶ added in v0.22.0
func WithProgressMessage(message string) ProgressOption
WithProgressMessage attaches a safe operator-facing message to an update.
func WithProgressMetadata ¶ added in v0.22.0
func WithProgressMetadata(metadata map[string]any) ProgressOption
WithProgressMetadata attaches safe metadata to an update. The map is cloned.
type ProgressUpdate ¶ added in v0.22.0
type ProgressUpdate struct {
Checkpoint string
Message string
Current int64
Total int64
Metadata map[string]any
}
ProgressUpdate describes a cooperative progress or checkpoint update from command code.
type RPCCommand ¶ added in v0.15.0
RPCCommand allows commands/queries to opt into RPC registration.
type RPCConfig ¶ added in v0.15.0
type RPCConfig struct {
// Method is the RPC method name, e.g. "fsm.apply_event".
Method string
// Timeout is an optional transport timeout hint.
Timeout time.Duration
// Streaming declares whether this endpoint is stream oriented.
Streaming bool
// Idempotent declares whether retries are generally safe.
Idempotent bool
// Permissions required to invoke this method.
Permissions []string
// Roles allowed to invoke this method.
Roles []string
// Summary is a short endpoint description for docs/discovery.
Summary string
// Description is a longer endpoint description for docs/discovery.
Description string
// Tags groups endpoint in generated clients/docs.
Tags []string
// Deprecated marks endpoint for phased removal.
Deprecated bool
// Since captures the version this endpoint was introduced.
Since string
}
RPCConfig declares optional transport level metadata for RPC exposure. The zero value is safe and keeps behavior minimally configured.
type RPCDescriber ¶ added in v0.15.0
type RPCDescriber interface {
RPCDescription() RPCDescription
}
RPCDescriber allows commands to expose richer endpoint metadata for docs/codegen. This is optional and only used by RPC resolver paths.
type RPCDescription ¶ added in v0.15.0
type RPCDescription struct {
Summary string
Description string
Tags []string
Deprecated bool
Since string
}
RPCDescription carries optional endpoint documentation metadata.
type RegistrationProvider ¶ added in v0.23.0
type RegistrationProvider interface {
RegistrationByID(kind HandlerKind, stableID string) (MessageRegistration, bool)
RegistrationByMessageType(kind HandlerKind, messageType string) (MessageRegistration, bool)
Registrations() []MessageRegistration
}
RegistrationProvider exposes an immutable registration snapshot.
type Registry ¶ added in v0.3.0
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶ added in v0.3.0
func NewRegistry() *Registry
func (*Registry) AddResolver ¶ added in v0.11.0
func (*Registry) CatalogDescriptor ¶ added in v0.21.0
func (r *Registry) CatalogDescriptor(commandID string) (CommandDescriptor, bool)
CatalogDescriptor returns one descriptor by stable command ID.
func (*Registry) CatalogDescriptors ¶ added in v0.21.0
func (r *Registry) CatalogDescriptors() []CommandDescriptor
CatalogDescriptors returns descriptors in deterministic registration order.
func (*Registry) CatalogDescriptorsByExposure ¶ added in v0.21.0
func (r *Registry) CatalogDescriptorsByExposure(exposed bool) []CommandDescriptor
CatalogDescriptorsByExposure returns descriptors with the requested admin exposure state. It does not perform actor authorization.
func (*Registry) CatalogDescriptorsByTag ¶ added in v0.21.0
func (r *Registry) CatalogDescriptorsByTag(tags ...string) []CommandDescriptor
CatalogDescriptorsByTag returns descriptors matching at least one tag.
func (*Registry) GetCLIOptions ¶ added in v0.3.0
func (*Registry) HasResolver ¶ added in v0.11.0
func (*Registry) Initialize ¶ added in v0.3.0
func (*Registry) RegisterCatalogDescriptor ¶ added in v0.21.0
func (r *Registry) RegisterCatalogDescriptor(descriptor CommandDescriptor) error
RegisterCatalogDescriptor registers or replaces an external catalog descriptor. Duplicate IDs replace in place and preserve original ordering.
func (*Registry) RegisterCommand ¶ added in v0.3.0
func (*Registry) RegistrationByID ¶ added in v0.23.0
func (r *Registry) RegistrationByID(kind HandlerKind, stableID string) (MessageRegistration, bool)
func (*Registry) RegistrationByMessageType ¶ added in v0.23.0
func (r *Registry) RegistrationByMessageType(kind HandlerKind, messageType string) (MessageRegistration, bool)
func (*Registry) Registrations ¶ added in v0.23.0
func (r *Registry) Registrations() []MessageRegistration
func (*Registry) SetCronRegister ¶ added in v0.3.0
func (r *Registry) SetCronRegister(fn func(opts HandlerConfig, handler any) error) *Registry
func (*Registry) SetRPCRegister ¶ added in v0.15.0
type RemoteDispatcher ¶ added in v0.23.0
type RemoteDispatcher interface {
DispatchRemote(context.Context, DispatchRoute, MessageRegistration, any, DispatchOptions) (DispatchOutcome, error)
}
RemoteDispatcher is implemented by an optional transport adapter. The port deliberately excludes envelopes, acknowledgements, and broker concepts.
type Result ¶ added in v0.3.0
type Result[T any] struct { // contains filtered or unexported fields }
Result collector implementation from before
func ResultFromContext ¶ added in v0.3.0
func (*Result[T]) GetMetadata ¶ added in v0.3.0
func (*Result[T]) ResultType ¶ added in v0.23.0
ResultType reports the exact collector type, including pointer and interface result types.
func (*Result[T]) StoreDynamic ¶ added in v0.23.0
StoreDynamic validates and stores an untyped value. An untyped nil is a present result only when T can represent nil.
func (*Result[T]) StoreError ¶ added in v0.3.0
func (*Result[T]) StoreWithMeta ¶ added in v0.3.0
Source Files
¶
- catalog.go
- cli_tree.go
- command.go
- command_exposure.go
- command_extended.go
- command_meta.go
- command_rpc.go
- dispatch_context.go
- dispatch_contracts.go
- message.go
- panics.go
- placement.go
- progress.go
- progress_observers.go
- provenance.go
- registration_index.go
- registry.go
- result.go
- routed_dispatch.go
- routed_errors.go
- validation.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
rpc-tsgen
command
|
|
|
examples
|
|
|
flow/batch_processing
command
|
|
|
flow/conditional_guard
command
|
|
|
flow/config_build
command
|
|
|
flow/dispatch_fanout
command
|
|
|
flow/metrics_decorator
command
|
|
|
flow/parallel_error_strategy
command
|
|
|
flow/resilience
command
|
|
|
flow/saga_compensation
command
|
|
|
rpc/tsgen
command
|
|
|
rpc/tsgen/export
command
Command export writes the offline Go contract and real wire fixtures.
|
Command export writes the offline Go contract and real wire fixtures. |
|
rpc/tsgen/fixture
Command export produces contract and wire fixtures without handlers or services.
|
Command export produces contract and wire fixtures without handlers or services. |
|
rpc/tsgen/full
Package full demonstrates offline generation pinned by the root go.mod.
|
Package full demonstrates offline generation pinned by the root go.mod. |
|
rpc/web_debug
command
|
|