sqs_web 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 665814da097e54c82e213f7b028c8a8f4d2ef6e7
4
- data.tar.gz: b7bf80a9fb820e16895468399ef237e2bcfc4c6d
3
+ metadata.gz: f1d0cd87afe1d1dfdd5da9165db08b08b11fdde8
4
+ data.tar.gz: 9d8e84165d1fd2a4ebb0d37357d82f44a8136140
5
5
  SHA512:
6
- metadata.gz: ebbac66344253cd96a7e3472d0a640be9c400fff44e97cbf4fe05ad2314ed33739221025aaa6a08d43f979a3a527248f010ff21f94d99369c07681fda1ce1bdc
7
- data.tar.gz: 34d3c19ed3e168fb13ef5ec5c9d9b924c0131a57308df05e4a2b10dfdf7b3c9d5c5fd182e274f45ac53ae8cd3c74f1f5d69c8373f4a85af6a788cb92c55243fa
6
+ metadata.gz: 031aae0a0934a71c853a3e5d3c6b6c2261b69f2c0ef09148e2b064df4eaf89246aa4cb288e77b313030a7191e76a9d2ffa1c7c2027f87c6a3274eff5b764a481
7
+ data.tar.gz: 0d81895f0e84f2dfe24469ba8834fd1019069c525b4fe5913d0428b3587d806c21a4919612ba6fac554674188e0a95ea5644f02830f7cd0f9b55607bc5f70fba
@@ -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
- `SqsWeb.options[:aws]` supports the following hash key/value pairs:
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 = aws_options.merge(credentials: credentials) if credentials.set?
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
- dlq_queue_url = sqs.get_queue_url(queue_name: queue_name).queue_url
32
- source_queue_url = sqs.list_dead_letter_source_queues({queue_url: dlq_queue_url}).queue_urls.first
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "sqs_web"
3
- gem.version = "0.0.3"
3
+ gem.version = "0.0.4"
4
4
  gem.author = "Nathaniel Ritholtz"
5
5
  gem.email = "nritholtz@gmail.com"
6
6
  gem.homepage = "https://github.com/nritholtz/sqs_web"
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.3
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-07-18 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra