Skip to content
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

Use SQS_PREFIX not ES_PREFIX for queues #1205

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ module Indexable
elsif instance_of?(Event)
OtherDoiJob.perform_later(dois_to_import)
# ignore if record was created via Salesforce API
elsif instance_of?(Provider) && !from_salesforce && (Rails.env.production? || ENV["ES_PREFIX"] == "stage")
elsif instance_of?(Provider) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the PR Description, but yes this isn't much better, but arguably not worse

send_provider_export_message(to_jsonapi.merge(slack_output: true))
elsif instance_of?(Client) && !from_salesforce && (Rails.env.production? || ENV["ES_PREFIX"] == "stage")
elsif instance_of?(Client) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
send_client_export_message(to_jsonapi.merge(slack_output: true))
elsif instance_of?(Contact) && !from_salesforce && (Rails.env.production? || ENV["ES_PREFIX"] == "stage")
elsif instance_of?(Contact) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
send_contact_export_message(to_jsonapi.merge(slack_output: true))
end
end
Expand Down Expand Up @@ -105,12 +105,7 @@ def send_contact_export_message(data)
# we use the AWS SQS client directly as there is no consumer in this app
def send_message(body, options = {})
sqs = Aws::SQS::Client.new
queue_name_prefix =
if Rails.env.stage?
ENV["ES_PREFIX"].present? ? "stage" : "test"
else
Rails.env
end
queue_name_prefix = ENV["SQS_PREFIX"].present? ? ENV["SQS_PREFIX"] : Rails.env
queue_url =
sqs.get_queue_url(queue_name: "#{queue_name_prefix}_#{options[:queue_name]}").queue_url
options[:shoryuken_class] ||= "DoiImportWorker"
Expand Down
10 changes: 1 addition & 9 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,7 @@ def self.reset(username)
)
url = ENV["BRACCO_URL"] + "?jwt=" + jwt
reset_url = ENV["BRACCO_URL"] + "/reset"
title = if Rails.env.stage?
if ENV["ES_PREFIX"].present?
"DataCite Fabrica Stage"
else
"DataCite Fabrica Test"
end
else
"DataCite Fabrica"
end
title = ENV["BRACCO_TITLE"]
subject = "#{title}: Password Reset Request"
account_type =
if user.instance_of?(Provider)
Expand Down
11 changes: 4 additions & 7 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
ENV["API_URL"] ||= "https://api.stage.datacite.org"
ENV["CDN_URL"] ||= "https://assets.datacite.org"
ENV["BRACCO_URL"] ||= "https://doi.datacite.org"
ENV["BRACCO_TITLE"] ||= "DataCite Fabrica"
ENV["GITHUB_URL"] ||= "https://github.com/datacite/lupo"
ENV["SEARCH_URL"] ||= "https://search.datacite.org/"
ENV["VOLPINO_URL"] ||= "https://profiles.datacite.org/api"
Expand All @@ -63,6 +64,7 @@
ENV["MG_DOMAIN"] ||= "mg.datacite.org"
ENV["HANDLES_MINTED"] ||= "10132"
ENV["REALM"] ||= ENV["API_URL"]
ENV["SQS_PREFIX"] ||= ""

module Lupo
class Application < Rails::Application
Expand Down Expand Up @@ -171,13 +173,8 @@ class Application < Rails::Application
# set Active Job queueing backend
config.active_job.queue_adapter = ENV["AWS_REGION"] ? :shoryuken : :inline

# use SQS based on environment, use "test" prefix for test system
if Rails.env.stage?
config.active_job.queue_name_prefix =
ENV["ES_PREFIX"].present? ? "stage" : "test"
else
config.active_job.queue_name_prefix = Rails.env
end
# use SQS based on environment or what has been defined
config.active_job.queue_name_prefix = ENV["SQS_PREFIX"].present? ? ENV["SQS_PREFIX"] : Rails.env

config.generators { |g| g.fixture_replacement :factory_bot }

Expand Down