Class: CDC::Core::Processor
- Inherits:
-
Object
- Object
- CDC::Core::Processor
- Defined in:
- lib/cdc/core/processor.rb
Overview
Base class for CDC event processors.
Subclasses implement #process and may opt into Ractor-safe execution by calling .ractor_safe!. cdc-core itself does not schedule Ractors; it only records processor capabilities for runtime layers such as cdc-ractor.
Direct Known Subclasses
Class Method Summary collapse
-
.ractor_safe! ⇒ true
Mark this processor class as safe to execute in Ractor-aware runtimes.
-
.ractor_safe? ⇒ Boolean
Whether this processor class has declared Ractor safety.
Instance Method Summary collapse
-
#flush ⇒ self
Flush any buffered work.
-
#healthy? ⇒ Boolean
Whether the processor is healthy and ready to accept work.
-
#process(_event) ⇒ Object
Process one event.
-
#ractor_safe? ⇒ Boolean
Whether this processor instance is Ractor-safe.
-
#start ⇒ self
Start the processor.
-
#stop ⇒ self
Stop the processor.
Class Method Details
.ractor_safe! ⇒ true
Mark this processor class as safe to execute in Ractor-aware runtimes.
14 15 16 |
# File 'lib/cdc/core/processor.rb', line 14 def self.ractor_safe! @ractor_safe = true end |
.ractor_safe? ⇒ Boolean
Whether this processor class has declared Ractor safety.
21 22 23 |
# File 'lib/cdc/core/processor.rb', line 21 def self.ractor_safe? @ractor_safe == true end |
Instance Method Details
#flush ⇒ self
Flush any buffered work.
Runtime layers can call this before shutdown or checkpoints. The default implementation is a no-op.
58 59 60 |
# File 'lib/cdc/core/processor.rb', line 58 def flush self end |
#healthy? ⇒ Boolean
Whether the processor is healthy and ready to accept work.
The default implementation assumes the processor is healthy.
67 68 69 |
# File 'lib/cdc/core/processor.rb', line 67 def healthy? true end |
#process(_event) ⇒ Object
Process one event.
Subclasses must override this method.
77 78 79 |
# File 'lib/cdc/core/processor.rb', line 77 def process(_event) raise NotImplementedError, "#{self.class} must implement #process" end |
#ractor_safe? ⇒ Boolean
Whether this processor instance is Ractor-safe.
28 29 30 |
# File 'lib/cdc/core/processor.rb', line 28 def ractor_safe? self.class.ractor_safe? end |
#start ⇒ self
Start the processor.
Runtime layers can call this before dispatch begins. The default implementation is a no-op.
38 39 40 |
# File 'lib/cdc/core/processor.rb', line 38 def start self end |
#stop ⇒ self
Stop the processor.
Runtime layers can call this during shutdown. The default implementation is a no-op.
48 49 50 |
# File 'lib/cdc/core/processor.rb', line 48 def stop self end |