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 +4 -4
- data/lib/eventq/eventq_aws/aws_subscription_manager.rb +28 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59946bde6488da5c2567aec735c8a6f251e3532bc0b2636123a4940c519ce935
|
4
|
+
data.tar.gz: 4b202d8435f23ea6e88a5b7351f9317d91c9179f610651152af9c7b2939a993a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
26
|
-
queue_arn = @client.sqs_helper(queue_region).get_queue_arn(queue)
|
25
|
+
queue_arn = configure_queue(queue, queue_region)
|
27
26
|
|
28
|
-
|
29
|
-
|
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
|
-
|
32
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
42
|
-
|
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
|
+
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-
|
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.
|
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
|