-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
Marcos G. Zimmermann edited this page Sep 25, 2025
·
4 revisions
Configure Lepus globally via Lepus.configure or Rails Railtie defaults.
Lepus.configure do |config|
config.connection_name = "MyApp"
config.rabbitmq_url = ENV.fetch("RABBITMQ_URL", "amqp://guest:guest@localhost:5672")
endOptions:
-
rabbitmq_url— defaultENV["RABBITMQ_URL"] || amqp://guest:guest@localhost:5672 -
connection_name— appears in RabbitMQ connection info -
recovery_attempts— max network recovery attempts (nil = infinite, default 10) -
recovery_interval— seconds between network recovery attempts (default 5.0) -
recover_from_connection_close— enable Bunny auto-recovery (default true) -
consumers_directory— directory to eager load consumers from (defaultapp/consumers) -
app_executor— Rails executor to wrap async work -
on_thread_error— Proc called on thread errors -
process_heartbeat_interval— seconds between heartbeats (default 60) -
process_alive_threshold— seconds to consider process alive (default 300) -
logger=— setLepus.logger
Lepus.configure do |config|
config.worker(:default) do |w|
w.pool_size = 1
w.pool_timeout = 5.0
w.before_fork { ActiveRecord::Base.clear_all_connections! }
w.after_fork { ActiveRecord::Base.establish_connection }
end
config.worker(:datasync, pool_size: 1, pool_timeout: 5.0)
end- Worker attributes:
pool_size,pool_timeout,before_fork,after_fork. - Each worker has its own connection pool (
Bunny::Sessionconnections). - Each consumer subscription gets a dedicated channel from the worker's pool.
Consumers assign themselves with worker: { name:, threads: } in their configure call.
Lepus.configure do |config|
config.producer(pool_size: 2, pool_timeout: 10.0)
# or
config.producer { |c| c.pool_size = 2; c.pool_timeout = 10.0 }
endNote: The producer pool_size represents Bunny connections (Bunny::Session), not channels. Bunny’s channel pooling is efficient; a single connection usually suffices.
When using Rails, the Railtie sets sensible defaults:
-
app.executorasapp_executor -
on_thread_errorreports viaRails.errorwhen available, otherwise logs - Log subscriber attaches to
:lepusevents