Sha256: 466819b5207656a768e0b0337d6ef782c90aef4608b0388e54eed742ef11880b
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# coding: utf-8 # frozen_string_literal: true module Stealth class Controller module CatchAll extend ActiveSupport::Concern included do def run_catch_all(reason: nil) error_level = fetch_error_level Stealth::Logger.l(topic: "catch_all", message: "CatchAll #{catch_all_state(error_level)} triggered for #{error_slug}: #{reason}") if defined?(CatchAllsController) step_to flow: 'catch_all', state: catch_all_state(error_level) end end private def fetch_error_level if fail_attempts = $redis.get(error_slug) begin fail_attempts = Integer(fail_attempts) rescue ArgumentError fail_attempts = 1 end fail_attempts += 1 else fail_attempts = 1 end # Set the error with an expiration to avoid filling Redis $redis.setex(error_slug, 15.minutes.to_i, fail_attempts) fail_attempts end def error_slug ['error', current_user_id, current_session.flow_string, current_session.state_string].join('-') end def catch_all_state(error_level) "level#{error_level}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stealth-0.10.0 | lib/stealth/controller/catch_all.rb |