dispatcher

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 9 Imported by: 11

Documentation

Index

Constants

View Source
const (
	TextCodeDispatchExecutorNotConfigured = "DISPATCH_EXECUTOR_NOT_CONFIGURED"
	TextCodeDispatchModeResolverFailed    = "DISPATCH_MODE_RESOLVER_FAILED"
)

Variables

View Source
var ExitOnErr = false

Functions

func ClearModeResolver added in v0.17.0

func ClearModeResolver()

func Dispatch

func Dispatch[T any](ctx context.Context, msg T) error

Dispatch executes all registered CommandHandlers for T.

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 DispatchWithResult[T any, R any](ctx context.Context, msg T) (R, error)

func Query

func Query[T any, R any](ctx context.Context, msg T) (R, error)

Query executes the single registered QueryHandler for T, returning R.

func RegisterExecutor added in v0.17.0

func RegisterExecutor(mode command.ExecutionMode, exec CommandExecutor) error

func Reset added in v0.13.0

func Reset()

Reset clears all command/query subscriptions.

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)
}

type ModeResolver added in v0.17.0

type ModeResolver interface {
	ResolveMode(ctx context.Context, commandID string) (mode command.ExecutionMode, found bool, err error)
}

type Subscription

type Subscription interface {
	Unsubscribe()
}

func SubscribeCommand

func SubscribeCommand[T any](cmd command.Commander[T], runnerOpts ...runner.Option) Subscription

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 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.

func SubscribeQueryFunc

func SubscribeQueryFunc[T any, R any](qry command.QueryFunc[T, R], runnerOpts ...runner.Option) Subscription

Jump to

Keyboard shortcuts

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