qrpc 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 0.4.0
3
+ * #precall and #postcall handler support on API object
4
+ * missing default value for options in Server#start_listening
5
+ * in some responses ID isn't available, but tried to be converted to
6
+ the symbol
7
+
2
8
  0.3.2 (2011-08-28)
3
9
  * UUID of the client now generated in compact format
4
10
  * compatiblity corrections with OkJson
@@ -7,8 +13,7 @@
7
13
  * UUID of the jobs now generated in compact format
8
14
 
9
15
  0.3.0 (2011-02-27)
10
- * bad json-rpc-object dependency (but noncritical, some special cases
11
- performance lag only)
16
+ * invalid json-rpc-object dependency
12
17
  * all public methods from Client moved to Client::Dispatcher
13
18
 
14
19
  0.2.2 (2011-02-13)
data/Gemfile CHANGED
@@ -11,5 +11,5 @@ source "http://rubygems.org"
11
11
  # Include everything needed to run rake, tests, features, etc.
12
12
  group :development do
13
13
  gem "bundler", ">= 1.0.0"
14
- gem "jeweler", ">= 1.5.2"
14
+ gem "jeweler2", ">= 2.0.0"
15
15
  end
data/Gemfile.lock CHANGED
@@ -3,27 +3,28 @@ GEM
3
3
  specs:
4
4
  abstract (1.0.0)
5
5
  addressable (2.2.6)
6
- depq (0.4)
7
- em-jack (0.1.3)
8
- eventmachine
9
- eventmachine (1.0.0.beta.3)
6
+ depq (0.6)
7
+ em-jack (0.1.5)
8
+ eventmachine (>= 0.12.10)
9
+ eventmachine (1.0.0.beta.4)
10
10
  git (1.2.5)
11
- hash-utils (0.18.1)
12
- jeweler (1.6.4)
13
- bundler (~> 1.0)
11
+ hash-utils (1.1.0)
12
+ ruby-version
13
+ jeweler2 (2.0.9)
14
14
  git (>= 1.2.5)
15
- rake
16
- json-rpc-objects (0.4.2)
15
+ json-rpc-objects (0.4.3)
17
16
  abstract (>= 1.0.0)
18
17
  addressable (>= 2.2.2)
19
18
  hash-utils (>= 0.18.0)
19
+ json-rpc-objects-json (>= 0.1.1)
20
+ json-rpc-objects-json (0.1.1)
20
21
  multi_json
21
- macaddr (1.4.0)
22
- systemu (~> 2.2.0)
23
- multi_json (1.0.3)
24
- rake (0.9.2)
25
- systemu (2.2.0)
26
- uuid (2.3.3)
22
+ macaddr (1.5.0)
23
+ systemu (>= 2.4.0)
24
+ multi_json (1.0.4)
25
+ ruby-version (0.3.1)
26
+ systemu (2.4.2)
27
+ uuid (2.3.5)
27
28
  macaddr (~> 1.0)
28
29
 
29
30
  PLATFORMS
@@ -34,6 +35,6 @@ DEPENDENCIES
34
35
  depq (>= 0.4)
35
36
  em-jack (>= 0.1.3)
36
37
  eventmachine
37
- jeweler (>= 1.5.2)
38
+ jeweler2 (>= 2.0.0)
38
39
  json-rpc-objects (>= 0.3.3)
39
40
  uuid (>= 2.3.2)
data/README.md CHANGED
@@ -74,6 +74,7 @@ Both `backtrace` and `dump` members are optional.
74
74
  Usage is simple. Look example:
75
75
 
76
76
  require "qrpc/server"
77
+ require "qrpc/locator"
77
78
 
78
79
  class Foo
79
80
  def subtract(x, y)
@@ -96,6 +97,10 @@ similar to fibers. Default number at one time processed jobs is 20,
96
97
  but it can be changed by setting `:max_jobs => <number>` to `#listen!`
97
98
  or `#start_listening`.
98
99
 
100
+ The `#precall` and `#postcall` handlers are supported on the API class
101
+ called if API responds to them. Currently, they don't receive any
102
+ parameters and are intended for simple call initialization only.
103
+
99
104
  Reponse will be put to the same queue server, to queue named
100
105
  `qrpc-<client identifier>-output`, with structure described above.
101
106
 
@@ -105,6 +110,7 @@ Client usage is simple too. Look example:
105
110
 
106
111
  require "eventmachine"
107
112
  require "qrpc/client"
113
+ require "qrpc/locator"
108
114
 
109
115
  EM::run do
110
116
  client = QRPC::Client::new QRPC::Locator::new "test"
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
 
13
13
  require 'rake'
14
- require 'jeweler'
14
+ require 'jeweler2'
15
15
 
16
16
  Jeweler::Tasks.new do |gem|
17
17
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.4.0
@@ -165,11 +165,13 @@ module QRPC
165
165
  # Results processing logic
166
166
  processor = Proc::new do |job|
167
167
  response = JsonRpcObjects::Response::parse(job.body)
168
- id = response.id.to_sym
169
168
  job.delete()
170
169
 
171
- if @jobs.include? id
172
- @jobs[id].assign_result(response)
170
+ if not response.id.nil?
171
+ id = response.id.to_sym
172
+ if @jobs.include? id
173
+ @jobs[id].assign_result(response)
174
+ end
173
175
  end
174
176
 
175
177
  @jobs.delete(id)
data/lib/qrpc/server.rb CHANGED
@@ -169,7 +169,7 @@ module QRPC
169
169
  # @param [Hash] opts options for the server
170
170
  #
171
171
 
172
- def start_listening(locator, opts)
172
+ def start_listening(locator, opts = { })
173
173
  @locator = locator
174
174
  @dispatcher = QRPC::Server::Dispatcher::new(opts[:max_jobs])
175
175
 
@@ -69,7 +69,9 @@ module QRPC
69
69
  request = self.request
70
70
 
71
71
  begin
72
+ @api.precall if @api.respond_to? :precall
72
73
  result = @api.send(request.method, *request.params)
74
+ @api.postcall if @api.respond_to? :postcall
73
75
  rescue ::Exception => e
74
76
  error = self.generate_error(request, e)
75
77
  end
data/qrpc.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "qrpc"
8
- s.version = "0.3.2"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Koz\u{e1}k"]
12
- s.date = "2011-08-28"
12
+ s.date = "2012-02-19"
13
13
  s.email = "martinkozak@martinkozak.net"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.homepage = "http://github.com/martinkozak/qrpc"
45
45
  s.licenses = ["MIT"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = "1.8.10"
47
+ s.rubygems_version = "1.8.17"
48
48
  s.summary = "Queued JSON-RPC client and server. Works as normal RPC server, but through queue interface, so allows highly scalable, distributed and asynchronous remote API implementation and fast data processing. It's based on eventmachine and beanstalkd, so it's fast and thread safe."
49
49
 
50
50
  if s.respond_to? :specification_version then
@@ -57,7 +57,7 @@ Gem::Specification.new do |s|
57
57
  s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
58
58
  s.add_runtime_dependency(%q<uuid>, [">= 2.3.2"])
59
59
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
60
- s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
60
+ s.add_development_dependency(%q<jeweler2>, [">= 2.0.0"])
61
61
  else
62
62
  s.add_dependency(%q<json-rpc-objects>, [">= 0.3.3"])
63
63
  s.add_dependency(%q<depq>, [">= 0.4"])
@@ -65,7 +65,7 @@ Gem::Specification.new do |s|
65
65
  s.add_dependency(%q<eventmachine>, [">= 0"])
66
66
  s.add_dependency(%q<uuid>, [">= 2.3.2"])
67
67
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
68
- s.add_dependency(%q<jeweler>, [">= 1.5.2"])
68
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
69
69
  end
70
70
  else
71
71
  s.add_dependency(%q<json-rpc-objects>, [">= 0.3.3"])
@@ -74,7 +74,7 @@ Gem::Specification.new do |s|
74
74
  s.add_dependency(%q<eventmachine>, [">= 0"])
75
75
  s.add_dependency(%q<uuid>, [">= 2.3.2"])
76
76
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
77
- s.add_dependency(%q<jeweler>, [">= 1.5.2"])
77
+ s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
78
78
  end
79
79
  end
80
80
 
data/test-server.rb CHANGED
@@ -4,9 +4,18 @@ require "rubygems"
4
4
  $:.push("./lib")
5
5
 
6
6
  class Foo
7
+ def precall
8
+ puts "precall"
9
+ end
10
+
7
11
  def subtract(x, y)
12
+ puts "call"
8
13
  x - y
9
14
  end
15
+
16
+ def postcall
17
+ puts "postcall"
18
+ end
10
19
  end
11
20
 
12
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-28 00:00:00.000000000 Z
12
+ date: 2012-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json-rpc-objects
16
- requirement: &26326300 !ruby/object:Gem::Requirement
16
+ requirement: &19394600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *26326300
24
+ version_requirements: *19394600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: depq
27
- requirement: &26325280 !ruby/object:Gem::Requirement
27
+ requirement: &19392680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.4'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *26325280
35
+ version_requirements: *19392680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-jack
38
- requirement: &26324140 !ruby/object:Gem::Requirement
38
+ requirement: &19391280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.1.3
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *26324140
46
+ version_requirements: *19391280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eventmachine
49
- requirement: &26321580 !ruby/object:Gem::Requirement
49
+ requirement: &19389520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *26321580
57
+ version_requirements: *19389520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: uuid
60
- requirement: &26320640 !ruby/object:Gem::Requirement
60
+ requirement: &19407260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.3.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *26320640
68
+ version_requirements: *19407260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &26319580 !ruby/object:Gem::Requirement
71
+ requirement: &19406280 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,18 +76,18 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *26319580
79
+ version_requirements: *19406280
80
80
  - !ruby/object:Gem::Dependency
81
- name: jeweler
82
- requirement: &26318540 !ruby/object:Gem::Requirement
81
+ name: jeweler2
82
+ requirement: &19405460 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
86
86
  - !ruby/object:Gem::Version
87
- version: 1.5.2
87
+ version: 2.0.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *26318540
90
+ version_requirements: *19405460
91
91
  description:
92
92
  email: martinkozak@martinkozak.net
93
93
  executables: []
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: -2316095507865135214
138
+ hash: -3804582272102704456
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 1.8.10
147
+ rubygems_version: 1.8.17
148
148
  signing_key:
149
149
  specification_version: 3
150
150
  summary: Queued JSON-RPC client and server. Works as normal RPC server, but through