eventq 2.4.0 → 2.5.0

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
  SHA256:
3
- metadata.gz: c8a55998f78ac404d51a4278b44b802a23d1b9c322cad2a29b8c1e94950ad4fa
4
- data.tar.gz: 92dddbaed323bf8f803a07adc483376a2b255c43ce015c6a5ed59c3b81081478
3
+ metadata.gz: 59946bde6488da5c2567aec735c8a6f251e3532bc0b2636123a4940c519ce935
4
+ data.tar.gz: 4b202d8435f23ea6e88a5b7351f9317d91c9179f610651152af9c7b2939a993a
5
5
  SHA512:
6
- metadata.gz: 45465979d1c58fd6cb0a4f54752a7cb4278c002465cbb12e3f4ee8b6e98538d9f65ab35e15d69cb41ae88d28f00fbc275bb73b7bc45be777e3c576d07384143f
7
- data.tar.gz: 7011679b0e5c08fc6a0468067816e6bf136ce24900e411d5e1b1afedd53180c92c454dc9696874a2fad3f0a4d30dcd9a829a55fe4e9fb557b519f33abfec33c8
6
+ metadata.gz: 93e097eb9be108a117f855260ea2334de8018029ba5027349d587bcd28553ab9a296accaca936abfe209d628c5ced3177bbbcfe435f6e2b5bd550a701a066299
7
+ data.tar.gz: b83f581d669072a79e378cd93f428628e9896ae0fa8dd09db63c8d3b39505814a29c438690829703cf3ee469b8fc2098b04b50565939323455cf1acdbb0e8c58
@@ -12,7 +12,7 @@ module EventQ
12
12
  @manager = options[:queue_manager]
13
13
  end
14
14
 
15
- def subscribe(event_type, queue, topic_region = nil, queue_region = nil)
15
+ def subscribe(event_type, queue, topic_region = nil, queue_region = nil, topic_namespaces = [EventQ.namespace])
16
16
  if queue.isolated
17
17
  method = :get_topic_arn
18
18
  else
@@ -22,24 +22,28 @@ module EventQ
22
22
  topic_arn = @client.sns_helper(topic_region).public_send(method, event_type, topic_region)
23
23
  raise Exceptions::EventTypeNotFound, 'SNS topic not found, unable to subscribe' unless topic_arn
24
24
 
25
- q = @manager.get_queue(queue)
26
- queue_arn = @client.sqs_helper(queue_region).get_queue_arn(queue)
25
+ queue_arn = configure_queue(queue, queue_region)
27
26
 
28
- attributes = default_queue_attributes(q, queue_arn)
29
- @client.sqs(queue_region).set_queue_attributes(attributes)
27
+ # subscribe the queue to the topic with the namespaces provided
28
+ topic_namespaces.each do |namespace|
29
+ namespaced_topic_arn = topic_arn.gsub(":#{EventQ.namespace}-", ":#{namespace}-")
30
30
 
31
- # skip subscribe if subscription for given queue/topic already exists
32
- # this fixes a localstack issue: https://github.com/localstack/localstack/issues/933
33
- return true if existing_subscription?(queue_arn, topic_arn)
31
+ # create the sns topic - this method is idempotent & returns the topic arn if it already exists
32
+ @client.sns.create_topic(name: "#{namespace}-#{event_type}".delete('.')) unless queue.isolated
34
33
 
35
- @client.sns(topic_region).subscribe(
36
- topic_arn: topic_arn,
37
- protocol: 'sqs',
38
- endpoint: queue_arn
39
- )
34
+ # skip subscribe if subscription for given queue/topic already exists
35
+ # this is a workaround for a localstack issue: https://github.com/localstack/localstack/issues/933
36
+ return true if existing_subscription?(queue_arn, namespaced_topic_arn)
40
37
 
41
- EventQ.logger.debug do
42
- "[#{self.class} #subscribe] - Subscribing Queue: #{queue.name} to topic_arn: #{topic_arn}, endpoint: #{queue_arn}"
38
+ EventQ.logger.debug do
39
+ "[#{self.class} #subscribe] - Subscribing Queue: #{queue.name} to topic_arn: #{namespaced_topic_arn}, endpoint: #{queue_arn}"
40
+ end
41
+
42
+ @client.sns(topic_region).subscribe(
43
+ topic_arn: namespaced_topic_arn,
44
+ protocol: 'sqs',
45
+ endpoint: queue_arn
46
+ )
43
47
  end
44
48
 
45
49
  true
@@ -51,6 +55,15 @@ module EventQ
51
55
 
52
56
  private
53
57
 
58
+ def configure_queue(queue, region)
59
+ q = @manager.get_queue(queue)
60
+ queue_arn = @client.sqs_helper(region).get_queue_arn(queue)
61
+
62
+ attributes = default_queue_attributes(q, queue_arn)
63
+ @client.sqs(region).set_queue_attributes(attributes)
64
+ queue_arn
65
+ end
66
+
54
67
  def default_queue_attributes(queue, queue_arn)
55
68
  {
56
69
  queue_url: queue,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventq
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SageOne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2019-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
270
  requirements: []
271
- rubygems_version: 3.0.4
271
+ rubygems_version: 3.0.6
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: EventQ is a pub/sub system that uses async notifications and message queues