Class: CircuitBreaker::Executors::NatsExecutor
- Inherits:
-
BaseExecutor
- Object
- BaseExecutor
- CircuitBreaker::Executors::NatsExecutor
- Defined in:
- lib/circuit_breaker/executors/nats_executor.rb
Overview
Executor class that uses NATS for workflow event distribution Handles workflow state management and event processing
Instance Attribute Summary collapse
-
#nats ⇒ Object
readonly
Reader for NATS client.
-
#workflow_id ⇒ Object
readonly
Reader for workflow ID.
Attributes inherited from BaseExecutor
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(context = {}) ⇒ NatsExecutor
constructor
Initialize a new NATS executor.
Methods included from DSL
included, #validate_parameters
Constructor Details
#initialize(context = {}) ⇒ NatsExecutor
Initialize a new NATS executor
19 20 21 22 23 24 |
# File 'lib/circuit_breaker/executors/nats_executor.rb', line 19 def initialize(context = {}) super @nats_url = context[:nats_url] || 'nats://localhost:4222' @nats = NATS.connect(@nats_url) setup_jetstream end |
Instance Attribute Details
#nats ⇒ Object (readonly)
Reader for NATS client
14 15 16 |
# File 'lib/circuit_breaker/executors/nats_executor.rb', line 14 def nats @nats end |
#workflow_id ⇒ Object (readonly)
Reader for workflow ID
12 13 14 |
# File 'lib/circuit_breaker/executors/nats_executor.rb', line 12 def workflow_id @workflow_id end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/circuit_breaker/executors/nats_executor.rb', line 26 def execute return unless @context[:petri_net] workflow_id = create_workflow( @context[:petri_net], workflow_id: @context[:workflow_id] ) @result = { workflow_id: workflow_id, status: 'completed' } end |