Class: Hyrax::EventStore Abstract
- Inherits:
-
Object
- Object
- Hyrax::EventStore
- Defined in:
- lib/hyrax/event_store.rb
Overview
The event store provides an interface to log numbered events into a storage system, e.g. a key-value store.
At the class level, we provide a ‘.create` method for logging event data with incrementing ids. Events have an “action” (a string description of the event), and a (numeric) timestamp. Clients SHOULD provide a timestamp that represnts the current application time (i.e. via `Hyrax::TimeService`); see `Hyrax::Event.create_now`.
At the instance level, events can be pushed by id onto a list of events for a given topic key, and fetched by the same topic. Initialize an instance with ‘.for(’topic_key’)‘ and use `#push(event_id)` to associate events with the topic.
Direct Known Subclasses
Class Method Summary collapse
-
.create(_action, _timestamp) ⇒ Integer
abstract
The id of the event.
- .for(key) ⇒ Object
- .logger ⇒ Logger
Instance Method Summary collapse
- #fetch(_size) ⇒ Enumerable<Hash<Symbol, String>>
-
#initialize(key) ⇒ EventStore
constructor
private
A new instance of EventStore.
-
#push(_value) ⇒ void
Adds a value to the end of a list identified by key.
Constructor Details
#initialize(key) ⇒ EventStore
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of EventStore.
62 63 64 |
# File 'lib/hyrax/event_store.rb', line 62 def initialize(key) @key = key end |
Class Method Details
.create(_action, _timestamp) ⇒ Integer
clients should consider using ‘Hyrax::Event` to manage events instead of directly interfacing with this method.
Returns the id of the event.
42 43 44 45 |
# File 'lib/hyrax/event_store.rb', line 42 def create(_action, ) raise NotImplementedError, 'EventStore.create should be provided by ' \ 'a concrete implementation' end |
.for(key) ⇒ Object
this is really just an initializer; deprecate in favor of ‘.new`?
53 54 55 |
# File 'lib/hyrax/event_store.rb', line 53 def for(key) new(key) end |
Instance Method Details
#fetch(_size) ⇒ Enumerable<Hash<Symbol, String>>
70 71 72 73 |
# File 'lib/hyrax/event_store.rb', line 70 def fetch(_size) raise NotImplementedError, 'EventStore#fetch should be provided by ' \ 'a concrete implementation' end |
#push(_value) ⇒ void
This method returns an undefined value.
Adds a value to the end of a list identified by key
81 82 83 84 |
# File 'lib/hyrax/event_store.rb', line 81 def push(_value) raise NotImplementedError, 'EventStore#push should be provided by ' \ 'a concrete implementation' end |