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.
Constant Summary collapse
- EMPTY_COMPONENTS =
Ractor.make_shareable( {} # : Hash[untyped, untyped] .freeze )
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether the key has no components.
-
#initialize(scope:, components: EMPTY_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: EMPTY_COMPONENTS) ⇒ OrderingKey
Build an ordering key.
23 24 25 26 27 |
# File 'lib/cdc/core/ordering_key.rb', line 23 def initialize(scope:, components: EMPTY_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)
17 18 19 |
# File 'lib/cdc/core/ordering_key.rb', line 17 def components @components end |
#scope ⇒ Symbol, Hash{String=>Object} (readonly)
17 18 19 |
# File 'lib/cdc/core/ordering_key.rb', line 17 def scope @scope end |
Instance Method Details
#empty? ⇒ Boolean
Whether the key has no components.
32 |
# File 'lib/cdc/core/ordering_key.rb', line 32 def empty? = components.empty? |
#to_h ⇒ Hash{String=>Object}
Convert the key into a Ractor-shareable hash.
37 38 39 40 41 42 |
# File 'lib/cdc/core/ordering_key.rb', line 37 def to_h Ractor.make_shareable({ 'scope' => scope, 'components' => components }.freeze) end |