Commanded EvenstoreDB adapter based on spear. The code is based on commanded-extreme-adapter.
The package can be installed from hex as follows.
Add commanded_spear_adapter
to your list of dependencies in mix.exs
:
def deps do
[{:commanded_spear_adapter, "~> 0.2"}]
end
Define and configure your Commanded application:
defmodule MyApp.Application do
use Commanded.Application, otp_app: :my_app
end
Configure the Commanded application to use the Commanded.EventStore.Adapters.Spear
adapter and set the connection settings for the Event Store you are using:
# config/config.exs
config :my_app, MyApp.Application,
event_store: [
adapter: Commanded.EventStore.Adapters.Spear,
serializer: Commanded.Serialization.JsonSerializer,
stream_prefix: "myapp",
spear: [
connection_string: "esdb://localhost:2113"
]
]
Refer to the Spear library documentation for details on the available connection settings.
Note: Stream prefix must not contain a dash character ("-").
This adapter does not support partitioning via the partition_by
option.
commanded_spear_adapter
uses Erlang's :global
registry to prevent duplicate subscriptions by stream/name.
To serialize and deserialize events in formats other than JSON, you must specify the content-type of the event body.
# config/config.exs
config :my_app, MyApp.Application,
event_store: [
adapter: Commanded.EventStore.Adapters.Spear,
serializer: MyApp.MessagePackSerializer,
content_type: "application/x-msgpack"
...
]
The content_type
settings defaults to application/json
.
You must run the Event Store with all projections enabled and standard projections started.
Use the --run-projections=all --start-standard-projections=true
flags when running the Event Store executable.