CommandedAggregateless.Command.Router (commanded_aggregateless v1.0.0)

Copy Markdown

Provides basic DSQL for registering commands with the Commanded.Commands.Router

This sets up a consistent convention that dispatches commands to an aggregate-per-command.

Summary

Functions

Configure the module to be able to register commands

Register a command with the Commanded.Commands.Router

Functions

__using__(opts)

(macro)
@spec __using__(any()) :: Macro.t()

Configure the module to be able to register commands

register_command(command_module, opts \\ [])

(macro)
@spec register_command(
  atom(),
  keyword()
) :: Macro.t()

Register a command with the Commanded.Commands.Router

Options:

  • :aggregate - the aggregate module to dispatch the command to. Defaults to the command module's Aggregate module (e.g. MyCommand.Aggregate)
  • :aggregate_identifier - the aggregate identifier. This is a keyword list with by and prefix keys. Defaults to the value returned by the aggregate module's identifier/0 function function.
  • :lifespan - the lifespan module to user with this command. Defaults to CommandedAggregateless.Command.DefaultLifespan
  • :timeout - the timeout for the command. Defaults to 5_000ms.

Examples:

  register_command(MyCommand)

  register_command(
    MyCommand,
    aggregate: MyAggregate,
    aggregate_identifier: [by: :id, prefix: "my_aggregate"],
    lifespan: MyLifespan,
    timeout: 10_000
  )

route_command(command_module)

(macro)