Class: RubyPi::Tools::Executor
- Inherits:
-
Object
- Object
- RubyPi::Tools::Executor
- Defined in:
- lib/ruby_pi/tools/executor.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
Default timeout for each tool execution, in seconds.
30
Instance Attribute Summary collapse
-
#mode ⇒ Symbol
readonly
The execution mode (:parallel or :sequential).
-
#timeout ⇒ Numeric
readonly
The per-tool timeout in seconds.
Instance Method Summary collapse
-
#execute(calls) ⇒ Array<RubyPi::Tools::Result>
Executes a list of tool calls and returns their results.
-
#initialize(registry, mode: :parallel, timeout: DEFAULT_TIMEOUT) ⇒ Executor
constructor
Creates a new Executor.
Constructor Details
#initialize(registry, mode: :parallel, timeout: DEFAULT_TIMEOUT) ⇒ Executor
Creates a new Executor.
44 45 46 47 48 49 50 51 52 |
# File 'lib/ruby_pi/tools/executor.rb', line 44 def initialize(registry, mode: :parallel, timeout: DEFAULT_TIMEOUT) unless %i[parallel sequential].include?(mode) raise ArgumentError, "Mode must be :parallel or :sequential, got #{mode.inspect}" end @registry = registry @mode = mode @timeout = timeout end |
Instance Attribute Details
#mode ⇒ Symbol (readonly)
Returns The execution mode (:parallel or :sequential).
33 34 35 |
# File 'lib/ruby_pi/tools/executor.rb', line 33 def mode @mode end |
#timeout ⇒ Numeric (readonly)
Returns The per-tool timeout in seconds.
36 37 38 |
# File 'lib/ruby_pi/tools/executor.rb', line 36 def timeout @timeout end |
Instance Method Details
#execute(calls) ⇒ Array<RubyPi::Tools::Result>
Executes a list of tool calls and returns their results.
Each call is a hash with ‘:name` (String or Symbol) and `:arguments` (Hash). Tools are looked up in the registry; if a tool is not found, a failure Result is returned for that call.
62 63 64 65 66 67 68 69 |
# File 'lib/ruby_pi/tools/executor.rb', line 62 def execute(calls) case @mode when :parallel execute_parallel(calls) when :sequential execute_sequential(calls) end end |