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 +7 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +17 -16
- data/README.md +6 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/qrpc/client/dispatcher.rb +5 -3
- data/lib/qrpc/server.rb +1 -1
- data/lib/qrpc/server/job.rb +2 -0
- data/qrpc.gemspec +6 -6
- data/test-server.rb +9 -0
- metadata +20 -20
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
|
-
*
|
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
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.
|
7
|
-
em-jack (0.1.
|
8
|
-
eventmachine
|
9
|
-
eventmachine (1.0.0.beta.
|
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 (
|
12
|
-
|
13
|
-
|
11
|
+
hash-utils (1.1.0)
|
12
|
+
ruby-version
|
13
|
+
jeweler2 (2.0.9)
|
14
14
|
git (>= 1.2.5)
|
15
|
-
|
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.
|
22
|
-
systemu (
|
23
|
-
multi_json (1.0.
|
24
|
-
|
25
|
-
systemu (2.2
|
26
|
-
uuid (2.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
|
-
|
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
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
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
|
172
|
-
|
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
data/lib/qrpc/server/job.rb
CHANGED
@@ -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.
|
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 = "
|
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.
|
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<
|
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<
|
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<
|
77
|
+
s.add_dependency(%q<jeweler2>, [">= 2.0.0"])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
data/test-server.rb
CHANGED
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.
|
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:
|
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: &
|
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: *
|
24
|
+
version_requirements: *19394600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: depq
|
27
|
-
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: *
|
35
|
+
version_requirements: *19392680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-jack
|
38
|
-
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: *
|
46
|
+
version_requirements: *19391280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: eventmachine
|
49
|
-
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: *
|
57
|
+
version_requirements: *19389520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: uuid
|
60
|
-
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: *
|
68
|
+
version_requirements: *19407260
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
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: *
|
79
|
+
version_requirements: *19406280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
-
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:
|
87
|
+
version: 2.0.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
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: -
|
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.
|
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
|