Sha256: 7a1b24a8cf4607c5093ecbe7838475e6b9f0992552f13d8d673711f925f8b6c6
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module SafeRequestTimeout class Railtie < Rails::Railtie config.safe_request_timeout = ActiveSupport::OrderedOptions.new config.safe_request_timeout.active_record_hook = true config.safe_request_timeout.rack_timeout = nil initializer "safe_request_timeout" do |app| if app.config.safe_request_timeout.active_record_hook ActiveSupport.on_load(:active_record) do begin SafeRequestTimeout::ActiveRecordHook.add_timeout! rescue ActiveRecord::ActiveRecordError => e Rails.logger&.warn("Could not add ActiveRecord hook for SafeRequestTimeout: #{e.inspect}") end end end if defined?(ActiveJob::Base.around_perform) ActiveJob::Base.around_perform do |job, block| SafeRequestTimeout.timeout(nil, &block) end end app.middleware.use SafeRequestTimeout::RackMiddleware, app.config.safe_request_timeout.rack_timeout if defined?(Sidekiq.server?) && Sidekiq.server? Sidekiq.configure_server do |sidekiq_config| sidekiq_config.server_middleware do |chain| chain.add SafeRequestTimeout::SidekiqMiddleware end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
safe_request_timeout-1.0.2 | lib/safe_request_timeout/railtie.rb |
safe_request_timeout-1.0.1 | lib/safe_request_timeout/railtie.rb |