Class: Akasha::Storage::HttpEventStore

Inherits:
Object
  • Object
show all
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

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:, 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

55
56
57
# File 'lib/akasha/storage/http_event_store.rb', line 55

def merge_all_by_event(into:, only:, namespace: nil)
  @client.merge_all_by_event(into, only, namespace: namespace)
end

#streamsObject

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