Class: Barbeque::JobQueue
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Barbeque::JobQueue
- Defined in:
- app/models/barbeque/job_queue.rb
Constant Summary collapse
- SQS_NAME_PREFIX =
ENV['BARBEQUE_SQS_NAME_PREFIX'] || 'Barbeque-'
- SQS_NAME_MAX_LENGTH =
80
Class Method Summary collapse
-
.queue_url_from_name(name) ⇒ String
Returns queue URL of given name.
Instance Method Summary collapse
Class Method Details
.queue_url_from_name(name) ⇒ String
Returns queue URL of given name. Basically, we should use stored queue URL as the documentation suggests. But when the Barbeque’s database is temporarily unavailable due to scheduled maintenance, we have to build queue URL without the database. The maintenance mode is enabled by BARBEQUE_DATABASE_MAINTENANCE and AWS_ACCOUNT_ID variable. [1]: docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-message-identifiers.html#sqs-general-identifiers
30 31 32 33 34 35 36 |
# File 'app/models/barbeque/job_queue.rb', line 30 def self.queue_url_from_name(name) if Barbeque::Maintenance.database_maintenance_mode? "https://sqs.#{ENV.fetch('AWS_REGION')}.amazonaws.com/#{ENV.fetch('AWS_ACCOUNT_ID')}/#{SQS_NAME_PREFIX}#{name}" else select(:queue_url).find_by!(name: name).queue_url end end |
Instance Method Details
#sqs_queue_name ⇒ Object
16 17 18 |
# File 'app/models/barbeque/job_queue.rb', line 16 def sqs_queue_name SQS_NAME_PREFIX + name end |