Class: Akasha::Storage::HttpEventStore
- Inherits:
-
Object
- Object
- Akasha::Storage::HttpEventStore
- Defined in:
- lib/akasha/storage/http_event_store.rb,
lib/akasha/storage/http_event_store/client.rb,
lib/akasha/storage/http_event_store/stream.rb,
lib/akasha/storage/http_event_store/event_serializer.rb,
lib/akasha/storage/http_event_store/response_handler.rb,
lib/akasha/storage/http_event_store/projection_manager.rb
Overview
HTTP-based interface to Eventstore (geteventstore.com)
Defined Under Namespace
Classes: Client, EventSerializer, ProjectionManager, ResponseHandler, Stream
Instance Method Summary collapse
-
#[](stream_name) ⇒ Object
Shortcut for accessing streams by their names.
-
#initialize(host: 'localhost', port: 2113, username: nil, password: nil, max_retries: 0) ⇒ HttpEventStore
constructor
Creates a new event store client, connecting to the specified ‘host` and `port` using an optional `username` and `password`.
-
#merge_all_by_event(into:, only:, namespace: nil) ⇒ Object
Merges all streams into one, filtering the resulting stream so it only contains events with the specified names, using a projection.
-
#streams ⇒ Object
Returns a Hash of streams.
Constructor Details
#initialize(host: 'localhost', port: 2113, username: nil, password: nil, max_retries: 0) ⇒ HttpEventStore
Creates a new event store client, connecting to the specified ‘host` and `port` using an optional `username` and `password`. Use the `max_retries` option to choose how many times to retry in case of network failures.
11 12 13 14 |
# File 'lib/akasha/storage/http_event_store.rb', line 11 def initialize(host: 'localhost', port: 2113, username: nil, password: nil, max_retries: 0) @client = Client.new(host: host, port: port, username: username, password: password) @max_retries = max_retries end |
Instance Method Details
#[](stream_name) ⇒ Object
Shortcut for accessing streams by their names.
24 25 26 |
# File 'lib/akasha/storage/http_event_store.rb', line 24 def [](stream_name) Stream.new(@client, stream_name, max_retries: @max_retries) end |
#merge_all_by_event(into:, only:, namespace: nil) ⇒ Object
Merges all streams into one, filtering the resulting stream so it only contains events with the specified names, using a projection.
Arguments:
`into` - name of the new stream
`only` - array of event names
`namespace` - optional namespace; if provided, the resulting stream will
only contain events with the same `metadata[:namespace]`
37 38 39 |
# File 'lib/akasha/storage/http_event_store.rb', line 37 def merge_all_by_event(into:, only:, namespace: nil) @client.merge_all_by_event(into, only, namespace: namespace, max_retries: @max_retries) end |
#streams ⇒ Object
Returns a Hash of streams. You can retrieve a Stream instance corresponding to any stream by its name. The stream does not have to exist, appending to it will create it.
19 20 21 |
# File 'lib/akasha/storage/http_event_store.rb', line 19 def streams self # Use the `[]` method on self. end |