cyclone_lariat 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +10 -10
- data/lib/cyclone_lariat/list_topics_store.rb +45 -0
- data/lib/cyclone_lariat/sns_client.rb +15 -4
- data/lib/cyclone_lariat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc046e8076d845378a3e32c67b9afe728f59e98d3728246b7835480464cb6f0
|
4
|
+
data.tar.gz: 7e521071b62ec40f378cee86d06b42d5a7e1857ca4ad72ddf9a92d97d7e2a2fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93830e825f2035d114ebb96ab8692d27670a644429675ddd8f21b582109adb4f7c8a0285bdd0f3c4b55d63af2da1b8f25155de1681250a2aef1f6d053366c012
|
7
|
+
data.tar.gz: ab100001f182c78762f0278ced7e6b404c25ef02380540946137e1022bda883359300029dce9e44457bc4fce0dd649a0d72ff6f6b4e2f0ffa66fb09c8d1ac834
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.3.8] - 2022-09-05
|
8
|
+
Changed
|
9
|
+
- Added pagination to sns topics list for receiving all topics
|
10
|
+
- Added list topics store for reduce unnecessary requests to aws
|
11
|
+
|
7
12
|
## [0.3.7] - 2022-02-10
|
8
13
|
Changed
|
9
14
|
- Add exception when received broken JSON
|
@@ -40,8 +45,8 @@ Added
|
|
40
45
|
|
41
46
|
## [0.2.2] - 2021-06-08
|
42
47
|
Changed
|
43
|
-
- Fix save to database
|
44
|
-
- Rename error to client error
|
48
|
+
- Fix save to database
|
49
|
+
- Rename error to client error
|
45
50
|
|
46
51
|
## [0.2.1] - 2021-06-02
|
47
52
|
- Fix can load from database if error_details is nil
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cyclone_lariat (0.3.
|
4
|
+
cyclone_lariat (0.3.8)
|
5
5
|
aws-sdk-sns
|
6
6
|
aws-sdk-sqs
|
7
7
|
luna_park (~> 0.11)
|
@@ -13,19 +13,19 @@ GEM
|
|
13
13
|
public_suffix (>= 2.0.2, < 5.0)
|
14
14
|
ast (2.4.2)
|
15
15
|
aws-eventstream (1.2.0)
|
16
|
-
aws-partitions (1.
|
17
|
-
aws-sdk-core (3.
|
16
|
+
aws-partitions (1.626.0)
|
17
|
+
aws-sdk-core (3.140.0)
|
18
18
|
aws-eventstream (~> 1, >= 1.0.2)
|
19
19
|
aws-partitions (~> 1, >= 1.525.0)
|
20
20
|
aws-sigv4 (~> 1.1)
|
21
|
-
jmespath (~> 1.
|
22
|
-
aws-sdk-sns (1.
|
23
|
-
aws-sdk-core (~> 3, >= 3.
|
21
|
+
jmespath (~> 1, >= 1.6.1)
|
22
|
+
aws-sdk-sns (1.54.0)
|
23
|
+
aws-sdk-core (~> 3, >= 3.127.0)
|
24
24
|
aws-sigv4 (~> 1.1)
|
25
|
-
aws-sdk-sqs (1.
|
26
|
-
aws-sdk-core (~> 3, >= 3.
|
25
|
+
aws-sdk-sqs (1.51.1)
|
26
|
+
aws-sdk-core (~> 3, >= 3.127.0)
|
27
27
|
aws-sigv4 (~> 1.1)
|
28
|
-
aws-sigv4 (1.
|
28
|
+
aws-sigv4 (1.5.1)
|
29
29
|
aws-eventstream (~> 1, >= 1.0.2)
|
30
30
|
byebug (11.1.3)
|
31
31
|
coderay (1.1.3)
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
diff-lcs (1.5.0)
|
39
39
|
docile (1.3.5)
|
40
40
|
hashdiff (1.0.1)
|
41
|
-
jmespath (1.
|
41
|
+
jmespath (1.6.1)
|
42
42
|
luna_park (0.11.1)
|
43
43
|
method_source (1.0.0)
|
44
44
|
parallel (1.20.1)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
module CycloneLariat
|
6
|
+
class ListTopicsStore
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def topic_arn(topic_name)
|
10
|
+
@topics[topic_name.to_sym]
|
11
|
+
end
|
12
|
+
|
13
|
+
def list
|
14
|
+
@topics.keys
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_topics(aws_client)
|
18
|
+
@topics ||= {}
|
19
|
+
@aws_client = aws_client
|
20
|
+
fetch
|
21
|
+
end
|
22
|
+
|
23
|
+
def clear_store!
|
24
|
+
@topics = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def fetch
|
30
|
+
return unless @topics.empty?
|
31
|
+
|
32
|
+
@next_token = ''
|
33
|
+
topics_from_aws until @next_token.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def topics_from_aws
|
37
|
+
result = @aws_client.list_topics(next_token: @next_token)
|
38
|
+
@next_token = result.next_token
|
39
|
+
result.topics.each do |topic|
|
40
|
+
topic_name = topic.topic_arn.split(':').last
|
41
|
+
@topics[topic_name.to_sym] = topic.topic_arn
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'aws-sdk-sns'
|
4
4
|
require_relative 'abstract/client'
|
5
|
+
require_relative 'list_topics_store'
|
5
6
|
|
6
7
|
module CycloneLariat
|
7
8
|
class SnsClient < Abstract::Client
|
@@ -31,11 +32,21 @@ module CycloneLariat
|
|
31
32
|
private
|
32
33
|
|
33
34
|
def topic_arn(topic_name)
|
34
|
-
|
35
|
-
|
36
|
-
raise Errors::TopicNotFound.new(expected_topic: topic_name, existed_topics: list.map(&:topic_arn)) if topic.nil?
|
35
|
+
topics_store.add_topics(aws_client)
|
36
|
+
topic_arn = topics_store.topic_arn(topic_name)
|
37
37
|
|
38
|
-
|
38
|
+
if topic_arn.nil?
|
39
|
+
raise Errors::TopicNotFound.new(
|
40
|
+
expected_topic: topic_name,
|
41
|
+
existed_topics: topics_store.list
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
topic_arn
|
46
|
+
end
|
47
|
+
|
48
|
+
def topics_store
|
49
|
+
ListTopicsStore.instance
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyclone_lariat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kudrin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-sns
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- lib/cyclone_lariat/command.rb
|
272
272
|
- lib/cyclone_lariat/errors.rb
|
273
273
|
- lib/cyclone_lariat/event.rb
|
274
|
+
- lib/cyclone_lariat/list_topics_store.rb
|
274
275
|
- lib/cyclone_lariat/messages_mapper.rb
|
275
276
|
- lib/cyclone_lariat/messages_repo.rb
|
276
277
|
- lib/cyclone_lariat/middleware.rb
|