6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/jets/rails/job/queue/url.rb', line 6
def queue_url(queue_name)
env_var = "JETS_QUEUE_URL_#{queue_name.upcase}" if ENV["AWS_LAMBDA_FUNCTION_NAME"]
if ENV[env_var] return ENV[env_var]
else
puts <<~EOL
WARN: JETS_QUEUE_URL_#{queue_name.upcase} not set. Unable to get queue url.
Maybe double check for:
config/jets/deploy.rb
config.job.additional_queues = ["#{queue_name}"]
A queue name must be defined for the SQS queue to be created.
EOL
end
end
return ENV[env_var] if ENV[env_var]
resp = Jets::Api::Release.retrieve("latest")
endpoint = resp.endpoints.find { |x| x["name"] == "queue_url_#{queue_name}" }
endpoint&.url
rescue Jets::Api::Error::NotFound => e
puts "WARN: Unable to get queue url from API: #{e.message}".color(:yellow)
puts <<~EOL
INFO: You can set #{env_var} in your environment to avoid this API call.
Locally, jets will try to get the latest release from the API to get the queue_url.
This will only work if the stack has been deployed successfully.
EOL
raise
end
|