Skip to content

Commit

Permalink
Make all sidekiq jobs unique
Browse files Browse the repository at this point in the history
Every one of these jobs has results based purely on the arguments, so there's no need — and some danger — to having duplicate jobs.
  • Loading branch information
ragesoss committed Oct 11, 2017
1 parent a791349 commit cc59f2f
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem 'figaro'
gem 'whenever'
gem 'mysql2'
gem 'sidekiq'
gem 'sidekiq-unique-jobs'
gem 'activerecord-import'
gem 'dalli'
gem 'connection_pool'
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ GEM
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
redis (~> 3.3, >= 3.3.3)
sidekiq-unique-jobs (5.0.10)
sidekiq (>= 4.0, <= 6.0)
thor (~> 0)
simple_form (3.5.0)
actionpack (> 4, < 5.2)
activemodel (> 4, < 5.2)
Expand Down Expand Up @@ -561,6 +564,7 @@ DEPENDENCIES
sentry-raven
shoulda-matchers (~> 3.1)
sidekiq
sidekiq-unique-jobs
simple_form
simplecov
timecop
Expand Down
1 change: 1 addition & 0 deletions app/workers/alert_mailer_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class AlertMailerWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_email(alert_id:)
perform_async(alert_id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/announce_course_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class AnnounceCourseWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_announcement(course:, editing_user:, instructor:)
perform_async(course.id, editing_user.id, instructor.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/blocked_edits_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class BlockedEditsWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_notifications(user:)
perform_async(user.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/course_submission_mailer_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class CourseSubmissionMailerWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_email(course, instructor)
perform_async(course.id, instructor.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/delete_course_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class DeleteCourseWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_deletion(course:, current_user:)
perform_async(course.id, current_user.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/enroll_in_course_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class EnrollInCourseWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_edits(course:, editing_user:, enrolling_user:)
perform_async(course.id, editing_user.id, enrolling_user.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/greet_students_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class GreetStudentsWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_greetings(course, greeter)
perform_async(course.id, greeter.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/notify_untrained_users_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class NotifyUntrainedUsersWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_notifications(course:, notifying_user:)
perform_async(course.id, notifying_user.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/remove_assignment_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class RemoveAssignmentWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_edits(course:, editing_user:, assignment:)
perform_async(course.id, editing_user.id, assignment.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/set_preferences_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class SetPreferencesWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_preference_setting(user:)
perform_async(user.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/update_assignments_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class UpdateAssignmentsWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_edits(course:, editing_user:)
perform_async(course.id, editing_user.id)
Expand Down
1 change: 1 addition & 0 deletions app/workers/update_course_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class UpdateCourseWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed

def self.schedule_edits(course:, editing_user:)
perform_async(course.id, editing_user.id)
Expand Down

0 comments on commit cc59f2f

Please sign in to comment.