Commanded v1.0.0 Commanded.Application behaviour View Source
Defines a Commanded application.
The application expects at least an :otp_app
option to be specified. It
should point to an OTP application that has the application configuration.
For example, the application:
defmodule MyApp.Application do
use Commanded.Application, otp_app: :my_app
router(MyApp.Router)
end
Could be configured with:
# config/config.exs
config :my_app, MyApp.Application
event_store: [
adapter: Commanded.EventStore.Adapters.EventStore,
event_store: MyApp.EventStore
],
pubsub: :local,
registry: :local
Alternatively, you can include the event store, pubsub, and registry config when defining the application:
defmodule MyApp.Application do
use Commanded.Application,
otp_app: :my_app,
event_store: [
adapter: Commanded.EventStore.Adapters.EventStore,
event_store: MyApp.EventStore
],
pubsub: :local,
registry: :local
router(MyApp.Router)
end
Link to this section Summary
Callbacks
Returns the application configuration stored in the :otp_app
environment.
Dispatch a registered command.
A callback executed when the application starts.
Starts the application supervisor.
Shuts down the application.
Link to this section Types
Link to this section Callbacks
Returns the application configuration stored in the :otp_app
environment.
dispatch(command, timeout_or_opts)
View Sourcedispatch( command :: struct(), timeout_or_opts :: integer() | :infinity | Keyword.t() ) :: :ok | {:ok, execution_result :: Commanded.Commands.ExecutionResult.t()} | {:ok, aggregate_version :: non_neg_integer()} | {:error, :unregistered_command} | {:error, :consistency_timeout} | {:error, reason :: term()}
Dispatch a registered command.
A callback executed when the application starts.
It must return {:ok, keyword}
with the updated list of configuration.
Starts the application supervisor.
Returns {:ok, pid}
on sucess, {:error, {:already_started, pid}}
if the
application is already started, or {:error, term}
in case anything else goes
wrong.
Shuts down the application.