diff --git a/app/jobs/action_cable_broadcast_job.rb b/app/jobs/action_cable_broadcast_job.rb index aedae2c46..b1208a97c 100644 --- a/app/jobs/action_cable_broadcast_job.rb +++ b/app/jobs/action_cable_broadcast_job.rb @@ -1,5 +1,5 @@ class ActionCableBroadcastJob < ApplicationJob - queue_as :default + queue_as :critical def perform(members, event_name, data) members.each do |member| diff --git a/app/jobs/agent_bots/csml_job.rb b/app/jobs/agent_bots/csml_job.rb index 1a65bf713..d0975e364 100644 --- a/app/jobs/agent_bots/csml_job.rb +++ b/app/jobs/agent_bots/csml_job.rb @@ -1,5 +1,5 @@ class AgentBots::CsmlJob < ApplicationJob - queue_as :bots + queue_as :high def perform(event, agent_bot, message) event_data = { message: message } diff --git a/app/jobs/agent_bots/webhook_job.rb b/app/jobs/agent_bots/webhook_job.rb index bfad365bc..d0c4e7959 100644 --- a/app/jobs/agent_bots/webhook_job.rb +++ b/app/jobs/agent_bots/webhook_job.rb @@ -1,3 +1,3 @@ class AgentBots::WebhookJob < WebhookJob - queue_as :bots + queue_as :high end diff --git a/app/jobs/agents/destroy_job.rb b/app/jobs/agents/destroy_job.rb index 1c40827b6..8596ca1cc 100644 --- a/app/jobs/agents/destroy_job.rb +++ b/app/jobs/agents/destroy_job.rb @@ -1,5 +1,5 @@ class Agents::DestroyJob < ApplicationJob - queue_as :default + queue_as :low def perform(account, user) ActiveRecord::Base.transaction do diff --git a/app/jobs/avatar/avatar_from_url_job.rb b/app/jobs/avatar/avatar_from_url_job.rb index a25698bc1..f1efea225 100644 --- a/app/jobs/avatar/avatar_from_url_job.rb +++ b/app/jobs/avatar/avatar_from_url_job.rb @@ -1,5 +1,5 @@ class Avatar::AvatarFromUrlJob < ApplicationJob - queue_as :default + queue_as :low def perform(avatarable, avatar_url) return unless avatarable.respond_to?(:avatar) diff --git a/app/jobs/conversations/activity_message_job.rb b/app/jobs/conversations/activity_message_job.rb index 54f631ee6..aa532e5b2 100644 --- a/app/jobs/conversations/activity_message_job.rb +++ b/app/jobs/conversations/activity_message_job.rb @@ -1,5 +1,5 @@ class Conversations::ActivityMessageJob < ApplicationJob - queue_as :default + queue_as :high def perform(conversation, message_params) conversation.messages.create!(message_params) diff --git a/app/jobs/delete_object_job.rb b/app/jobs/delete_object_job.rb index e478cd374..6f6e13a01 100644 --- a/app/jobs/delete_object_job.rb +++ b/app/jobs/delete_object_job.rb @@ -1,5 +1,5 @@ class DeleteObjectJob < ApplicationJob - queue_as :default + queue_as :low def perform(object) object.destroy! diff --git a/app/jobs/event_dispatcher_job.rb b/app/jobs/event_dispatcher_job.rb index c08d52d74..2e6c807ea 100644 --- a/app/jobs/event_dispatcher_job.rb +++ b/app/jobs/event_dispatcher_job.rb @@ -1,5 +1,5 @@ class EventDispatcherJob < ApplicationJob - queue_as :events + queue_as :critical def perform(event_name, timestamp, data) Rails.configuration.dispatcher.async_dispatcher.publish_event(event_name, timestamp, data) diff --git a/app/jobs/hook_job.rb b/app/jobs/hook_job.rb index bf0c7a1f9..9d54462e2 100644 --- a/app/jobs/hook_job.rb +++ b/app/jobs/hook_job.rb @@ -1,5 +1,5 @@ class HookJob < ApplicationJob - queue_as :integrations + queue_as :medium def perform(hook, event_name, event_data = {}) case hook.app_id diff --git a/app/jobs/inboxes/fetch_imap_email_inboxes_job.rb b/app/jobs/inboxes/fetch_imap_email_inboxes_job.rb index 190714c1e..b360940e3 100644 --- a/app/jobs/inboxes/fetch_imap_email_inboxes_job.rb +++ b/app/jobs/inboxes/fetch_imap_email_inboxes_job.rb @@ -1,5 +1,5 @@ class Inboxes::FetchImapEmailInboxesJob < ApplicationJob - queue_as :low + queue_as :scheduled_jobs def perform Inbox.where(channel_type: 'Channel::Email').all.find_each(batch_size: 100) do |inbox| diff --git a/app/jobs/inboxes/fetch_imap_emails_job.rb b/app/jobs/inboxes/fetch_imap_emails_job.rb index b84e79ee6..1072e7ba6 100644 --- a/app/jobs/inboxes/fetch_imap_emails_job.rb +++ b/app/jobs/inboxes/fetch_imap_emails_job.rb @@ -1,7 +1,7 @@ require 'net/imap' class Inboxes::FetchImapEmailsJob < ApplicationJob - queue_as :low + queue_as :scheduled_jobs def perform(channel) return unless should_fetch_email?(channel) diff --git a/app/jobs/webhook_job.rb b/app/jobs/webhook_job.rb index 9f4d96a10..61b5e8daf 100644 --- a/app/jobs/webhook_job.rb +++ b/app/jobs/webhook_job.rb @@ -1,5 +1,5 @@ class WebhookJob < ApplicationJob - queue_as :webhooks + queue_as :medium def perform(url, payload) Webhooks::Trigger.execute(url, payload) diff --git a/app/models/custom_attribute_definition.rb b/app/models/custom_attribute_definition.rb index 59a314da6..71aab06f8 100644 --- a/app/models/custom_attribute_definition.rb +++ b/app/models/custom_attribute_definition.rb @@ -40,10 +40,10 @@ class CustomAttributeDefinition < ApplicationRecord private def sync_widget_pre_chat_custom_fields - ::Inboxes::SyncWidgetPreChatCustomFieldsJob.perform_now(account, attribute_key) + ::Inboxes::SyncWidgetPreChatCustomFieldsJob.perform_later(account, attribute_key) end def update_widget_pre_chat_custom_fields - ::Inboxes::UpdateWidgetPreChatCustomFieldsJob.perform_now(account, self) + ::Inboxes::UpdateWidgetPreChatCustomFieldsJob.perform_later(account, self) end end diff --git a/config/sidekiq.yml b/config/sidekiq.yml index c9bf96300..4bc3d1cb8 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -11,23 +11,22 @@ # Sidekiq will run this file through ERB when reading it so you can # even put in dynamic logic, like a host-specific queue. # http://www.mikeperham.com/2013/11/13/advanced-sidekiq-host-specific-queues/ +# https://github.com/sidekiq/sidekiq/wiki/Advanced-Options +# Since queues are declared without waits, the jobs in lower ranking queues will only be processed +# if there are no jobs in higher ranking queues. :queues: - - [async_database_migration, 1] - - [low, 2] - - [scheduled_jobs, 2] - - [webhooks, 2] - - [bots, 2] - - [active_storage_analysis, 2] - - [action_mailbox_incineration, 2] - - [active_storage_purge, 2] - - [integrations, 3] - - [default, 3] - - [mailers, 3] - - [medium, 4] - - [events, 4] - - [action_mailbox_routing, 4] - - [high, 5] - - [critical, 10] + - critical + - high + - medium + - default + - mailers + - action_mailbox_routing + - low + - scheduled_jobs + - async_database_migration + - active_storage_analysis + - active_storage_purge + - action_mailbox_incineration # you can override concurrency based on environment production: diff --git a/spec/jobs/agent_bots/webhook_job_spec.rb b/spec/jobs/agent_bots/webhook_job_spec.rb index 3c4fdce7a..c642d88fc 100644 --- a/spec/jobs/agent_bots/webhook_job_spec.rb +++ b/spec/jobs/agent_bots/webhook_job_spec.rb @@ -11,7 +11,7 @@ RSpec.describe AgentBots::WebhookJob, type: :job do it 'queues the job' do expect { job }.to have_enqueued_job(described_class) .with(url, payload) - .on_queue('bots') + .on_queue('high') end it 'executes perform' do diff --git a/spec/jobs/agents/destroy_job_spec.rb b/spec/jobs/agents/destroy_job_spec.rb index 38786dbc0..7d7f6c036 100644 --- a/spec/jobs/agents/destroy_job_spec.rb +++ b/spec/jobs/agents/destroy_job_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Agents::DestroyJob, type: :job do it 'enqueues the job' do expect { job }.to have_enqueued_job(described_class) .with(account, user) - .on_queue('default') + .on_queue('low') end describe '#perform' do diff --git a/spec/jobs/avatar/avatar_from_url_job_spec.rb b/spec/jobs/avatar/avatar_from_url_job_spec.rb index 9a4ebd646..11e43de64 100644 --- a/spec/jobs/avatar/avatar_from_url_job_spec.rb +++ b/spec/jobs/avatar/avatar_from_url_job_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Avatar::AvatarFromUrlJob, type: :job do it 'enqueues the job' do expect { described_class.perform_later(avatarable, avatar_url) }.to have_enqueued_job(described_class) - .on_queue('default') + .on_queue('low') end it 'will attach avatar from url' do diff --git a/spec/jobs/delete_object_job_spec.rb b/spec/jobs/delete_object_job_spec.rb index 7ed623bd4..15f19bdb0 100644 --- a/spec/jobs/delete_object_job_spec.rb +++ b/spec/jobs/delete_object_job_spec.rb @@ -8,7 +8,7 @@ RSpec.describe DeleteObjectJob, type: :job do it 'enqueues the job' do expect { job }.to have_enqueued_job(described_class) .with(account) - .on_queue('default') + .on_queue('low') end context 'when an object is passed to the job' do diff --git a/spec/jobs/event_dispatcher_job_spec.rb b/spec/jobs/event_dispatcher_job_spec.rb index 14da570b2..a0297785a 100644 --- a/spec/jobs/event_dispatcher_job_spec.rb +++ b/spec/jobs/event_dispatcher_job_spec.rb @@ -11,7 +11,7 @@ RSpec.describe EventDispatcherJob, type: :job do it 'queues the job' do expect { job }.to have_enqueued_job(described_class) .with(event_name, timestamp, event_data) - .on_queue('events') + .on_queue('critical') end it 'publishes event' do diff --git a/spec/jobs/hook_job_spec.rb b/spec/jobs/hook_job_spec.rb index 85517d51c..8275bfa31 100644 --- a/spec/jobs/hook_job_spec.rb +++ b/spec/jobs/hook_job_spec.rb @@ -12,7 +12,7 @@ RSpec.describe HookJob, type: :job do it 'enqueues the job' do expect { job }.to have_enqueued_job(described_class) .with(hook, event_name, event_data) - .on_queue('integrations') + .on_queue('medium') end context 'when handleable events like message.created' do diff --git a/spec/jobs/inboxes/fetch_imap_email_inboxes_job_spec.rb b/spec/jobs/inboxes/fetch_imap_email_inboxes_job_spec.rb index df0b34aca..33f516e42 100644 --- a/spec/jobs/inboxes/fetch_imap_email_inboxes_job_spec.rb +++ b/spec/jobs/inboxes/fetch_imap_email_inboxes_job_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Inboxes::FetchImapEmailInboxesJob, type: :job do it 'enqueues the job' do expect { described_class.perform_later }.to have_enqueued_job(described_class) - .on_queue('low') + .on_queue('scheduled_jobs') end context 'when called' do diff --git a/spec/jobs/inboxes/fetch_imap_emails_job_spec.rb b/spec/jobs/inboxes/fetch_imap_emails_job_spec.rb index 329574535..14efa2031 100644 --- a/spec/jobs/inboxes/fetch_imap_emails_job_spec.rb +++ b/spec/jobs/inboxes/fetch_imap_emails_job_spec.rb @@ -19,7 +19,7 @@ RSpec.describe Inboxes::FetchImapEmailsJob, type: :job do it 'enqueues the job' do expect { described_class.perform_later }.to have_enqueued_job(described_class) - .on_queue('low') + .on_queue('scheduled_jobs') end context 'when imap fetch new emails' do diff --git a/spec/jobs/webhook_job_spec.rb b/spec/jobs/webhook_job_spec.rb index 4a10762f4..f5b8d9dd8 100644 --- a/spec/jobs/webhook_job_spec.rb +++ b/spec/jobs/webhook_job_spec.rb @@ -11,7 +11,7 @@ RSpec.describe WebhookJob, type: :job do it 'queues the job' do expect { job }.to have_enqueued_job(described_class) .with(url, payload) - .on_queue('webhooks') + .on_queue('medium') end it 'executes perform' do