Class: ApiKeys::Jobs::CallbacksJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- ApiKeys::Jobs::CallbacksJob
- Includes:
- Logging
- Defined in:
- lib/api_keys/jobs/callbacks_job.rb
Overview
Background job to execute configured lifecycle callbacks asynchronously.
Instance Method Summary collapse
-
#perform(callback_type, context = {}) ⇒ Object
Executes the appropriate callback based on the type.
Instance Method Details
#perform(callback_type, context = {}) ⇒ Object
Executes the appropriate callback based on the type.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/api_keys/jobs/callbacks_job.rb', line 20 def perform(callback_type, context = {}) config = ApiKeys.configuration case callback_type when :before_authentication execute_callback(config.before_authentication, context) when :after_authentication execute_callback(config.after_authentication, context) else log_warn "[ApiKeys::Jobs::CallbacksJob] Unknown callback type: #{callback_type}" end rescue StandardError => e log_error "[ApiKeys::Jobs::CallbacksJob] Error executing callback #{callback_type} with context #{context.inspect}: #{e.class}: #{e.} #{e.backtrace.join(" ")}" # Avoid retrying callback errors by default, as the original request succeeded. # Depending on callback importance, users might configure retries separately. end |