sqs_web 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.markdown +3 -1
- data/lib/sqs_web/application/sqs_action.rb +21 -8
- data/spec/integration/overview_spec.rb +1 -1
- data/sqs_web.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d0cd87afe1d1dfdd5da9165db08b08b11fdde8
|
4
|
+
data.tar.gz: 9d8e84165d1fd2a4ebb0d37357d82f44a8136140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 031aae0a0934a71c853a3e5d3c6b6c2261b69f2c0ef09148e2b064df4eaf89246aa4cb288e77b313030a7191e76a9d2ffa1c7c2027f87c6a3274eff5b764a481
|
7
|
+
data.tar.gz: 0d81895f0e84f2dfe24469ba8834fd1019069c525b4fe5913d0428b3587d806c21a4919612ba6fac554674188e0a95ea5644f02830f7cd0f9b55607bc5f70fba
|
data/README.markdown
CHANGED
@@ -54,10 +54,12 @@ end
|
|
54
54
|
`sqs_web` runs as a Sinatra application within the rails application. Visit it at `/sqs`.
|
55
55
|
|
56
56
|
## Supported SqsWeb configuration options
|
57
|
-
|
57
|
+
The ```aws``` section is used to configure the Aws objects used by sqs_web internally. The sqs_web-specific keys are listed below, and you can expect any other key defined in that block to be passed on untouched to ```Aws::SQS::Client#initialize```:
|
58
|
+
|
58
59
|
- `access_key_id` : AWS Access Key. If not set will default to environment variable `AWS_ACCESS_KEY_ID` or instance profile credentials
|
59
60
|
- `secret_access_key` : AWS Secret Access Key. If not set will default to environment variable `AWS_SECRET_ACCESS_KEY` or instance profile credentials.
|
60
61
|
- `region`: AWS region for the SQS queue. If not set will default to environment variable `AWS_REGION` or else to `us-east-1`.
|
62
|
+
- `sqs_endpoint` can be used to explicitly override the SQS endpoint. If not set will default to environment variable `AWS_SQS_ENDPOINT` or default SQS endpoint.
|
61
63
|
|
62
64
|
`SqsWeb.options[:queues]` supports an array of strings for the SQS queue names.
|
63
65
|
```ruby
|
@@ -3,33 +3,46 @@ class SqsAction
|
|
3
3
|
protected
|
4
4
|
|
5
5
|
def self.sqs
|
6
|
-
@@sqs ||= Aws::SQS::Client.new
|
6
|
+
@@sqs ||= Aws::SQS::Client.new(SqsWeb.options[:aws])
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.initialize_aws
|
10
10
|
# aws-sdk tries to load the credentials from the ENV variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
|
11
11
|
# when not explicit supplied
|
12
|
-
return if SqsWeb.options[:aws].empty?
|
13
|
-
|
14
12
|
aws_options = SqsWeb.options[:aws]
|
15
13
|
|
14
|
+
return if aws_options.empty?
|
15
|
+
|
16
16
|
# assume credentials based authentication
|
17
17
|
credentials = Aws::Credentials.new(
|
18
18
|
aws_options[:access_key_id],
|
19
19
|
aws_options[:secret_access_key])
|
20
20
|
|
21
21
|
# but only if the configuration options have valid values
|
22
|
-
aws_options =
|
22
|
+
aws_options[:credentials] = credentials if credentials.set?
|
23
|
+
|
24
|
+
#Override SQS endpoint
|
25
|
+
environment_endpoint = ENV["AWS_SQS_ENDPOINT"]
|
26
|
+
explicit_endpoint = SqsWeb.options[:aws][:endpoint] || environment_endpoint
|
27
|
+
aws_options[:endpoint] = explicit_endpoint unless explicit_endpoint.to_s.empty?
|
23
28
|
|
24
29
|
Aws::SQS::Client.remove_plugin(Aws::Plugins::SQSMd5s)
|
25
|
-
|
26
|
-
Aws.config = aws_options
|
27
30
|
end
|
28
31
|
|
29
32
|
def self.load_queue_urls
|
30
33
|
sqs && SqsWeb.options[:queues].map do |queue_name|
|
31
|
-
|
32
|
-
|
34
|
+
#More helpful error message when queue name does not exist
|
35
|
+
begin
|
36
|
+
dlq_queue_url = sqs.get_queue_url(queue_name: queue_name).queue_url
|
37
|
+
rescue Aws::SQS::Errors::NonExistentQueue => e
|
38
|
+
raise $!, "#{queue_name} is not an existing queue name" ,$!.backtrace
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
source_queue_url = sqs.list_dead_letter_source_queues({queue_url: dlq_queue_url}).queue_urls.first
|
43
|
+
# ElasticMQ doesn't support 'list_dead_letter_source_queues' yet
|
44
|
+
rescue Aws::SQS::Errors::NotFound
|
45
|
+
end
|
33
46
|
{name: queue_name, url: dlq_queue_url, source_url: source_queue_url}
|
34
47
|
end
|
35
48
|
end
|
@@ -31,6 +31,6 @@ RSpec.describe "Overview Page", :sqs do
|
|
31
31
|
|
32
32
|
visit "/sqs/overview"
|
33
33
|
|
34
|
-
match_content(page, "Aws::SQS::Errors::NonExistentQueue: BOGUSQUEUE")
|
34
|
+
match_content(page, "<Aws::SQS::Errors::NonExistentQueue: BOGUSQUEUE is not an existing queue name>: BOGUSQUEUE is not an existing queue name")
|
35
35
|
end
|
36
36
|
end
|
data/sqs_web.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqs_web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Ritholtz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|