Class: CDC::Core::OrderingKey
- Inherits:
-
Object
- Object
- CDC::Core::OrderingKey
- Defined in:
- lib/cdc/core/ordering_key.rb
Overview
Immutable grouping key for ordering-related dispatch.
OrderingKey captures the scope plus the components that define a particular ordered lane. It does not choose an execution strategy.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether the key has no components.
-
#initialize(scope:, components: {}) ⇒ OrderingKey
constructor
Build an ordering key.
-
#to_h ⇒ Hash{String=>Object}
Convert the key into a Ractor-shareable hash.
Constructor Details
#initialize(scope:, components: {}) ⇒ OrderingKey
Build an ordering key.
18 19 20 21 22 |
# File 'lib/cdc/core/ordering_key.rb', line 18 def initialize(scope:, components: {}) @scope = OrderingScope.normalize(scope) @components = EventMetadata.new(components).to_h Ractor.make_shareable(self) end |
Instance Attribute Details
#components ⇒ Symbol, Hash{String=>Object} (readonly)
12 13 14 |
# File 'lib/cdc/core/ordering_key.rb', line 12 def components @components end |
#scope ⇒ Symbol, Hash{String=>Object} (readonly)
12 13 14 |
# File 'lib/cdc/core/ordering_key.rb', line 12 def scope @scope end |
Instance Method Details
#empty? ⇒ Boolean
Whether the key has no components.
27 |
# File 'lib/cdc/core/ordering_key.rb', line 27 def empty? = components.empty? |
#to_h ⇒ Hash{String=>Object}
Convert the key into a Ractor-shareable hash.
32 33 34 35 36 37 |
# File 'lib/cdc/core/ordering_key.rb', line 32 def to_h Ractor.make_shareable({ 'scope' => scope, 'components' => components }.freeze) end |