module Fly::RegionalDatabase
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.
Public Class Methods
replay_in_primary_region!(state:)
click to toggle source
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
# File lib/fly-ruby/regional_database.rb, line 17 def self.replay_in_primary_region!(state:) res = Rack::Response.new( "", 409, {"Fly-Replay" => "region=#{Fly.configuration.primary_region};state=#{state}"} ) res.finish end