-
Notifications
You must be signed in to change notification settings - Fork 8
Refactor ReindexByDoiJob to include Shoryuken::Worker and update perform method #1495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,11 @@ | ||||||||||||||||||||
| # frozen_string_literal: true | ||||||||||||||||||||
|
|
||||||||||||||||||||
| class ReindexByDoiJob < ApplicationJob | ||||||||||||||||||||
| queue_as :lupo_background | ||||||||||||||||||||
| include Shoryuken::Worker | ||||||||||||||||||||
|
|
||||||||||||||||||||
| def perform(doi_id, _options = {}) | ||||||||||||||||||||
| shoryuken_options queue: -> { "#{ENV["RAILS_ENV"]}_lupo_background" }, auto_delete: true | ||||||||||||||||||||
|
|
||||||||||||||||||||
| def perform(sqs_message = nil, doi_id = nil) | ||||||||||||||||||||
| doi = Doi.find_by(doi: doi_id) | ||||||||||||||||||||
| return unless doi.present? | ||||||||||||||||||||
|
||||||||||||||||||||
| def perform(sqs_message = nil, doi_id = nil) | |
| doi = Doi.find_by(doi: doi_id) | |
| return unless doi.present? | |
| def perform(sqs_message = nil, doi_id = nil) | |
| # When called via perform_later, sqs_message contains the doi_id | |
| # When called directly by Shoryuken, doi_id is the second argument | |
| resolved_doi_id = doi_id || sqs_message | |
| doi = Doi.find_by(doi: resolved_doi_id) | |
| return unless doi.present? |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/jobs/reindex_by_doi_job.rb` around lines 8 - 10, The perform signature
currently def perform(sqs_message = nil, doi_id = nil) causes single-argument
calls (perform_later/perform_now) to place the DOI into sqs_message and leave
doi_id nil; update perform in ReindexByDoiJob so it normalizes inputs: if doi_id
is nil then detect whether sqs_message is the DOI string (e.g., String) or a
Shoryuken/SQS payload (e.g., Hash with "body" or :body) and set doi_id
accordingly before calling Doi.find_by(doi: doi_id); this preserves support for
perform_later/perform_now and direct Shoryuken invocation while keeping calls to
Doi.find_by unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the Shoryuken queue name aligned with the publisher.
Line 7 hard-codes
ENV["RAILS_ENV"], butapp/services/sqs_message_service.rb:6-7publishes toENV["SQS_PREFIX"].presence || Rails.env. In prefixed environments, producers will send to<prefix>_lupo_backgroundwhile this worker listens on<RAILS_ENV>_lupo_background, so it will never see those messages.💡 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents