Documentation
¶
Index ¶
- Constants
- Variables
- func ClearModeResolver()
- func CommandRunObservers() []command.CommandRunObserver
- func CommandSubscriptionHook[T any](runtime *Runtime) func(any, ...runner.Option) (Subscription, error)
- func Dispatch[T any](ctx context.Context, msg T) error
- func DispatchTo[T any](ctx context.Context, runtime *Runtime, msg T) error
- func DispatchWith[T any](ctx context.Context, msg T, opts command.DispatchOptions) (command.DispatchReceipt, error)
- func DispatchWithResult[T any, R any](ctx context.Context, msg T) (R, error)
- func InstallDefaultRuntime(runtime *Runtime) (func(), error)
- func Query[T any, R any](ctx context.Context, msg T) (R, error)
- func QuerySubscriptionHook[T any, R any](runtime *Runtime) func(any, ...runner.Option) (Subscription, error)
- func QueryTo[T any, R any](ctx context.Context, runtime *Runtime, msg T) (R, error)
- func RegisterExecutor(mode command.ExecutionMode, exec CommandExecutor) error
- func RegisterObservedExecutor(mode command.ExecutionMode, exec CommandExecutor) error
- func Reset()
- func RunObservedCommand(ctx context.Context, run command.DispatchRunContext, ...) error
- func SetCommandRoutingMode(mode RoutingMode, opts ...RoutingOption) error
- func SetCommandRunObservers(observers ...command.CommandRunObserver)
- func SetModeResolver(resolver ModeResolver)
- func UnregisterExecutor(mode command.ExecutionMode)
- type CommandExecutor
- type ModeResolver
- type RoutingMode
- type RoutingOption
- type Runtime
- func (r *Runtime) AttachRegistrationProvider(provider command.RegistrationProvider) error
- func (r *Runtime) ConfigurePlacementResolver(resolver command.PlacementResolver) error
- func (r *Runtime) ConfigureRemoteDispatcher(remote command.RemoteDispatcher) error
- func (r *Runtime) Dispatch(ctx context.Context, kind command.HandlerKind, message any, ...) (command.DispatchOutcome, error)
- func (r *Runtime) InvokeLocal(ctx context.Context, registration command.MessageRegistration, message any, ...) (command.DispatchOutcome, error)
- func (r *Runtime) InvokeLocalByID(ctx context.Context, kind command.HandlerKind, stableID string, message any, ...) (command.DispatchOutcome, error)
- func (r *Runtime) InvokeLocalByMessageType(ctx context.Context, kind command.HandlerKind, messageType string, message any, ...) (command.DispatchOutcome, error)
- func (r *Runtime) RegisterExecutor(mode command.ExecutionMode, executor CommandExecutor) error
- func (r *Runtime) RegistrationProvider() command.RegistrationProvider
- func (r *Runtime) ReplacePlacementPolicies(policies ...command.PlacementPolicy) error
- func (r *Runtime) Reset()
- func (r *Runtime) RoutedReady() error
- func (r *Runtime) UnregisterExecutor(mode command.ExecutionMode)
- type RuntimeOption
- type Subscription
- func AddCommandRunObserver(observer command.CommandRunObserver) Subscription
- func SubscribeCommand[T any](cmd command.Commander[T], runnerOpts ...runner.Option) Subscription
- func SubscribeCommandFunc[T any](handler command.CommandFunc[T], runnerOpts ...runner.Option) Subscription
- func SubscribeCommandTo[T any](runtime *Runtime, cmd command.Commander[T], runnerOpts ...runner.Option) Subscription
- func SubscribeQuery[T any, R any](qry command.Querier[T, R], runnerOpts ...runner.Option) Subscription
- func SubscribeQueryFunc[T any, R any](qry command.QueryFunc[T, R], runnerOpts ...runner.Option) Subscription
- func SubscribeQueryTo[T any, R any](runtime *Runtime, qry command.Querier[T, R], runnerOpts ...runner.Option) Subscription
Constants ¶
const ( TextCodeDispatchExecutorNotConfigured = "DISPATCH_EXECUTOR_NOT_CONFIGURED" TextCodeDispatchModeResolverFailed = "DISPATCH_MODE_RESOLVER_FAILED" )
const ( TextCodeInvalidRoutingMode = "INVALID_ROUTING_MODE" TextCodeDispatchRoutingLocked = "DISPATCH_ROUTING_MODE_LOCKED" )
Variables ¶
var ExitOnErr = false
Functions ¶
func ClearModeResolver ¶ added in v0.17.0
func ClearModeResolver()
func CommandRunObservers ¶ added in v0.22.0
func CommandRunObservers() []command.CommandRunObserver
CommandRunObservers returns a snapshot of currently registered observers.
func CommandSubscriptionHook ¶ added in v0.23.0
func CommandSubscriptionHook[T any](runtime *Runtime) func(any, ...runner.Option) (Subscription, error)
CommandSubscriptionHook adapts RuntimeContainer's untyped composition hook to a typed runtime subscription.
func DispatchTo ¶ added in v0.23.0
DispatchTo executes a typed command against one isolated runtime.
func DispatchWith ¶ added in v0.17.0
func DispatchWith[T any](ctx context.Context, msg T, opts command.DispatchOptions) (command.DispatchReceipt, error)
func DispatchWithResult ¶ added in v0.3.0
func InstallDefaultRuntime ¶ added in v0.23.0
InstallDefaultRuntime replaces the process default and returns an idempotent restore closure. Restoration is conditional so an older closure cannot overwrite a newer installation.
func QuerySubscriptionHook ¶ added in v0.23.0
func QuerySubscriptionHook[T any, R any](runtime *Runtime) func(any, ...runner.Option) (Subscription, error)
QuerySubscriptionHook adapts RuntimeContainer's untyped composition hook to a typed runtime query subscription.
func RegisterExecutor ¶ added in v0.17.0
func RegisterExecutor(mode command.ExecutionMode, exec CommandExecutor) error
func RegisterObservedExecutor ¶ added in v0.22.0
func RegisterObservedExecutor(mode command.ExecutionMode, exec CommandExecutor) error
RegisterObservedExecutor registers a queued executor with acceptance lifecycle instrumentation. Inline execution is already observed directly.
func RunObservedCommand ¶ added in v0.22.0
func RunObservedCommand(ctx context.Context, run command.DispatchRunContext, fn func(context.Context) error) error
RunObservedCommand wraps delayed queued command execution with lifecycle and progress events using a run context captured at acceptance time.
func SetCommandRoutingMode ¶ added in v0.18.0
func SetCommandRoutingMode(mode RoutingMode, opts ...RoutingOption) error
func SetCommandRunObservers ¶ added in v0.22.0
func SetCommandRunObservers(observers ...command.CommandRunObserver)
SetCommandRunObservers replaces all registered command run observers.
func SetModeResolver ¶ added in v0.17.0
func SetModeResolver(resolver ModeResolver)
func UnregisterExecutor ¶ added in v0.17.0
func UnregisterExecutor(mode command.ExecutionMode)
Types ¶
type CommandExecutor ¶ added in v0.17.0
type CommandExecutor interface {
Execute(ctx context.Context, msg any, commandID string, opts command.DispatchOptions) (command.DispatchReceipt, error)
}
func ExecutorForMode ¶ added in v0.20.0
func ExecutorForMode(mode command.ExecutionMode) (CommandExecutor, bool)
func ObserveExecutor ¶ added in v0.22.0
func ObserveExecutor(exec CommandExecutor) CommandExecutor
ObserveExecutor wraps a queued executor with acceptance lifecycle events.
type ModeResolver ¶ added in v0.17.0
type RoutingMode ¶ added in v0.18.0
type RoutingMode string
const ( RoutingModeExact RoutingMode = "exact" RoutingModeRich RoutingMode = "rich" )
func CommandRoutingMode ¶ added in v0.18.0
func CommandRoutingMode() RoutingMode
type RoutingOption ¶ added in v0.18.0
type RoutingOption func(*routingConfig)
func WithRoutingMatchStrategy ¶ added in v0.18.0
func WithRoutingMatchStrategy(strategy router.MatchStrategy) RoutingOption
func WithRoutingMatcher ¶ added in v0.18.0
func WithRoutingMatcher(matcher func(pattern, topic string) bool) RoutingOption
type Runtime ¶ added in v0.23.0
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns isolated command and query subscription state.
func DefaultRuntime ¶ added in v0.23.0
func DefaultRuntime() *Runtime
DefaultRuntime returns the concurrency-safe process default.
func NewRuntime ¶ added in v0.23.0
func NewRuntime(options ...RuntimeOption) *Runtime
func (*Runtime) AttachRegistrationProvider ¶ added in v0.23.0
func (r *Runtime) AttachRegistrationProvider(provider command.RegistrationProvider) error
AttachRegistrationProvider validates and snapshots a complete provider generation before making it visible to dynamic dispatch.
func (*Runtime) ConfigurePlacementResolver ¶ added in v0.23.0
func (r *Runtime) ConfigurePlacementResolver(resolver command.PlacementResolver) error
ConfigurePlacementResolver installs an application-owned resolver as part of one atomic provider/placement generation.
func (*Runtime) ConfigureRemoteDispatcher ¶ added in v0.23.0
func (r *Runtime) ConfigureRemoteDispatcher(remote command.RemoteDispatcher) error
ConfigureRemoteDispatcher installs or clears the transport-neutral remote port as part of one atomic runtime generation.
func (*Runtime) Dispatch ¶ added in v0.23.0
func (r *Runtime) Dispatch(ctx context.Context, kind command.HandlerKind, message any, options command.DispatchOptions) (command.DispatchOutcome, error)
Dispatch resolves a dynamic value by kind and message type, then invokes it locally. Placement is layered onto this method by routed runtime generation configuration.
func (*Runtime) InvokeLocal ¶ added in v0.23.0
func (r *Runtime) InvokeLocal(ctx context.Context, registration command.MessageRegistration, message any, options command.DispatchOptions) (command.DispatchOutcome, error)
InvokeLocal is the trusted, already-resolved local invocation boundary.
func (*Runtime) InvokeLocalByID ¶ added in v0.23.0
func (r *Runtime) InvokeLocalByID(ctx context.Context, kind command.HandlerKind, stableID string, message any, options command.DispatchOptions) (command.DispatchOutcome, error)
func (*Runtime) InvokeLocalByMessageType ¶ added in v0.23.0
func (r *Runtime) InvokeLocalByMessageType(ctx context.Context, kind command.HandlerKind, messageType string, message any, options command.DispatchOptions) (command.DispatchOutcome, error)
func (*Runtime) RegisterExecutor ¶ added in v0.23.0
func (r *Runtime) RegisterExecutor(mode command.ExecutionMode, executor CommandExecutor) error
func (*Runtime) RegistrationProvider ¶ added in v0.23.0
func (r *Runtime) RegistrationProvider() command.RegistrationProvider
func (*Runtime) ReplacePlacementPolicies ¶ added in v0.23.0
func (r *Runtime) ReplacePlacementPolicies(policies ...command.PlacementPolicy) error
ReplacePlacementPolicies validates all kind-qualified IDs and routes before atomically publishing the new resolver snapshot.
func (*Runtime) Reset ¶ added in v0.23.0
func (r *Runtime) Reset()
Reset clears subscriptions, executors, and routed configuration owned by one runtime. Existing subscription handles remain safe and idempotent.
func (*Runtime) RoutedReady ¶ added in v0.23.0
RoutedReady reports whether stable-ID and dynamic operations have a complete registration generation. Typed local dispatch does not require readiness.
func (*Runtime) UnregisterExecutor ¶ added in v0.23.0
func (r *Runtime) UnregisterExecutor(mode command.ExecutionMode)
type RuntimeOption ¶ added in v0.23.0
type RuntimeOption func(*Runtime)
type Subscription ¶
type Subscription interface {
Unsubscribe()
}
func AddCommandRunObserver ¶ added in v0.22.0
func AddCommandRunObserver(observer command.CommandRunObserver) Subscription
AddCommandRunObserver registers a command run observer and returns an idempotent unsubscribe handle.
func SubscribeCommand ¶
Subscribe a CommandHandler for a particular message type T. TODO: should this return an error?!
func SubscribeCommandFunc ¶
func SubscribeCommandFunc[T any](handler command.CommandFunc[T], runnerOpts ...runner.Option) Subscription
func SubscribeCommandTo ¶ added in v0.23.0
func SubscribeQuery ¶
func SubscribeQuery[T any, R any](qry command.Querier[T, R], runnerOpts ...runner.Option) Subscription
Subscribe a QueryHandler for a particular message type T, R.