Class: Kaal::Backend::DispatchAttemptLogger
- Inherits:
-
Object
- Object
- Kaal::Backend::DispatchAttemptLogger
- Defined in:
- lib/kaal/backend/dispatch_attempt_logger.rb
Overview
Logs dispatch attempts through a backend-provided dispatch registry.
Instance Method Summary collapse
- #call(lock_key) ⇒ Object
-
#initialize(configuration:, dispatch_registry_provider:, logger: nil, node_id_provider: Socket.method(:gethostname)) ⇒ DispatchAttemptLogger
constructor
A new instance of DispatchAttemptLogger.
Constructor Details
#initialize(configuration:, dispatch_registry_provider:, logger: nil, node_id_provider: Socket.method(:gethostname)) ⇒ DispatchAttemptLogger
Returns a new instance of DispatchAttemptLogger.
13 14 15 16 17 18 |
# File 'lib/kaal/backend/dispatch_attempt_logger.rb', line 13 def initialize(configuration:, dispatch_registry_provider:, logger: nil, node_id_provider: Socket.method(:gethostname)) @configuration = configuration @dispatch_registry_provider = dispatch_registry_provider @logger = logger @node_id_provider = node_id_provider end |
Instance Method Details
#call(lock_key) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kaal/backend/dispatch_attempt_logger.rb', line 20 def call(lock_key) return unless @configuration.enable_log_dispatch_registry registry = @dispatch_registry_provider.call return unless registry cron_key, fire_time = DispatchLogging.parse_lock_key(lock_key) registry.log_dispatch(cron_key, fire_time, @node_id_provider.call, 'dispatched') rescue StandardError => e (@logger || @configuration.logger)&.error("Failed to log dispatch for #{lock_key}: #{e.}") end |