Class: Brute::Middleware::UserQueue

Inherits:
Base
  • Object
show all
Defined in:
lib/brute/middleware/user_queue.rb

Constant Summary

Constants included from Hooks

Hooks::AFTER_LLM_EVENT, Hooks::AFTER_TOOL_EVENT, Hooks::APPROVE_TOOL_EVENT, Hooks::BEFORE_LLM_EVENT, Hooks::BEFORE_TOOL_EVENT, Hooks::COMPACTED_EVENT, Hooks::COMPACT_DURATION_EVENT, Hooks::DURATION_EVENT, Hooks::ENTER_EVENT, Hooks::EXIT_EVENT, Hooks::FARADAY_ERROR_EVENT, Hooks::LLM_DURATION_EVENT, Hooks::LLM_FAILURE_EVENT, Hooks::MIDDLEWARE_ADDED_EVENT, Hooks::OPEN_ROUTER_SERVER_ERROR_EVENT, Hooks::STANDARD_ERROR_EVENT, Hooks::TOOL_DURATION_EVENT, Hooks::TURN_DURATION_EVENT, Hooks::TURN_END_EVENT, Hooks::TURN_START_EVENT

Instance Method Summary collapse

Methods included from Hooks

new

Constructor Details

#initialize(app, inputs: []) ⇒ UserQueue

Useful for testing... App will keep looping till all inputs are drained.



13
14
15
16
# File 'lib/brute/middleware/user_queue.rb', line 13

def initialize(app, inputs: [])
  @app = app
  @inputs = inputs
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/brute/middleware/user_queue.rb', line 18

def call(env)
  if @inputs.any?
    while inputs.any?
      inputs.shift.then do |input|
        @app.call(env)
      end
    end
  else
    @app.call
  end
end