Adds automatic recovery and exit strategy

This commit is contained in:
Brusk Awat 2024-08-05 00:54:19 +03:00
parent 876a48a1ab
commit 28b620b7b4
No known key found for this signature in database
GPG Key ID: F51EBACCACA34A52
2 changed files with 15 additions and 2 deletions

View File

@ -9,6 +9,15 @@ module RabbitCarrots
end
class Configuration
attr_accessor :rabbitmq_host, :rabbitmq_port, :rabbitmq_user, :rabbitmq_password, :rabbitmq_vhost, :routing_key_mappings, :rabbitmq_exchange_name
attr_accessor :rabbitmq_host,
:rabbitmq_port,
:rabbitmq_user,
:rabbitmq_password,
:rabbitmq_vhost,
:routing_key_mappings,
:rabbitmq_exchange_name,
:automatically_recover,
:network_recovery_interval,
:recovery_attempts
end
end

View File

@ -11,7 +11,11 @@ module RabbitCarrots
port: RabbitCarrots.configuration.rabbitmq_port,
user: RabbitCarrots.configuration.rabbitmq_user,
password: RabbitCarrots.configuration.rabbitmq_password,
vhost: RabbitCarrots.configuration.rabbitmq_vhost
vhost: RabbitCarrots.configuration.rabbitmq_vhost,
automatically_recover: RabbitCarrots.configuration.automatically_recover || true,
network_recovery_interval: RabbitCarrots.configuration.network_recovery_interval || 5,
recovery_attempts: RabbitCarrots.configuration.recovery_attempts || 5,
recovery_attempts_exhausted: -> { Process.kill('TERM', Process.pid) }
)
@connection.start