Class: Igniter::Store::ChangeEvent
- Inherits:
-
Struct
- Object
- Struct
- Igniter::Store::ChangeEvent
- Defined in:
- lib/igniter/store/change_event.rb
Overview
Immutable value object emitted after each committed fact write.
Carries a compact reference to the committed fact (fact_id, store, key, timestamps, causation) plus a monotonic cursor sequence assigned by the emitting ChangefeedBuffer.
The fact field carries the full Fact object for transports (e.g. TCP push) that need the complete payload on delivery. It is not included in to_h to keep wire representations compact.
Instance Attribute Summary collapse
-
#causation ⇒ Object
Returns the value of attribute causation.
-
#cursor ⇒ Object
Returns the value of attribute cursor.
-
#emitted_at ⇒ Object
Returns the value of attribute emitted_at.
-
#fact ⇒ Object
Returns the value of attribute fact.
-
#fact_id ⇒ Object
Returns the value of attribute fact_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#producer ⇒ Object
Returns the value of attribute producer.
-
#schema_version ⇒ Object
Returns the value of attribute schema_version.
-
#store ⇒ Object
Returns the value of attribute store.
-
#transaction_time ⇒ Object
Returns the value of attribute transaction_time.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#causation ⇒ Object
Returns the value of attribute causation
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def causation @causation end |
#cursor ⇒ Object
Returns the value of attribute cursor
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def cursor @cursor end |
#emitted_at ⇒ Object
Returns the value of attribute emitted_at
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def emitted_at @emitted_at end |
#fact ⇒ Object
Returns the value of attribute fact
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def fact @fact end |
#fact_id ⇒ Object
Returns the value of attribute fact_id
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def fact_id @fact_id end |
#id ⇒ Object
Returns the value of attribute id
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def id @id end |
#key ⇒ Object
Returns the value of attribute key
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def key @key end |
#producer ⇒ Object
Returns the value of attribute producer
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def producer @producer end |
#schema_version ⇒ Object
Returns the value of attribute schema_version
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def schema_version @schema_version end |
#store ⇒ Object
Returns the value of attribute store
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def store @store end |
#transaction_time ⇒ Object
Returns the value of attribute transaction_time
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def transaction_time @transaction_time end |
#type ⇒ Object
Returns the value of attribute type
16 17 18 |
# File 'lib/igniter/store/change_event.rb', line 16 def type @type end |
Class Method Details
.from_fact(fact, sequence:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/igniter/store/change_event.rb', line 31 def self.from_fact(fact, sequence:) new( schema_version: 1, id: "change_#{SecureRandom.uuid}", type: :fact_committed, store: fact.store, key: fact.key, fact_id: fact.id, transaction_time: fact.transaction_time, emitted_at: Process.clock_gettime(Process::CLOCK_REALTIME), producer: fact.producer, causation: fact.causation, cursor: { sequence: sequence }.freeze, fact: fact ).freeze end |
Instance Method Details
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/igniter/store/change_event.rb', line 48 def to_h { schema_version: schema_version, id: id, type: type, store: store, key: key, fact_id: fact_id, transaction_time: transaction_time, emitted_at: emitted_at, producer: producer, causation: causation, cursor: cursor } end |