Class: RailsEventStore::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_event_store/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(repository: Repositories::EventRepository.new, event_broker: EventBroker.new, page_size: PAGE_SIZE) ⇒ Client

Returns a new instance of Client.


4
5
6
7
8
9
10
# File 'lib/rails_event_store/client.rb', line 4

def initialize(repository: Repositories::EventRepository.new,
               event_broker: EventBroker.new,
               page_size: PAGE_SIZE)
  @repository = repository
  @page_size = page_size
  @event_broker = event_broker
end

Instance Method Details

#append_to_stream(event, stream_name = GLOBAL_STREAM, expected_version = :any) ⇒ Object


16
17
18
# File 'lib/rails_event_store/client.rb', line 16

def append_to_stream(event, stream_name = GLOBAL_STREAM, expected_version = :any)
  event_store.append_to_stream(stream_name, event, expected_version)
end

#delete_stream(stream_name) ⇒ Object


20
21
22
# File 'lib/rails_event_store/client.rb', line 20

def delete_stream(stream_name)
  event_store.delete_stream(stream_name)
end

#publish_event(event, stream_name = GLOBAL_STREAM, expected_version = :any) ⇒ Object


12
13
14
# File 'lib/rails_event_store/client.rb', line 12

def publish_event(event, stream_name = GLOBAL_STREAM, expected_version = :any)
  event_store.publish_event(event, stream_name, expected_version)
end

#read_all_streams_forward(start = :head, count = page_size) ⇒ Object Also known as: read_all_streams


34
35
36
# File 'lib/rails_event_store/client.rb', line 34

def read_all_streams_forward(start = :head, count = page_size)
  event_store.read_all_streams_forward(start, count)
end

#read_events_forward(stream_name, start = :head, count = page_size) ⇒ Object Also known as: read_events


24
25
26
# File 'lib/rails_event_store/client.rb', line 24

def read_events_forward(stream_name, start = :head, count = page_size)
  event_store.read_events_forward(stream_name, start, count)
end

#read_stream_events_forward(stream_name) ⇒ Object Also known as: read_all_events


29
30
31
# File 'lib/rails_event_store/client.rb', line 29

def read_stream_events_forward(stream_name)
  event_store.read_stream_events_forward(stream_name)
end

#subscribe(subscriber, event_types) ⇒ Object


39
40
41
# File 'lib/rails_event_store/client.rb', line 39

def subscribe(subscriber, event_types)
  event_store.subscribe(subscriber, event_types)
end

#subscribe_to_all_events(subscriber) ⇒ Object


43
44
45
# File 'lib/rails_event_store/client.rb', line 43

def subscribe_to_all_events(subscriber)
  event_store.subscribe_to_all_events(subscriber)
end