Class: RailsEventStore::Client
- Inherits:
-
Object
- Object
- RailsEventStore::Client
- Defined in:
- lib/rails_event_store/client.rb
Instance Method Summary collapse
- #delete_stream(stream_name) ⇒ Object
-
#initialize(repository = Repositories::EventRepository.new) ⇒ Client
constructor
A new instance of Client.
- #publish_event(event_data, stream_name = 'all', expected_version = nil) ⇒ Object
- #read_all_events(stream_name) ⇒ Object
- #read_all_streams ⇒ Object
- #read_events(stream_name, start, count) ⇒ Object
- #subscribe(subscriber, event_types = []) ⇒ Object
Constructor Details
#initialize(repository = Repositories::EventRepository.new) ⇒ Client
Returns a new instance of Client.
4 5 6 |
# File 'lib/rails_event_store/client.rb', line 4 def initialize(repository = Repositories::EventRepository.new) @repository = repository end |
Instance Method Details
#delete_stream(stream_name) ⇒ Object
13 14 15 |
# File 'lib/rails_event_store/client.rb', line 13 def delete_stream(stream_name) Actions::DeleteStreamEvents.new(@repository).call(stream_name) end |
#publish_event(event_data, stream_name = 'all', expected_version = nil) ⇒ Object
8 9 10 11 |
# File 'lib/rails_event_store/client.rb', line 8 def publish_event(event_data, stream_name = 'all', expected_version = nil) event = Actions::AppendEventToStream.new(@repository).call(stream_name, event_data, expected_version) event_broker.notify_subscribers(event) end |
#read_all_events(stream_name) ⇒ Object
21 22 23 |
# File 'lib/rails_event_store/client.rb', line 21 def read_all_events(stream_name) Actions::ReadAllEvents.new(@repository).call(stream_name) end |
#read_all_streams ⇒ Object
25 26 27 |
# File 'lib/rails_event_store/client.rb', line 25 def read_all_streams Actions::ReadAllStreams.new(@repository).call end |
#read_events(stream_name, start, count) ⇒ Object
17 18 19 |
# File 'lib/rails_event_store/client.rb', line 17 def read_events(stream_name, start, count) Actions::ReadEventsBatch.new(@repository).call(stream_name, start, count) end |
#subscribe(subscriber, event_types = []) ⇒ Object
29 30 31 |
# File 'lib/rails_event_store/client.rb', line 29 def subscribe(subscriber, event_types = []) event_broker.add_subscriber(subscriber, event_types) end |