From 1a8d8b52e74b9fd3b8bae15801e3dac89b92a59a Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Sun, 12 Dec 2021 13:41:55 +0500 Subject: [PATCH] Changed redis setup --- app/controllers/epp/base_controller.rb | 2 +- app/lib/shunter.rb | 7 ++++++- config/application.yml.sample | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 3400a07e5..024a39406 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -20,8 +20,8 @@ module Epp rescue_from StandardError, with: :respond_with_command_failed_error rescue_from AuthorizationError, with: :respond_with_authorization_error - rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error rescue_from Shunter::ThrottleError, with: :respond_with_session_limit_exceeded_error + rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error before_action :set_paper_trail_whodunnit diff --git a/app/lib/shunter.rb b/app/lib/shunter.rb index 3339a8fcd..b06de6b9f 100644 --- a/app/lib/shunter.rb +++ b/app/lib/shunter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Shunter module_function @@ -7,7 +9,10 @@ module Shunter ONE_MINUTE = 60 ONE_HUNDRED_REQUESTS = 100 - BASE_CONNECTION = ENV['shunter_redis_connection'] || { host: 'redis', port: 6379 } + BASE_CONNECTION = { + host: ENV['shunter_redis_host'] || 'redis', + port: (ENV['shunter_redis_port'] || '6379').to_i, + }.freeze def default_error_message "Session limit exceeded. Current limit is #{default_threshold} in #{default_timespan} seconds" diff --git a/config/application.yml.sample b/config/application.yml.sample index b8b9b12d0..dffeea5be 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -199,6 +199,8 @@ test: legal_documents_dir: 'test/fixtures/files' shunter_default_adapter: "Shunter::Adapters::Memory" shunter_enabled: "false" + shunter_redis_host: "redis" + shunter_redis_port: "6379" openssl_config_path: 'test/fixtures/files/test_ca/openssl.cnf' crl_dir: 'test/fixtures/files/test_ca/crl'