cyclone_lariat 0.3.5 → 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/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +15 -2
- data/Gemfile.lock +37 -74
- data/README.md +1 -0
- data/cyclone_lariat.gemspec +1 -2
- data/lib/cyclone_lariat/list_topics_store.rb +45 -0
- data/lib/cyclone_lariat/messages_mapper.rb +10 -13
- data/lib/cyclone_lariat/middleware.rb +7 -3
- data/lib/cyclone_lariat/sns_client.rb +15 -4
- data/lib/cyclone_lariat/version.rb +1 -1
- metadata +4 -17
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/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.6
|
1
|
+
ruby-2.4.6
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,19 @@ 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
|
+
|
12
|
+
## [0.3.7] - 2022-02-10
|
13
|
+
Changed
|
14
|
+
- Add exception when received broken JSON
|
15
|
+
|
16
|
+
## [0.3.6] - 2022-02-09
|
17
|
+
Changed
|
18
|
+
- Downgrade minimum ruby version to 2.4.0
|
19
|
+
|
7
20
|
## [0.3.3] - 2021-07-14
|
8
21
|
Changed
|
9
22
|
- Bugfix of message equality check
|
@@ -32,8 +45,8 @@ Added
|
|
32
45
|
|
33
46
|
## [0.2.2] - 2021-06-08
|
34
47
|
Changed
|
35
|
-
- Fix save to database
|
36
|
-
- Rename error to client error
|
48
|
+
- Fix save to database
|
49
|
+
- Rename error to client error
|
37
50
|
|
38
51
|
## [0.2.1] - 2021-06-02
|
39
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)
|
@@ -9,75 +9,40 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.
|
12
|
+
addressable (2.8.0)
|
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)
|
32
|
-
concurrent-ruby (1.1.8)
|
33
32
|
crack (0.4.5)
|
34
33
|
rexml
|
35
34
|
database_cleaner-core (2.0.1)
|
36
35
|
database_cleaner-sequel (2.0.0)
|
37
36
|
database_cleaner-core (~> 2.0.0)
|
38
37
|
sequel
|
39
|
-
diff-lcs (1.
|
40
|
-
docile (1.
|
41
|
-
dry-configurable (0.12.1)
|
42
|
-
concurrent-ruby (~> 1.0)
|
43
|
-
dry-core (~> 0.5, >= 0.5.0)
|
44
|
-
dry-container (0.7.2)
|
45
|
-
concurrent-ruby (~> 1.0)
|
46
|
-
dry-configurable (~> 0.1, >= 0.1.3)
|
47
|
-
dry-core (0.5.0)
|
48
|
-
concurrent-ruby (~> 1.0)
|
49
|
-
dry-equalizer (0.3.0)
|
50
|
-
dry-inflector (0.2.0)
|
51
|
-
dry-initializer (3.0.4)
|
52
|
-
dry-logic (1.2.0)
|
53
|
-
concurrent-ruby (~> 1.0)
|
54
|
-
dry-core (~> 0.5, >= 0.5)
|
55
|
-
dry-schema (1.6.2)
|
56
|
-
concurrent-ruby (~> 1.0)
|
57
|
-
dry-configurable (~> 0.8, >= 0.8.3)
|
58
|
-
dry-core (~> 0.5, >= 0.5)
|
59
|
-
dry-initializer (~> 3.0)
|
60
|
-
dry-logic (~> 1.0)
|
61
|
-
dry-types (~> 1.5)
|
62
|
-
dry-types (1.5.1)
|
63
|
-
concurrent-ruby (~> 1.0)
|
64
|
-
dry-container (~> 0.3)
|
65
|
-
dry-core (~> 0.5, >= 0.5)
|
66
|
-
dry-inflector (~> 0.1, >= 0.1.2)
|
67
|
-
dry-logic (~> 1.0, >= 1.0.2)
|
68
|
-
dry-validation (1.6.0)
|
69
|
-
concurrent-ruby (~> 1.0)
|
70
|
-
dry-container (~> 0.7, >= 0.7.1)
|
71
|
-
dry-core (~> 0.4)
|
72
|
-
dry-equalizer (~> 0.2)
|
73
|
-
dry-initializer (~> 3.0)
|
74
|
-
dry-schema (~> 1.5, >= 1.5.2)
|
38
|
+
diff-lcs (1.5.0)
|
39
|
+
docile (1.3.5)
|
75
40
|
hashdiff (1.0.1)
|
76
|
-
jmespath (1.
|
77
|
-
luna_park (0.11.
|
41
|
+
jmespath (1.6.1)
|
42
|
+
luna_park (0.11.1)
|
78
43
|
method_source (1.0.0)
|
79
44
|
parallel (1.20.1)
|
80
|
-
parser (3.0.
|
45
|
+
parser (3.1.0.0)
|
81
46
|
ast (~> 2.4.1)
|
82
47
|
pg (1.2.3)
|
83
48
|
pry (0.13.1)
|
@@ -87,23 +52,23 @@ GEM
|
|
87
52
|
byebug (~> 11.0)
|
88
53
|
pry (~> 0.13.0)
|
89
54
|
public_suffix (4.0.6)
|
90
|
-
rainbow (3.
|
91
|
-
rake (13.0.
|
92
|
-
regexp_parser (2.
|
55
|
+
rainbow (3.1.1)
|
56
|
+
rake (13.0.6)
|
57
|
+
regexp_parser (2.2.0)
|
93
58
|
rexml (3.2.5)
|
94
|
-
rspec (3.
|
95
|
-
rspec-core (~> 3.
|
96
|
-
rspec-expectations (~> 3.
|
97
|
-
rspec-mocks (~> 3.
|
98
|
-
rspec-core (3.
|
99
|
-
rspec-support (~> 3.
|
100
|
-
rspec-expectations (3.
|
59
|
+
rspec (3.11.0)
|
60
|
+
rspec-core (~> 3.11.0)
|
61
|
+
rspec-expectations (~> 3.11.0)
|
62
|
+
rspec-mocks (~> 3.11.0)
|
63
|
+
rspec-core (3.11.0)
|
64
|
+
rspec-support (~> 3.11.0)
|
65
|
+
rspec-expectations (3.11.0)
|
101
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
-
rspec-support (~> 3.
|
103
|
-
rspec-mocks (3.
|
67
|
+
rspec-support (~> 3.11.0)
|
68
|
+
rspec-mocks (3.11.0)
|
104
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
105
|
-
rspec-support (~> 3.
|
106
|
-
rspec-support (3.
|
70
|
+
rspec-support (~> 3.11.0)
|
71
|
+
rspec-support (3.11.0)
|
107
72
|
rubocop (0.93.1)
|
108
73
|
parallel (~> 1.10)
|
109
74
|
parser (>= 2.7.1.5)
|
@@ -113,34 +78,32 @@ GEM
|
|
113
78
|
rubocop-ast (>= 0.6.0)
|
114
79
|
ruby-progressbar (~> 1.7)
|
115
80
|
unicode-display_width (>= 1.4.0, < 2.0)
|
116
|
-
rubocop-ast (1.
|
117
|
-
parser (>=
|
81
|
+
rubocop-ast (1.4.1)
|
82
|
+
parser (>= 2.7.1.5)
|
118
83
|
ruby-progressbar (1.11.0)
|
119
|
-
sequel (5.
|
120
|
-
simplecov (0.
|
84
|
+
sequel (5.53.0)
|
85
|
+
simplecov (0.18.5)
|
121
86
|
docile (~> 1.1)
|
122
87
|
simplecov-html (~> 0.11)
|
123
|
-
simplecov_json_formatter (~> 0.1)
|
124
88
|
simplecov-html (0.12.3)
|
125
|
-
simplecov_json_formatter (0.1.3)
|
126
89
|
timecop (0.9.4)
|
127
|
-
unicode-display_width (1.
|
90
|
+
unicode-display_width (1.8.0)
|
128
91
|
webmock (3.7.6)
|
129
92
|
addressable (>= 2.3.6)
|
130
93
|
crack (>= 0.3.2)
|
131
94
|
hashdiff (>= 0.4.0, < 2.0.0)
|
132
|
-
|
95
|
+
webrick (1.7.0)
|
96
|
+
yard (0.9.27)
|
97
|
+
webrick (~> 1.7.0)
|
133
98
|
|
134
99
|
PLATFORMS
|
135
100
|
ruby
|
136
|
-
x86_64-linux
|
137
101
|
|
138
102
|
DEPENDENCIES
|
139
103
|
bundler (~> 1.17)
|
140
104
|
byebug (~> 11.1)
|
141
105
|
cyclone_lariat!
|
142
106
|
database_cleaner-sequel (~> 2.0)
|
143
|
-
dry-validation (~> 1.1)
|
144
107
|
pg (~> 1.2)
|
145
108
|
pry (~> 0.13)
|
146
109
|
pry-byebug (~> 3.9)
|
data/README.md
CHANGED
data/cyclone_lariat.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = 'Shoryuken middleware for LunaPark based application.'
|
14
14
|
spec.homepage = 'https://am-team.github.io/cyclone_lariat/#/'
|
15
15
|
spec.license = 'MIT'
|
16
|
-
spec.required_ruby_version = '>= 2.
|
16
|
+
spec.required_ruby_version = '>= 2.4.0'
|
17
17
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -39,7 +39,6 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
40
40
|
spec.add_development_dependency 'byebug', '~> 11.1'
|
41
41
|
spec.add_development_dependency 'database_cleaner-sequel', '~> 2.0'
|
42
|
-
spec.add_development_dependency 'dry-validation', '~> 1.1'
|
43
42
|
spec.add_development_dependency 'pg', '~> 1.2'
|
44
43
|
spec.add_development_dependency 'pry', '~> 0.13'
|
45
44
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
@@ -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
|
@@ -12,18 +12,17 @@ module CycloneLariat
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_row(input)
|
15
|
-
|
16
|
-
uuid:
|
17
|
-
kind:
|
18
|
-
type:
|
19
|
-
publisher:
|
20
|
-
data:
|
21
|
-
client_error_message:
|
22
|
-
client_error_details:
|
23
|
-
version:
|
24
|
-
sent_at:
|
15
|
+
{
|
16
|
+
uuid: input.uuid,
|
17
|
+
kind: input.kind,
|
18
|
+
type: input.type,
|
19
|
+
publisher: input.publisher,
|
20
|
+
data: JSON.generate(input.data),
|
21
|
+
client_error_message: input.client_error&.message,
|
22
|
+
client_error_details: JSON.generate(input.client_error&.details),
|
23
|
+
version: input.version,
|
24
|
+
sent_at: input.sent_at
|
25
25
|
}
|
26
|
-
row
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
@@ -45,5 +44,3 @@ module CycloneLariat
|
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
48
|
-
|
49
|
-
|
@@ -13,9 +13,10 @@ module CycloneLariat
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(_worker_instance, queue, _sqs_msg, body, &block)
|
16
|
-
msg = receive_message(body)
|
16
|
+
msg = receive_message!(body)
|
17
17
|
|
18
18
|
message_notifier&.info 'Receive message', message: msg, queue: queue
|
19
|
+
return if msg.is_a? String
|
19
20
|
|
20
21
|
catch_standard_error(queue, msg) do
|
21
22
|
event = Event.wrap(msg)
|
@@ -30,8 +31,11 @@ module CycloneLariat
|
|
30
31
|
|
31
32
|
attr_reader :errors_notifier, :message_notifier, :events_repo
|
32
33
|
|
33
|
-
def receive_message(body)
|
34
|
-
body[:Message] ? JSON.parse(body[:Message], symbolize_names: true
|
34
|
+
def receive_message!(body)
|
35
|
+
body[:Message] ? JSON.parse(body[:Message], symbolize_names: true) : body
|
36
|
+
rescue JSON::ParserError => e
|
37
|
+
errors_notifier&.error(e, message: body[:Message])
|
38
|
+
body[:Message]
|
35
39
|
end
|
36
40
|
|
37
41
|
def store_in_dataset(event)
|
@@ -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:
|
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
|
@@ -95,20 +95,6 @@ dependencies:
|
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '2.0'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: dry-validation
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - "~>"
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: '1.1'
|
105
|
-
type: :development
|
106
|
-
prerelease: false
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
108
|
-
requirements:
|
109
|
-
- - "~>"
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '1.1'
|
112
98
|
- !ruby/object:Gem::Dependency
|
113
99
|
name: pg
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,6 +271,7 @@ files:
|
|
285
271
|
- lib/cyclone_lariat/command.rb
|
286
272
|
- lib/cyclone_lariat/errors.rb
|
287
273
|
- lib/cyclone_lariat/event.rb
|
274
|
+
- lib/cyclone_lariat/list_topics_store.rb
|
288
275
|
- lib/cyclone_lariat/messages_mapper.rb
|
289
276
|
- lib/cyclone_lariat/messages_repo.rb
|
290
277
|
- lib/cyclone_lariat/middleware.rb
|
@@ -305,7 +292,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
292
|
requirements:
|
306
293
|
- - ">="
|
307
294
|
- !ruby/object:Gem::Version
|
308
|
-
version: 2.
|
295
|
+
version: 2.4.0
|
309
296
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
310
297
|
requirements:
|
311
298
|
- - ">="
|