Class: Falqon::Configuration
- Inherits:
-
Object
- Object
- Falqon::Configuration
- Extended by:
- T::Sig
- Defined in:
- lib/falqon/configuration.rb
Overview
Falqon configuration
Falqon can be configured before use, by leveraging the Falqon.configure
method. It’s recommended to configure Falqon in an initializer file, such as config/initializers/falqon.rb
. In a Rails application, the generator can be used to create the initializer file:
rails generate falqon:install
Otherwise, the file can be created manually:
Falqon.configure do |config|
# Configure global queue name prefix
# config.prefix = ENV.fetch("FALQON_PREFIX", "falqon")
# Retry strategy (none or linear)
# config.retry_strategy = :linear
# Maximum number of retries before a message is discarded (-1 for infinite retries)
# config.max_retries = 3
# Retry delay (in seconds) for linear retry strategy (defaults to 0)
# config.retry_delay = 60
# Configure the Redis client options
# config.redis_options = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0") }
# Or, configure the Redis client directly
# config.redis = ConnectionPool.new(size: 5, timeout: 5) { Redis.new(url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0")) }
# Configure logger
# config.logger = Logger.new(STDOUT)
end
The values above are the default values.
In addition, it is recommended to configure Redis to be persistent in production environments, in order not to lose data. Refer to the Redis documentation for more information.
Instance Attribute Summary collapse
- #logger ⇒ Object
- #max_retries ⇒ Object
- #prefix ⇒ Object
- #redis ⇒ Object
- #redis_options ⇒ Object
- #retry_delay ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#logger ⇒ Object
137 138 139 |
# File 'lib/falqon/configuration.rb', line 137 def logger @logger ||= Logger.new(File::NULL) end |
#max_retries ⇒ Object
106 107 108 |
# File 'lib/falqon/configuration.rb', line 106 def max_retries @max_retries ||= 3 end |
#prefix ⇒ Object
78 79 80 |
# File 'lib/falqon/configuration.rb', line 78 def prefix @prefix ||= "falqon" end |
#redis ⇒ Object
122 123 124 |
# File 'lib/falqon/configuration.rb', line 122 def redis @redis ||= ConnectionPool.new(size: 5, timeout: 5) { Redis.new(**) } end |
#redis_options ⇒ Object
128 129 130 131 132 133 |
# File 'lib/falqon/configuration.rb', line 128 def @redis_options ||= { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0"), middlewares: [Middlewares::Logger], } end |
#retry_delay ⇒ Object
116 117 118 |
# File 'lib/falqon/configuration.rb', line 116 def retry_delay @retry_delay ||= 0 end |
Instance Method Details
#retry_strategy ⇒ Object
86 87 88 |
# File 'lib/falqon/configuration.rb', line 86 def retry_strategy @retry_strategy ||= :linear end |
#retry_strategy=(retry_strategy) ⇒ Object
94 95 96 97 98 |
# File 'lib/falqon/configuration.rb', line 94 def retry_strategy=(retry_strategy) raise ArgumentError, "Invalid retry strategy #{retry_strategy.inspect}" unless [:none, :linear].include? retry_strategy @retry_strategy = retry_strategy end |