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 " WARN: JETS_QUEUE_URL_\#{queue_name.upcase} not set. Unable to get queue url.\n Maybe double check for:\n\n config/jets/deploy.rb\n\n config.job.additional_queues = [\"\#{queue_name}\"]\n\n A queue name must be defined for the SQS queue to be created.\n EOL\n end\n end\n\n # Locally can also be set to avoid the API call for testing\n return ENV[env_var] if ENV[env_var]\n\n # Only reach here locally.\n # Will try getting queue url from API latest release\n # 1. can be nil\n # 2. can raise NotFound error\n resp = Jets::Api::Release.retrieve(\"latest\")\n endpoint = resp.endpoints.find { |x| x[\"name\"] == \"queue_url_\#{queue_name}\" }\n endpoint&.url\nrescue Jets::Api::Error::NotFound => e\n puts \"WARN: Unable to get queue url from API: \#{e.message}\".color(:yellow)\n puts <<~EOL\n INFO: You can set \#{env_var} in your environment to avoid this API call.\n Locally, jets will try to get the latest release from the API to get the queue_url.\n This will only work if the stack has been deployed successfully.\n EOL\n raise\nend\n"
|