Class: Hatchet::ConcurrencyExpression
- Inherits:
-
Object
- Object
- Hatchet::ConcurrencyExpression
- Defined in:
- lib/hatchet/concurrency.rb
Overview
Defines a concurrency expression for workflow or task-level concurrency control
Constant Summary collapse
- LIMIT_STRATEGY_MAP =
Map Ruby symbol to v1 proto enum symbol
{ cancel_in_progress: :CANCEL_IN_PROGRESS, cancel_newest: :CANCEL_NEWEST, group_round_robin: :GROUP_ROUND_ROBIN, queue: :QUEUE_NEWEST, drop_newest: :DROP_NEWEST, }.freeze
Instance Attribute Summary collapse
-
#expression ⇒ String
readonly
CEL expression evaluated against the workflow input.
-
#limit_strategy ⇒ Symbol
readonly
Strategy when limit is exceeded (:cancel_in_progress, :cancel_newest, :group_round_robin, :queue).
-
#max_runs ⇒ Integer
readonly
Maximum concurrent runs for this key.
Instance Method Summary collapse
-
#initialize(expression:, max_runs: 1, limit_strategy: :cancel_in_progress) ⇒ ConcurrencyExpression
constructor
A new instance of ConcurrencyExpression.
-
#to_h ⇒ Hash
Convert to a hash for API serialization.
-
#to_proto ⇒ V1::Concurrency
Convert to a V1::Concurrency protobuf message.
Constructor Details
#initialize(expression:, max_runs: 1, limit_strategy: :cancel_in_progress) ⇒ ConcurrencyExpression
Returns a new instance of ConcurrencyExpression.
39 40 41 42 43 |
# File 'lib/hatchet/concurrency.rb', line 39 def initialize(expression:, max_runs: 1, limit_strategy: :cancel_in_progress) @expression = expression @max_runs = max_runs @limit_strategy = limit_strategy end |
Instance Attribute Details
#expression ⇒ String (readonly)
Returns CEL expression evaluated against the workflow input.
28 29 30 |
# File 'lib/hatchet/concurrency.rb', line 28 def expression @expression end |
#limit_strategy ⇒ Symbol (readonly)
Returns Strategy when limit is exceeded (:cancel_in_progress, :cancel_newest, :group_round_robin, :queue).
34 35 36 |
# File 'lib/hatchet/concurrency.rb', line 34 def limit_strategy @limit_strategy end |
#max_runs ⇒ Integer (readonly)
Returns Maximum concurrent runs for this key.
31 32 33 |
# File 'lib/hatchet/concurrency.rb', line 31 def max_runs @max_runs end |
Instance Method Details
#to_h ⇒ Hash
Convert to a hash for API serialization
47 48 49 50 51 52 53 |
# File 'lib/hatchet/concurrency.rb', line 47 def to_h { expression: @expression, max_runs: @max_runs, limit_strategy: @limit_strategy.to_s.upcase, } end |
#to_proto ⇒ V1::Concurrency
Convert to a V1::Concurrency protobuf message
66 67 68 69 70 71 72 73 74 |
# File 'lib/hatchet/concurrency.rb', line 66 def to_proto proto_strategy = LIMIT_STRATEGY_MAP[@limit_strategy] || :CANCEL_IN_PROGRESS ::V1::Concurrency.new( expression: @expression, max_runs: @max_runs, limit_strategy: proto_strategy, ) end |