mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 06:56:23 +02:00
27 lines
624 B
Ruby
27 lines
624 B
Ruby
module Shunter
|
|
module_function
|
|
|
|
class ThrottleError < StandardError; end
|
|
|
|
BASE_LOGGER = ::Logger.new($stdout)
|
|
ONE_MINUTE = 60
|
|
ONE_HUNDRED_REQUESTS = 100
|
|
|
|
BASE_CONNECTION = ENV['shunter_redis_connection'] || { host: 'redis', port: 6379 }
|
|
|
|
def default_timespan
|
|
ENV['shunter_default_timespan'] || ONE_MINUTE
|
|
end
|
|
|
|
def default_threshold
|
|
ENV['shunter_default_threshold'] || ONE_HUNDRED_REQUESTS
|
|
end
|
|
|
|
def default_adapter
|
|
ENV['shunter_default_adapter'] || 'Shunter::Adapters::Redis'
|
|
end
|
|
|
|
def feature_enabled?
|
|
ActiveModel::Type::Boolean.new.cast(ENV['shunter_enabled'] || 'false')
|
|
end
|
|
end
|