rising_dragon 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +5 -9
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/lib/rising_dragon.rb +10 -10
- data/lib/rising_dragon/event.rb +6 -1
- data/lib/rising_dragon/sns/publisher.rb +1 -1
- data/lib/rising_dragon/sqs/emitter.rb +9 -9
- data/lib/rising_dragon/sqs/worker.rb +7 -7
- data/lib/rising_dragon/version.rb +1 -1
- data/rising_dragon.gemspec +22 -25
- metadata +28 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb5dc5654759f81fba65dc418831a23d1ecc4ceb73db69ca8fef62f72b3c557c
|
4
|
+
data.tar.gz: 7e6eeee3233eb3beb3ceee64d5c7715e79f38486d8e92cb7aea634e0149805f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efdfb06d72a98f0ff4199b28336af0f111d5af155e62a4250beb990226f0d05676080ec12a95e91afc579e6ecac8745011446f3458782a1545bd41cbef3db716
|
7
|
+
data.tar.gz: 278d17f1fad7a5174c4f946e013bd9155e23d6a758e6c71ce146e985a97dbb94ba91a777376307b369eacd03c2459266dd327d2de61f62e27e44440839ebd81d
|
data/.rubocop.yml
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
inherit_gem:
|
2
|
-
|
3
|
-
- 'config/
|
2
|
+
fincop:
|
3
|
+
- 'config/rails.yml'
|
4
4
|
- 'config/rspec.yml'
|
5
|
+
- 'config/rubocop.yml'
|
5
6
|
|
6
7
|
AllCops:
|
7
|
-
TargetRubyVersion: 2.
|
8
|
-
DisplayStyleGuide: true
|
8
|
+
TargetRubyVersion: 2.5
|
9
9
|
|
10
|
-
|
11
|
-
Max: 100
|
12
|
-
|
13
|
-
RSpec/MultipleExpectations:
|
14
|
-
Max: 30
|
10
|
+
DisplayStyleGuide: true
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rising_dragon'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "rising_dragon"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/lib/rising_dragon.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'json'
|
2
|
+
require 'securerandom'
|
3
3
|
|
4
|
-
require
|
4
|
+
require 'shoryuken'
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
6
|
+
require 'rising_dragon/version'
|
7
|
+
require 'rising_dragon/event'
|
8
|
+
require 'rising_dragon/error'
|
9
|
+
require 'rising_dragon/sns/publisher'
|
10
|
+
require 'rising_dragon/sqs/emitter'
|
11
|
+
require 'rising_dragon/sqs/handler'
|
12
|
+
require 'rising_dragon/sqs/worker'
|
13
13
|
|
14
14
|
module RisingDragon
|
15
15
|
extend SingleForwardable
|
data/lib/rising_dragon/event.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module RisingDragon
|
2
2
|
class Event
|
3
3
|
attr_reader :id, :type, :timestamp, :data
|
4
|
-
def initialize(id:, type:, timestamp:, data:)
|
4
|
+
def initialize(id:, type:, timestamp:, data:, sqs_msg:)
|
5
5
|
@id = id
|
6
6
|
@type = type
|
7
7
|
@timestamp = timestamp
|
8
8
|
@data = data
|
9
|
+
@sqs_msg = sqs_msg
|
9
10
|
end
|
10
11
|
|
11
12
|
def to_json(*option)
|
@@ -16,5 +17,9 @@ module RisingDragon
|
|
16
17
|
data: @data,
|
17
18
|
}.to_json(*option)
|
18
19
|
end
|
20
|
+
|
21
|
+
def delete!
|
22
|
+
@sqs_msg.delete
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
@@ -18,7 +18,7 @@ module RisingDragon
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def create_event(type, data)
|
21
|
-
::RisingDragon::Event.new(id: uuid, timestamp: unixtime, type: type, data: data)
|
21
|
+
::RisingDragon::Event.new(id: uuid, timestamp: unixtime, type: type, data: data, sqs_msg: nil)
|
22
22
|
end
|
23
23
|
|
24
24
|
def uuid
|
@@ -44,19 +44,19 @@ module RisingDragon
|
|
44
44
|
nil
|
45
45
|
end
|
46
46
|
|
47
|
-
def event_from_json(body)
|
48
|
-
msg = JSON.parse(body[
|
47
|
+
def event_from_json(sqs_msg, body)
|
48
|
+
msg = JSON.parse(body['Message'])
|
49
49
|
|
50
|
-
id = msg[
|
51
|
-
type = msg[
|
52
|
-
timestamp = Time.at(msg[
|
53
|
-
data = msg[
|
50
|
+
id = msg['id']
|
51
|
+
type = msg['type']
|
52
|
+
timestamp = Time.at(msg['timestamp'] / 1000.0)
|
53
|
+
data = msg['data']
|
54
54
|
|
55
|
-
::RisingDragon::Event.new(id: id, type: type, timestamp: timestamp, data: data)
|
55
|
+
::RisingDragon::Event.new(id: id, type: type, timestamp: timestamp, data: data, sqs_msg: sqs_msg)
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
event = event_from_json(body)
|
58
|
+
def emit_sqs_msg(sqs_msg, body)
|
59
|
+
event = event_from_json(sqs_msg, body)
|
60
60
|
emit_event(event)
|
61
61
|
end
|
62
62
|
end
|
@@ -10,17 +10,17 @@ module RisingDragon
|
|
10
10
|
|
11
11
|
module ClassMethods
|
12
12
|
def rising_dragon_options(sqs_queue_name, opt = {})
|
13
|
-
shoryuken_opt = { queue: sqs_queue_name, body_parser: :json, auto_delete: true, shoryuken_group:
|
13
|
+
shoryuken_opt = { queue: sqs_queue_name, body_parser: :json, auto_delete: true, shoryuken_group: 'default' }.merge(opt)
|
14
14
|
shoryuken_options(shoryuken_opt)
|
15
15
|
|
16
|
-
register_queue(sqs_queue_name, shoryuken_opt[
|
16
|
+
register_queue(sqs_queue_name, shoryuken_opt['shoryuken_group'], opt) # shoryuken_options will change hash key.... :(
|
17
17
|
end
|
18
18
|
|
19
19
|
def register_queue(sqs_queue_name, group_name, option)
|
20
|
-
concurrency = option[
|
20
|
+
concurrency = option['concurrency'] || 25
|
21
21
|
Shoryuken.add_group(group_name, concurrency)
|
22
22
|
|
23
|
-
weight = option[
|
23
|
+
weight = option['weight'] || 1
|
24
24
|
Shoryuken.add_queue(sqs_queue_name, weight, group_name)
|
25
25
|
end
|
26
26
|
|
@@ -37,9 +37,9 @@ module RisingDragon
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def perform(
|
41
|
-
self.class.emitter.
|
42
|
-
rescue => e
|
40
|
+
def perform(sqs_msg, body)
|
41
|
+
self.class.emitter.emit_sqs_msg(sqs_msg, body)
|
42
|
+
rescue StandardError => e
|
43
43
|
rescue_from(e)
|
44
44
|
end
|
45
45
|
|
data/rising_dragon.gemspec
CHANGED
@@ -1,44 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
3
|
+
require 'rising_dragon/version'
|
6
4
|
|
7
5
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
6
|
+
spec.name = 'rising_dragon'
|
9
7
|
spec.version = RisingDragon::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
8
|
+
spec.authors = ['ota42y']
|
9
|
+
spec.email = ['ota42y@gmail.com']
|
12
10
|
|
13
|
-
spec.summary =
|
14
|
-
spec.homepage =
|
15
|
-
spec.description =
|
16
|
-
spec.license =
|
11
|
+
spec.summary = 'Event driven architecture library for AWS SNS/SQS'
|
12
|
+
spec.homepage = 'https://github.com/ota42y/rising_dragon'
|
13
|
+
spec.description = 'Event driven architecture library for AWS SNS/SQS include SQS worker and SNS publisher'
|
14
|
+
spec.license = 'MIT'
|
17
15
|
|
18
16
|
if spec.respond_to?(:metadata)
|
19
17
|
# allow push to any host
|
20
18
|
else
|
21
|
-
raise
|
22
|
-
|
19
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
20
|
+
'public gem pushes.'
|
23
21
|
end
|
24
22
|
|
25
23
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
24
|
f.match(%r{^(test|spec|features)/})
|
27
25
|
end
|
28
|
-
spec.bindir =
|
26
|
+
spec.bindir = 'exe'
|
29
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = [
|
28
|
+
spec.require_paths = ['lib']
|
31
29
|
|
32
|
-
spec.add_dependency
|
30
|
+
spec.add_dependency 'shoryuken', '>= 3.1.7'
|
33
31
|
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
33
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
37
35
|
|
38
|
-
spec.add_development_dependency
|
39
|
-
spec.add_development_dependency
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency "aws-sdk-sqs"
|
36
|
+
spec.add_development_dependency 'aws-sdk-core', '>= 3'
|
37
|
+
spec.add_development_dependency 'aws-sdk-sqs'
|
38
|
+
spec.add_development_dependency 'fincop', '>= 0.52.1.0'
|
39
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
40
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
44
41
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rising_dragon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoryuken
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.1.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.1.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -67,89 +67,75 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: aws-sdk-core
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: aws-sdk-sqs
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: fincop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.52.1.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.52.1.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry
|
112
|
+
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '0.10'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: aws-sdk-core
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '3'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '3'
|
124
|
+
version: '0.10'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: pry-byebug
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
|
-
- - "
|
129
|
+
- - "~>"
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
131
|
+
version: '3.4'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
|
-
- - "
|
136
|
+
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
138
|
+
version: '3.4'
|
153
139
|
description: Event driven architecture library for AWS SNS/SQS include SQS worker
|
154
140
|
and SNS publisher
|
155
141
|
email:
|
@@ -198,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
184
|
version: '0'
|
199
185
|
requirements: []
|
200
186
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.7.5
|
202
188
|
signing_key:
|
203
189
|
specification_version: 4
|
204
190
|
summary: Event driven architecture library for AWS SNS/SQS
|