Class: Hooksmith::Jobs::DispatcherJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Hooksmith::Jobs::DispatcherJob
- Defined in:
- lib/hooksmith/jobs/dispatcher_job.rb
Overview
ActiveJob for asynchronous webhook processing.
This job wraps the Dispatcher to process webhooks in the background, allowing your webhook endpoint to respond quickly while processing happens asynchronously.
Instance Method Summary collapse
-
#perform(provider:, event:, payload:, **options) ⇒ Object
Performs the webhook dispatch asynchronously.
Instance Method Details
#perform(provider:, event:, payload:, **options) ⇒ Object
Performs the webhook dispatch asynchronously.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hooksmith/jobs/dispatcher_job.rb', line 41 def perform(provider:, event:, payload:, **) provider = provider.to_s event = event.to_s if check_idempotency?() key = Hooksmith::Idempotency.extract_key(provider:, payload:) if key && Hooksmith::Idempotency.already_processed?(provider:, key:) Hooksmith.logger.info("Skipping duplicate webhook: #{provider}/#{event} (key=#{key})") return nil end end Hooksmith::Dispatcher.new(provider:, event:, payload:).run! end |