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, HttpError, ProjectionManager, ResponseHandler, Stream
Constant Summary collapse
- Error =
Base class for all HTTP Event store errors.
Class.new(RuntimeError)
- InvalidStreamNameError =
Stream name contains invalid characters.
Class.new(Error)
- HttpClientError =
4xx HTTP status code.
Class.new(HttpError)
- HttpServerError =
5xx HTTP status code.
Class.new(HttpError)
Instance Method Summary collapse
-
#[](stream_name) ⇒ Object
Shortcut for accessing streams by their names.
-
#initialize(host: 'localhost', port: 2113, username: nil, password: nil) ⇒ 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:) ⇒ 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) ⇒ HttpEventStore
Creates a new event store client, connecting to the specified host and port using an optional username and password.
30 31 32 |
# File 'lib/akasha/storage/http_event_store.rb', line 30 def initialize(host: 'localhost', port: 2113, username: nil, password: nil) @client = Client.new(host: host, port: port, username: username, password: password) end |
Instance Method Details
#[](stream_name) ⇒ Object
Shortcut for accessing streams by their names.
42 43 44 |
# File 'lib/akasha/storage/http_event_store.rb', line 42 def [](stream_name) Stream.new(@client, stream_name) end |
#merge_all_by_event(into:, only:) ⇒ 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
53 54 55 |
# File 'lib/akasha/storage/http_event_store.rb', line 53 def merge_all_by_event(into:, only:) @client.merge_all_by_event(into, only) 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.
37 38 39 |
# File 'lib/akasha/storage/http_event_store.rb', line 37 def streams self # Use the `[]` method on self. end |