Class: Phronomy::Workflow
- Inherits:
-
Object
- Object
- Phronomy::Workflow
- Includes:
- Runnable
- Defined in:
- lib/phronomy/workflow.rb,
lib/phronomy/workflow/phase_machine_builder.rb
Overview
StateChart-style Workflow definition DSL.
Defined Under Namespace
Classes: Builder, PhaseMachineBuilder
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(runner) ⇒ Workflow
constructor
A new instance of Workflow.
- #invoke(input, config: {}, invocation_context: nil) ⇒ Object
- #invoke_async(input, config: {}, invocation_context: nil) ⇒ Object
- #resume(state:, input: nil) ⇒ Object
- #send_event(state:, event:, input: nil) ⇒ Object
-
#signal(thread_id:, event:, payload: nil) ⇒ Boolean
Sends an event to an active Workflow session without blocking.
- #stream(input, config: {}, invocation_context: nil, &block) ⇒ Object
Methods included from Runnable
Constructor Details
#initialize(runner) ⇒ Workflow
Returns a new instance of Workflow.
17 18 19 |
# File 'lib/phronomy/workflow.rb', line 17 def initialize(runner) @runner = runner end |
Class Method Details
Instance Method Details
#invoke(input, config: {}, invocation_context: nil) ⇒ Object
21 22 23 24 |
# File 'lib/phronomy/workflow.rb', line 21 def invoke(input, config: {}, invocation_context: nil) config = _apply_invocation_context(config, invocation_context) if invocation_context @runner.invoke(input, config: config) end |
#invoke_async(input, config: {}, invocation_context: nil) ⇒ Object
26 27 28 29 |
# File 'lib/phronomy/workflow.rb', line 26 def invoke_async(input, config: {}, invocation_context: nil) config = _apply_invocation_context(config, invocation_context) if invocation_context @runner.invoke_deferred(input, config: config) end |
#resume(state:, input: nil) ⇒ Object
36 37 38 |
# File 'lib/phronomy/workflow.rb', line 36 def resume(state:, input: nil) @runner.resume(state: state, input: input) end |
#send_event(state:, event:, input: nil) ⇒ Object
40 41 42 |
# File 'lib/phronomy/workflow.rb', line 40 def send_event(state:, event:, input: nil) @runner.send_event(state: state, event: event, input: input) end |
#signal(thread_id:, event:, payload: nil) ⇒ Boolean
Sends an event to an active Workflow session without blocking.
This method is safe to call from an Agent/Tool listener running on the EventLoop thread because it only enqueues a later dispatch.
52 53 54 55 56 57 58 |
# File 'lib/phronomy/workflow.rb', line 52 def signal(thread_id:, event:, payload: nil) @runner.signal( thread_id: thread_id, event: event, payload: payload ) end |
#stream(input, config: {}, invocation_context: nil, &block) ⇒ Object
31 32 33 34 |
# File 'lib/phronomy/workflow.rb', line 31 def stream(input, config: {}, invocation_context: nil, &block) config = _apply_invocation_context(config, invocation_context) if invocation_context @runner.stream(input, config: config, &block) end |