Skip to content

Allow event handlers to subscribe to individual streams - #203

Merged
slashdotdash merged 3 commits into
masterfrom
feature/event-handler-subscribe-to-stream
Sep 20, 2018
Merged

slashdotdash merged 3 commits into
masterfrom
feature/event-handler-subscribe-to-stream

Conversation

@slashdotdash

Copy link
Copy Markdown
Member

Event handlers subscribe to all events appended to any stream by default. For event handlers that are only interested in events appended to one stream it is now possible to subcribe to a single stream using the subscribe_to option:

defmodule ExampleHandler do
  use Commanded.Event.Handler, 
    name: __MODULE__,
    subscribe_to: "stream1234"

  def handle(%AnEvent{..}, metadata) do
    :ok
  end
end

In the above example, the configuration would guarantee only events appended to stream stream1234 would be received and handled by the event handler.

Closes #174.

… stream

Including subscriptions to all events appended to any stream by using `:all` during subscribe.
@slashdotdash
slashdotdash force-pushed the feature/event-handler-subscribe-to-stream branch 4 times, most recently from 38df233 to c876925 Compare September 20, 2018 21:09
Event handler can specify `subscribe_to` as a config option to determine a single stream to subscribe to.

By default the handler will subscribe to all events appended to any stream.
@slashdotdash
slashdotdash force-pushed the feature/event-handler-subscribe-to-stream branch from c876925 to ff1f561 Compare September 20, 2018 21:14
To allow reuse by external registry providers who want to implement the `Commanded.Registration` behaviour.
@slashdotdash
slashdotdash merged commit ff2788a into master Sep 20, 2018
@slashdotdash
slashdotdash deleted the feature/event-handler-subscribe-to-stream branch September 20, 2018 21:36
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

Successfully merging this pull request may close these issues.

1 participant