Class: Hecks::Runtime::Event
- Inherits:
-
Struct
- Object
- Struct
- Hecks::Runtime::Event
- Defined in:
- lib/hecks/runtime/event.rb
Overview
correlation is NOT on the wire — to_h below deliberately omits it,
the same as bin/run's own event projection does. It is runtime
bookkeeping stamped by Dispatcher#dispatch when a saga leg's own
dispatch causes this event (see SagaInterpreter#deliver_saga_dispatch
and #saga_correlation) : a Hash of correlation_head -> correlation
value, so an event caused by one saga cannot be misread by an unrelated
one correlating on a different field. Absent for any event no saga
dispatch caused, which is most of them.
Instance Attribute Summary collapse
-
#aggregate ⇒ Object
Returns the value of attribute aggregate.
-
#correlation ⇒ Object
Returns the value of attribute correlation.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#occurred_at ⇒ Object
Returns the value of attribute occurred_at.
-
#payload ⇒ Object
Returns the value of attribute payload.
Instance Method Summary collapse
-
#emit! ⇒ Object
AN EMITTED EVENT IS A RECORD OF SOMETHING THAT HAPPENED, and a mutable audit trail is not one.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#aggregate ⇒ Object
Returns the value of attribute aggregate
13 14 15 |
# File 'lib/hecks/runtime/event.rb', line 13 def aggregate @aggregate end |
#correlation ⇒ Object
Returns the value of attribute correlation
13 14 15 |
# File 'lib/hecks/runtime/event.rb', line 13 def correlation @correlation end |
#id ⇒ Object
Returns the value of attribute id
13 14 15 |
# File 'lib/hecks/runtime/event.rb', line 13 def id @id end |
#name ⇒ Object
Returns the value of attribute name
13 14 15 |
# File 'lib/hecks/runtime/event.rb', line 13 def name @name end |
#occurred_at ⇒ Object
Returns the value of attribute occurred_at
13 14 15 |
# File 'lib/hecks/runtime/event.rb', line 13 def occurred_at @occurred_at end |
#payload ⇒ Object
Returns the value of attribute payload
13 14 15 |
# File 'lib/hecks/runtime/event.rb', line 13 def payload @payload end |
Instance Method Details
#emit! ⇒ Object
AN EMITTED EVENT IS A RECORD OF SOMETHING THAT HAPPENED, and a mutable audit trail is not one. The PAYLOAD — the domain fact the event carries — is frozen THROUGH on emission: freezing the Hash alone would leave every value in it editable in place, which is the shape all four previous freezing bugs had.
THE WHOLE EVENT, not just its payload. Correlation used to be
merged onto already-emitted events by Dispatcher#dispatch, which
is what kept an event writable after it had happened; it is set at
construction now, because it is part of the transaction and known
from dispatch's own argument before anything is emitted.
The LOG stays appendable: new events are still recorded. It is each event that stops changing once it exists.
28 29 30 31 32 |
# File 'lib/hecks/runtime/event.rb', line 28 def emit! Freezer.deep(payload) Freezer.deep(correlation) freeze end |
#inspect ⇒ Object
48 |
# File 'lib/hecks/runtime/event.rb', line 48 def inspect = "#<Event #{self}>" |
#to_h ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/hecks/runtime/event.rb', line 34 def to_h { name: name, aggregate: aggregate, id: id, payload: payload, occurred_at: occurred_at } end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/hecks/runtime/event.rb', line 44 def to_s "#{name}(#{aggregate}##{id}) #{payload.inspect}" end |