Module: Fly::RegionalDatabase
- Defined in:
- lib/fly-ruby/regional_database.rb
Overview
Note that using instance variables in Rack middleware is considered a poor practice in multithreaded environments. Instead of using dirty tricks like using Object#dup, values are passed to methods.
Defined Under Namespace
Classes: DbExceptionHandlerMiddleware, ReplayableRequestMiddleware
Class Method Summary collapse
-
.replay_in_primary_region!(state:) ⇒ Object
Stop the current request and ask for it to be replayed in the primary region.
Class Method Details
.replay_in_primary_region!(state:) ⇒ Object
Stop the current request and ask for it to be replayed in the primary region. Pass one of three states to the target region, to determine how to handle the request:
Possible states: captured_write, http_method, threshold captured_write: A write was rejected by the database http_method: A non-idempotent HTTP method was replayed before hitting the application threshold: A recent write set a threshold during which all requests are replayed
19 20 21 22 23 24 25 26 |
# File 'lib/fly-ruby/regional_database.rb', line 19 def self.replay_in_primary_region!(state:) res = Rack::Response.new( "", 409, {"Fly-Replay" => "region=#{Fly.configuration.primary_region};state=#{state}"} ) res.finish end |