Class: Circuitry::Middleware::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/circuitry/middleware/rack.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Rack

Returns a new instance of Rack.



7
8
9
10
11
# File 'lib/circuitry/middleware/rack.rb', line 7

def initialize(app, options = {})
  @app = app
  Circuitry.publisher_config.async_strategy = options.fetch(:publish_async_strategy, :batch)
  Circuitry.subscriber_config.async_strategy = options.fetch(:subscribe_async_strategy, :thread)
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/circuitry/middleware/rack.rb', line 13

def call(env)
  status, headers, actual_body = @app.call(env)
  body = ::Rack::BodyProxy.new(actual_body) do
    Circuitry.flush
  end
  [status, headers, body]
end