Class: Mammoth::ReplicationConsumer
- Inherits:
-
Object
- Object
- Mammoth::ReplicationConsumer
- Defined in:
- lib/mammoth/replication_consumer.rb
Overview
Consumes normalized CDC work from an injected source.
ReplicationConsumer is intentionally upstream-agnostic. It does not know which upstream system produced the work. Its job is to consume CDC Ecosystem work and yield either individual change events or transaction envelopes depending on Mammoth's configured delivery unit.
Instance Attribute Summary collapse
-
#delivery_unit ⇒ Object
readonly
Returns the value of attribute delivery_unit.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source: nil, delivery_unit: :event) ⇒ ReplicationConsumer
constructor
A new instance of ReplicationConsumer.
-
#start {|event| ... } ⇒ Integer
Consume normalized CDC work from the configured source.
Constructor Details
#initialize(source: nil, delivery_unit: :event) ⇒ ReplicationConsumer
Returns a new instance of ReplicationConsumer.
16 17 18 19 |
# File 'lib/mammoth/replication_consumer.rb', line 16 def initialize(source: nil, delivery_unit: :event) @source = source @delivery_unit = delivery_unit.to_sym end |
Instance Attribute Details
#delivery_unit ⇒ Object (readonly)
Returns the value of attribute delivery_unit.
12 13 14 |
# File 'lib/mammoth/replication_consumer.rb', line 12 def delivery_unit @delivery_unit end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
12 13 14 |
# File 'lib/mammoth/replication_consumer.rb', line 12 def source @source end |
Instance Method Details
#start {|event| ... } ⇒ Integer
Consume normalized CDC work from the configured source.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mammoth/replication_consumer.rb', line 25 def start return enum_for(:start) unless block_given? count = 0 each_event do |event| yield event count += 1 end count end |