Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple event stores #76

Closed
slashdotdash opened this issue Oct 25, 2017 · 3 comments
Closed

Support multiple event stores #76

slashdotdash opened this issue Oct 25, 2017 · 3 comments
Assignees

Comments

@slashdotdash
Copy link
Member

slashdotdash commented Oct 25, 2017

Allow multiple event stores to be used in an application by providing an EventStore macro to use in your own module, as per Ecto's repo.

Define your event store module:

defmodule MyApp.EventStore do
  use EventStore, 
    otp_app: :my_app

  # Optional `init/1` function to modify config at runtime.
  def init(config) do
    {:ok, config}
  end
end

Configure the event store:

config :my_app, MyApp.EventStore,
  serializer: EventStore.TermSerializer,
  username: "postgres",
  password: "postgres",
  database: "eventstore_dev",
  hostname: "localhost",
  pool_size: 10,
  pool_overflow: 5

config :my_app, event_stores: [MyApp.EventStore]

Usage:

:ok = MyApp.EventStore.append_to_stream(stream_uuid, expected_version, events)
@hauleth
Copy link

hauleth commented Jun 29, 2018

This would provide additional pro: there could be init callback like in Ecto that would allow to load configuration in runtime instead of relying on some weird tooling.

@slashdotdash
Copy link
Member Author

Work in progress on branch feature/multi-event-store.

@slashdotdash
Copy link
Member Author

Done in #168.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants