rodent 0.0.4 → 0.0.6

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
2
  SHA1:
3
- metadata.gz: 9c5f5acd62d35708b4c479376ee213fce72db021
4
- data.tar.gz: f5a167799d4f338b0f710bc9b37e0938b0c2218a
3
+ metadata.gz: e4ce06ed64e117b8ffdf7bc7b255a5d16c9aa1d3
4
+ data.tar.gz: f2ed601b95b431f707586557f60a9cf7a72a266e
5
5
  SHA512:
6
- metadata.gz: 1835d65838471df32ea85c56ed15f6cc0fe0bfa2a5ae9aa466179fb829e20f0f33a06faf4b6a64e5be7c7480e305b4db492e4974578978d7e346ceb5dcc67d1f
7
- data.tar.gz: dd91fa08ee77cc2196cb8cac75c4dfaa1534e6b8477f273fee6490577dc0b94e33bc3a4f4c3a091fc671da6eda09d34167f7c82351979acbef896d77e0abe724
6
+ metadata.gz: e18301edb739bfbfd08572986d6e81048ed191e207a76b869f64a7bd11452029deb7746a187abe62d37b51309a86c593f93e06050e40d5db2ad82995550d0020
7
+ data.tar.gz: a3815b902fc5f27ef7a6474a8da266e0814c5929f6e77b69e439d3632e9eb41121f0f236d59441f19080baddce93cc95c614b2d48924efbd261a9f732886b814
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ log/*.log
3
3
  *.gem
4
4
  .yardoc/
5
5
  doc/
6
+ .bundle/
data/README.md CHANGED
@@ -154,3 +154,7 @@ Total: 51 120 40.7 117 235
154
154
  ## License & Acknowledgments
155
155
 
156
156
  Rodent is distributed under the MIT license, for full details please see the LICENSE file.
157
+
158
+
159
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kkdoo/rodent/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
160
+
data/lib/rodent/base.rb CHANGED
@@ -2,6 +2,7 @@ module Rodent
2
2
  class Base
3
3
  class << self
4
4
  attr_reader :listeners, :instance
5
+ attr_accessor :error_handler
5
6
 
6
7
  def listeners
7
8
  @listeners ||= []
@@ -19,7 +20,9 @@ module Rodent
19
20
  end
20
21
 
21
22
  def bind
22
- listeners.each(&:bind)
23
+ listeners.each do |listener|
24
+ listener.bind(error_handler)
25
+ end
23
26
  end
24
27
  end
25
28
  end
@@ -51,7 +51,7 @@ module Rodent
51
51
  consumer.consume do
52
52
  consumer.on_delivery do |metadata, payload|
53
53
  response = MultiJson.load(payload)
54
- response['headers']['Content-Length'] = response['body'].length.to_s
54
+ response['headers']['Content-Length'] = response['body'].to_s.bytes.count.to_s
55
55
  response['headers']['Content-Type'] = 'application/json'
56
56
  async_callback.call([response['status'], headers.merge(response['headers']), response['body']])
57
57
  metadata.ack
@@ -12,13 +12,17 @@ module Rodent
12
12
  @source = block
13
13
  end
14
14
 
15
- def bind
15
+ def bind(error_handler)
16
16
  AMQP::Channel.new do |channel|
17
17
  channel.prefetch(100)
18
18
  queue = channel.queue(@type, exclusive: true, auto_delete: true)
19
19
  queue.bind(channel.direct('rodent.requests'), routing_key: @type)
20
20
  queue.subscribe(ack: true) do |metadata, payload|
21
- self.body = call(MultiJson.load(payload))
21
+ begin
22
+ self.body = call(MultiJson.load(payload))
23
+ rescue Exception => e
24
+ self.status, self.headers, self.body = error_handler.call(e) if error_handler
25
+ end
22
26
  channel.default_exchange.publish(MultiJson.dump(response), routing_key: metadata.reply_to, correlation_id: metadata.message_id)
23
27
  metadata.ack
24
28
  end
@@ -1,8 +1,10 @@
1
+ require 'multi_json'
2
+
1
3
  module Rodent
2
4
  module Test
3
5
  module Helpers
4
6
  def request(path, *args)
5
- @rodent_response = api.route(path).call(*args)
7
+ @rodent_response = MultiJson.load(api.route(path).call(*args))
6
8
  end
7
9
 
8
10
  def response
@@ -1,3 +1,3 @@
1
1
  module Rodent
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.6'
3
3
  end
data/rodent.gemspec CHANGED
@@ -10,26 +10,26 @@ Gem::Specification.new do |s|
10
10
  s.email = ['artem.maschenko@gmail.com']
11
11
  s.homepage = 'https://github.com/kkdoo/rodent'
12
12
  s.summary = 'Framework for micro services'
13
- s.description = s.summary
13
+ s.description = 'Rodent is an open source asynchronous framework for Micro Service Architecture (MSA). It is a lightweight and designed to easily develop APIs. Main goals is scaling, simplicity and perfomance.'
14
14
  s.license = 'MIT'
15
15
 
16
16
  s.rubyforge_project = 'rodent'
17
17
 
18
18
  s.required_ruby_version = '>=1.9.2'
19
19
 
20
- s.add_dependency 'multi_json'
21
- s.add_dependency 'goliath'
22
- s.add_dependency 'amqp'
23
- s.add_dependency 'em-synchrony'
24
- s.add_dependency 'bson_ext'
20
+ s.add_runtime_dependency 'multi_json', '~> 1.8.4'
21
+ s.add_runtime_dependency 'goliath', '~> 1.0.3'
22
+ s.add_runtime_dependency 'amqp', '~> 1.2.1'
23
+ s.add_runtime_dependency 'em-synchrony', '~> 1.0.3'
24
+ s.add_runtime_dependency 'bson_ext', '~> 1.9.2'
25
25
 
26
- s.add_development_dependency 'rake'
27
- s.add_development_dependency 'rspec'
28
- s.add_development_dependency 'em-http-request'
29
- s.add_development_dependency 'rack-test'
30
- s.add_development_dependency 'evented-spec'
31
- s.add_development_dependency 'redcarpet'
32
- s.add_development_dependency 'yard'
26
+ s.add_development_dependency 'rake', '~> 0'
27
+ s.add_development_dependency 'rspec', '~> 2.14.1'
28
+ s.add_development_dependency 'em-http-request', '~> 1.1.1'
29
+ s.add_development_dependency 'rack-test', '~> 0.6.2'
30
+ s.add_development_dependency 'evented-spec', '~> 0'
31
+ s.add_development_dependency 'redcarpet', '~> 3.0.0'
32
+ s.add_development_dependency 'yard', '~> 0.8.7.3'
33
33
 
34
34
  s.files = `git ls-files`.split("\n")
35
35
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,194 +1,196 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Maschenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-08 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.8.4
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
- version: '0'
26
+ version: 1.8.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: goliath
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: amqp
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.2.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.2.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: em-synchrony
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.0.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 1.0.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bson_ext
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 1.9.2
76
76
  type: :runtime
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'
82
+ version: 1.9.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
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
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 2.14.1
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'
110
+ version: 2.14.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: em-http-request
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 1.1.1
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: '0'
124
+ version: 1.1.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rack-test
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 0.6.2
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 0.6.2
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: evented-spec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: redcarpet
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0'
159
+ version: 3.0.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 3.0.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: yard
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: 0.8.7.3
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
181
- description: Framework for micro services
180
+ version: 0.8.7.3
181
+ description: Rodent is an open source asynchronous framework for Micro Service Architecture
182
+ (MSA). It is a lightweight and designed to easily develop APIs. Main goals is scaling,
183
+ simplicity and perfomance.
182
184
  email:
183
185
  - artem.maschenko@gmail.com
184
186
  executables: []
185
187
  extensions: []
186
188
  extra_rdoc_files: []
187
189
  files:
188
- - .gitignore
189
- - .rspec
190
- - .travis.yml
191
- - .yardopts
190
+ - ".gitignore"
191
+ - ".rspec"
192
+ - ".travis.yml"
193
+ - ".yardopts"
192
194
  - Gemfile
193
195
  - LICENSE
194
196
  - README.md
@@ -217,17 +219,17 @@ require_paths:
217
219
  - lib
218
220
  required_ruby_version: !ruby/object:Gem::Requirement
219
221
  requirements:
220
- - - '>='
222
+ - - ">="
221
223
  - !ruby/object:Gem::Version
222
224
  version: 1.9.2
223
225
  required_rubygems_version: !ruby/object:Gem::Requirement
224
226
  requirements:
225
- - - '>='
227
+ - - ">="
226
228
  - !ruby/object:Gem::Version
227
229
  version: '0'
228
230
  requirements: []
229
231
  rubyforge_project: rodent
230
- rubygems_version: 2.0.3
232
+ rubygems_version: 2.2.0
231
233
  signing_key:
232
234
  specification_version: 4
233
235
  summary: Framework for micro services