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 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 ContextWithDispatchOptions(ctx context.Context, opts DispatchOptions) context.Context
- func ContextWithDispatchRun(ctx context.Context, run DispatchRunContext) 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 GetGoroutineID() uint64
- func GetMessageType(msg any) string
- func IsNilMessage(msg any) bool
- func MakePanicHandler(logger PanicLogger) func(funcName string, fields ...map[string]any)
- func NewQueueMultiHandlerUnsupportedError(commandID string, handlerCount int) *errors.Error
- 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 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 DispatchReceipt
- type DispatchRunContext
- type ExecutionMode
- type ExposableCommand
- type HTTPCommand
- type HandlerConfig
- type Message
- type MessageFactory
- type PanicLogger
- type ProgressAwareCommander
- type ProgressOption
- type ProgressUpdate
- type Querier
- type QueryFunc
- type RPCCommand
- type RPCConfig
- type RPCDescriber
- type RPCDescription
- 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) SetCronRegister(fn func(opts HandlerConfig, handler any) error) *Registry
- func (r *Registry) SetRPCRegister(fn func(opts RPCConfig, handler any, meta CommandMeta) error) *Registry
- type Resolver
- type Result
- 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" )
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 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 ContextWithDispatchOptions ¶ added in v0.17.0
func ContextWithDispatchOptions(ctx context.Context, opts DispatchOptions) 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 ContextWithResult ¶ added in v0.3.0
Context helpers
func DefaultPanicLogger ¶ added in v0.2.0
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 NewQueueMultiHandlerUnsupportedError ¶ added in v0.17.0
TODO(BKG_CMD phase 2): enforce this via DispatchWith in queued routing paths.
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 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
DispatchID string
CommandID string
Handler 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
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 DispatchReceipt ¶ added in v0.17.0
type DispatchRunContext ¶ added in v0.22.0
type DispatchRunContext struct {
RunID string
DispatchID string
CommandID string
Handler string
ExecutionMode ExecutionMode
CorrelationID string
IdempotencyKey string
Attempt int
MaxAttempts int
StartedAt time.Time
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 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 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 PanicLogger ¶ added in v0.2.0
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 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) 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 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]) StoreError ¶ added in v0.3.0
func (*Result[T]) StoreWithMeta ¶ added in v0.3.0
Source Files
¶
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/web_debug
command
|
|