diff --git a/Gemfile b/Gemfile index b4352fa7..893eb528 100644 --- a/Gemfile +++ b/Gemfile @@ -44,6 +44,7 @@ gem 'turbo-rails' gem 'twitter_cldr', require: false gem 'tzinfo-data' +gem 'activejob-uniqueness' gem 'airbrake' gem 'newrelic_rpm' diff --git a/Gemfile.lock b/Gemfile.lock index 52baffbd..0599aa7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,9 @@ GEM activejob (8.0.1) activesupport (= 8.0.1) globalid (>= 0.3.6) + activejob-uniqueness (0.4.0) + activejob (>= 4.2, < 8.1) + redlock (>= 2.0, < 3) activemodel (8.0.1) activesupport (= 8.0.1) activerecord (8.0.1) @@ -111,6 +114,7 @@ GEM base64 (0.2.0) bcrypt (3.1.20) benchmark (0.4.0) + benchmark-ips (2.12.0) better_html (2.1.1) actionview (>= 6.0) activesupport (>= 6.0) @@ -443,6 +447,8 @@ GEM psych (>= 4.0.0) redis-client (0.23.0) connection_pool + redlock (2.0.6) + redis-client (>= 0.14.1, < 1.0.0) regexp_parser (2.9.3) reline (0.6.0) io-console (~> 0.5) @@ -594,12 +600,14 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + activejob-uniqueness airbrake annotaterb arabic-letter-connector aws-sdk-s3 aws-sdk-secretsmanager azure-storage-blob + benchmark-ips (~> 2.12.0) better_html bootsnap brakeman diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 55b41697..4c38234e 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true +require 'benchmark' + class ApplicationJob < ActiveJob::Base include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation + unique :while_executing, on_conflict: :log retry_on StandardError, wait: 6.seconds, attempts: 5 unless Docuseal.multitenant? - unique :while_executing, on_conflict: :log def perform(*args) receiver_str, _, message = args.shift.rpartition('.')