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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5c5d93d6e463303f924ecf079f76eb71d9a119b9
4
- data.tar.gz: d129eaa86cdc2cac07d6f57f7d8a87fe7e2f5479
2
+ SHA256:
3
+ metadata.gz: cb5dc5654759f81fba65dc418831a23d1ecc4ceb73db69ca8fef62f72b3c557c
4
+ data.tar.gz: 7e6eeee3233eb3beb3ceee64d5c7715e79f38486d8e92cb7aea634e0149805f4
5
5
  SHA512:
6
- metadata.gz: 4bc67eae15b2d2e78c97102bc64d1bf8642368c45548fe9f22eb76dfce5f34a9bc112af92cf9e29b752da7e3be4556e0e986ce9f8b3c3545f5ef7aa6331a5b5b
7
- data.tar.gz: 2f548e49ae67e1306a1876b42d0ea86a31410a02bc49f5e991d99532aed4fc328c1c69097453115e4a22ef76da3ced9de138788e4a5f9bc53d70b3e0aa32e350
6
+ metadata.gz: efdfb06d72a98f0ff4199b28336af0f111d5af155e62a4250beb990226f0d05676080ec12a95e91afc579e6ecac8745011446f3458782a1545bd41cbef3db716
7
+ data.tar.gz: 278d17f1fad7a5174c4f946e013bd9155e23d6a758e6c71ce146e985a97dbb94ba91a777376307b369eacd03c2459266dd327d2de61f62e27e44440839ebd81d
@@ -1,14 +1,10 @@
1
1
  inherit_gem:
2
- onkcop:
3
- - 'config/rubocop.yml'
2
+ fincop:
3
+ - 'config/rails.yml'
4
4
  - 'config/rspec.yml'
5
+ - 'config/rubocop.yml'
5
6
 
6
7
  AllCops:
7
- TargetRubyVersion: 2.4
8
- DisplayStyleGuide: true
8
+ TargetRubyVersion: 2.5
9
9
 
10
- RSpec/ExampleLength:
11
- Max: 100
12
-
13
- RSpec/MultipleExpectations:
14
- Max: 30
10
+ DisplayStyleGuide: true
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rising_dragon.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -13,7 +13,7 @@ Use AWS SQS/SNS as event worker for Microservices.
13
13
  Add this line to your application's Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'rising_dragon', '>= 0.3.4'
16
+ gem 'rising_dragon'
17
17
  ```
18
18
 
19
19
  And then execute:
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "rising_dragon"
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 "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,15 +1,15 @@
1
- require "json"
2
- require "securerandom"
1
+ require 'json'
2
+ require 'securerandom'
3
3
 
4
- require "shoryuken"
4
+ require 'shoryuken'
5
5
 
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"
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
@@ -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["Message"])
47
+ def event_from_json(sqs_msg, body)
48
+ msg = JSON.parse(body['Message'])
49
49
 
50
- id = msg["id"]
51
- type = msg["type"]
52
- timestamp = Time.at(msg["timestamp"] / 1000.0)
53
- data = msg["data"]
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 emit_sns_msg(body)
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: "default" }.merge(opt)
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["shoryuken_group"], opt) # shoryuken_options will change hash key.... :(
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["concurrency"] || 25
20
+ concurrency = option['concurrency'] || 25
21
21
  Shoryuken.add_group(group_name, concurrency)
22
22
 
23
- weight = option["weight"] || 1
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(_sqs_msg, body)
41
- self.class.emitter.emit_sns_msg(body)
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
 
@@ -1,3 +1,3 @@
1
1
  module RisingDragon
2
- VERSION = "0.3.4".freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -1,44 +1,41 @@
1
- # coding: utf-8
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 "rising_dragon/version"
3
+ require 'rising_dragon/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
- spec.name = "rising_dragon"
6
+ spec.name = 'rising_dragon'
9
7
  spec.version = RisingDragon::VERSION
10
- spec.authors = ["ota42y"]
11
- spec.email = ["ota42y@gmail.com"]
8
+ spec.authors = ['ota42y']
9
+ spec.email = ['ota42y@gmail.com']
12
10
 
13
- spec.summary = "Event driven architecture library for AWS SNS/SQS"
14
- spec.homepage = "https://github.com/ota42y/rising_dragon"
15
- spec.description = "Event driven architecture library for AWS SNS/SQS include SQS worker and SNS publisher"
16
- spec.license = "MIT"
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 "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
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 = "exe"
26
+ spec.bindir = 'exe'
29
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
28
+ spec.require_paths = ['lib']
31
29
 
32
- spec.add_dependency "shoryuken", "~> 3.1.7"
30
+ spec.add_dependency 'shoryuken', '>= 3.1.7'
33
31
 
34
- spec.add_development_dependency "bundler", "~> 1.14"
35
- spec.add_development_dependency "rake", "~> 12.0"
36
- spec.add_development_dependency "rspec", "~> 3"
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 "rubocop", "~> 0.49.1"
39
- spec.add_development_dependency "onkcop", "~> 0.49.1"
40
- spec.add_development_dependency "pry", "~> 0.10"
41
- spec.add_development_dependency "pry-byebug", "~> 3.4"
42
- spec.add_development_dependency "aws-sdk-core", ">= 3"
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.3.4
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: 2017-11-13 00:00:00.000000000 Z
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: rubocop
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: 0.49.1
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: 0.49.1
82
+ version: '3'
83
83
  - !ruby/object:Gem::Dependency
84
- name: onkcop
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.49.1
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.49.1
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry
98
+ name: fincop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0.10'
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: '0.10'
110
+ version: 0.52.1.0
111
111
  - !ruby/object:Gem::Dependency
112
- name: pry-byebug
112
+ name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.4'
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: '3.4'
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: aws-sdk-sqs
126
+ name: pry-byebug
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
- - - ">="
129
+ - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '0'
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: '0'
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.6.13
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