Skip to content

Commit

Permalink
chore(scalability): Add dedicated webhook worker (#2979)
Browse files Browse the repository at this point in the history
- Add a webhook worker
  • Loading branch information
jdenquin authored Dec 18, 2024
1 parent 70858cd commit 6bb3cbf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/jobs/send_http_webhook_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# frozen_string_literal: true

class SendHttpWebhookJob < ApplicationJob
queue_as do
if ActiveModel::Type::Boolean.new.cast(ENV['SIDEKIQ_WEBHOOK'])
:webhook_worker
else
:webhook
end
end

def perform(webhook)
Webhooks::SendHttpService.call(webhook:)
end
Expand Down
8 changes: 7 additions & 1 deletion app/jobs/send_webhook_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
require Rails.root.join('lib/lago_http_client/lago_http_client')

class SendWebhookJob < ApplicationJob
queue_as 'webhook'
queue_as do
if ActiveModel::Type::Boolean.new.cast(ENV['SIDEKIQ_WEBHOOK'])
:webhook_worker
else
:webhook
end
end

retry_on ActiveJob::DeserializationError, wait: :polynomially_longer, attempts: 6

Expand Down
10 changes: 10 additions & 0 deletions config/sidekiq/sidekiq_webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
concurrency: 10
timeout: 25
retry: 1
queues:
- webhook_worker

production:
concurrency: <%= ENV.fetch('SIDEKIQ_CONCURRENCY', 10) %>
staging:
concurrency: 10

0 comments on commit 6bb3cbf

Please sign in to comment.