Class: CDC::Core::EventPosition
- Inherits:
-
Object
- Object
- CDC::Core::EventPosition
- Defined in:
- lib/cdc/core/event_position.rb
Overview
Immutable representation of an event’s position metadata.
EventPosition is intentionally small and transport-agnostic. It captures the position strategy plus the event fields that a runtime may use to preserve ordering guarantees.
Instance Attribute Summary collapse
- #occurred_at ⇒ Symbol, ... readonly
- #sequence_number ⇒ Symbol, ... readonly
- #strategy ⇒ Symbol, ... readonly
- #transaction_id ⇒ Symbol, ... readonly
- #value ⇒ Symbol, ... readonly
Instance Method Summary collapse
-
#initialize(strategy:, value:, transaction_id: nil, sequence_number: nil, occurred_at: nil) ⇒ EventPosition
constructor
Build an event position.
-
#to_h ⇒ Hash{String=>Object,nil}
Convert the position into a Ractor-shareable hash.
Constructor Details
#initialize(strategy:, value:, transaction_id: nil, sequence_number: nil, occurred_at: nil) ⇒ EventPosition
Build an event position.
25 26 27 28 29 30 31 32 |
# File 'lib/cdc/core/event_position.rb', line 25 def initialize(strategy:, value:, transaction_id: nil, sequence_number: nil, occurred_at: nil) @strategy = strategy.to_sym @value = value @transaction_id = transaction_id @sequence_number = sequence_number @occurred_at = occurred_at Ractor.make_shareable(self) end |
Instance Attribute Details
#occurred_at ⇒ Symbol, ... (readonly)
16 17 18 |
# File 'lib/cdc/core/event_position.rb', line 16 def occurred_at @occurred_at end |
#sequence_number ⇒ Symbol, ... (readonly)
16 17 18 |
# File 'lib/cdc/core/event_position.rb', line 16 def sequence_number @sequence_number end |
#strategy ⇒ Symbol, ... (readonly)
16 17 18 |
# File 'lib/cdc/core/event_position.rb', line 16 def strategy @strategy end |
#transaction_id ⇒ Symbol, ... (readonly)
16 17 18 |
# File 'lib/cdc/core/event_position.rb', line 16 def transaction_id @transaction_id end |
#value ⇒ Symbol, ... (readonly)
16 17 18 |
# File 'lib/cdc/core/event_position.rb', line 16 def value @value end |
Instance Method Details
#to_h ⇒ Hash{String=>Object,nil}
Convert the position into a Ractor-shareable hash.
37 38 39 40 41 42 43 44 45 |
# File 'lib/cdc/core/event_position.rb', line 37 def to_h Ractor.make_shareable({ 'strategy' => strategy, 'value' => value, 'transaction_id' => transaction_id, 'sequence_number' => sequence_number, 'occurred_at' => occurred_at }.freeze) end |