rcom 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -25
- data/lib/rcom/node.rb +0 -6
- data/lib/rcom/rpc.rb +34 -45
- data/lib/rcom/task.rb +4 -11
- data/lib/rcom/topic.rb +7 -11
- data/lib/rcom/version.rb +1 -1
- data/rcom.gemspec +0 -1
- data/test/spec/rpc_spec.rb +53 -21
- data/test/spec/task_spec.rb +17 -23
- data/test/spec/topic_spec.rb +21 -20
- metadata +2 -29
- data/test/bin/rpc_consumer.rb +0 -13
- data/test/bin/rpc_publisher.rb +0 -12
- data/test/bin/task_consumer.rb +0 -12
- data/test/bin/task_publisher.rb +0 -12
- data/test/bin/topic_publisher.rb +0 -13
- data/test/bin/topic_subscriber.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 961e69a1d381ea475b48b4e32d832cd2681d3f26
|
4
|
+
data.tar.gz: e2b0f139d952fd0cb9f18058f58362fa4c89f925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adbc997033ab5010d3ce09a0fadc1d47b0675e51a5fdde33df92b67a4a6d15a0452a2bff34e0c06cfd928373d1ec9e879bb5fd40bd3072bbd2a92b969fa6ef0c
|
7
|
+
data.tar.gz: 6c3768301c0079b53bf41fae0495f81222d38c9fcef354933b3ef2121082b43c8a6ef1cd972b6f0272466b33f579817655e42b9f215b6cbee1d2da853e997668
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ gem 'rcom'
|
|
18
18
|
|
19
19
|
## Usage.
|
20
20
|
|
21
|
-
Rcom supports the request-response, publish-subscribe and task
|
21
|
+
Rcom supports the request-response, publish-subscribe and task queue patterns for inter-service messaging. Publishers are non-blocking, subscribers/consumers are blocking and should be run as independent processes. Processes communicate using MessagePack internally.
|
22
22
|
|
23
23
|
### Node.
|
24
24
|
|
@@ -35,7 +35,7 @@ node = Rcom::Node.new('local').connect
|
|
35
35
|
|
36
36
|
### Topics.
|
37
37
|
|
38
|
-
One service might need to update many different services about an event, following the publish-subscribe pattern. You can publish and subscribe to topics on a node, specifying a
|
38
|
+
One service might need to update many different services about an event, following the publish-subscribe pattern. You can publish and subscribe to topics on a node, specifying a channel.
|
39
39
|
|
40
40
|
- Publisher.
|
41
41
|
|
@@ -46,7 +46,7 @@ message = {
|
|
46
46
|
}
|
47
47
|
|
48
48
|
node = Rcom::Node.new('local').connect
|
49
|
-
topic = Rcom::Topic.new(node: node,
|
49
|
+
topic = Rcom::Topic.new(node: node, channel: 'users')
|
50
50
|
|
51
51
|
topic.publish(message)
|
52
52
|
```
|
@@ -55,7 +55,7 @@ topic.publish(message)
|
|
55
55
|
|
56
56
|
```ruby
|
57
57
|
node = Rcom::Node.new('local').connect
|
58
|
-
topic = Rcom::Topic.new(node: node,
|
58
|
+
topic = Rcom::Topic.new(node: node, channel: 'users')
|
59
59
|
|
60
60
|
topic.subscribe do |message|
|
61
61
|
p message
|
@@ -64,7 +64,7 @@ end
|
|
64
64
|
|
65
65
|
## Tasks.
|
66
66
|
|
67
|
-
A service might need to push
|
67
|
+
A service might need to push consuming tasks into a queue and forget about them. Tasks will be processed by consumers listening to the queue.
|
68
68
|
|
69
69
|
- Publisher.
|
70
70
|
|
@@ -75,7 +75,7 @@ message = {
|
|
75
75
|
}
|
76
76
|
|
77
77
|
node = Rcom::Node.new('local').connect
|
78
|
-
messages = Rcom::Task.new(node: node,
|
78
|
+
messages = Rcom::Task.new(node: node, channel: 'messages')
|
79
79
|
|
80
80
|
messages.publish(message)
|
81
81
|
```
|
@@ -84,7 +84,7 @@ messages.publish(message)
|
|
84
84
|
|
85
85
|
```ruby
|
86
86
|
node = Rcom::Node.new('local').connect
|
87
|
-
messages = Rcom::Task.new(node: node,
|
87
|
+
messages = Rcom::Task.new(node: node, channel: 'messages')
|
88
88
|
|
89
89
|
messages.subscribe do |message|
|
90
90
|
sleep 1
|
@@ -94,37 +94,37 @@ end
|
|
94
94
|
|
95
95
|
## RPC, requests and responses.
|
96
96
|
|
97
|
-
In some cases services need real time informations from other services that can't be asynchronously processed. A service can
|
97
|
+
In some cases services need real time informations from other services that can't be asynchronously processed. A service can request informations on a channel. The other service listening on the same route will reply to the request.
|
98
98
|
|
99
|
-
-
|
99
|
+
- Request.
|
100
100
|
|
101
101
|
```ruby
|
102
|
-
message = {
|
103
|
-
route: 'user.key',
|
104
|
-
args: 1
|
105
|
-
}
|
106
|
-
|
107
102
|
node = Rcom::Node.new('local').connect
|
108
|
-
|
103
|
+
service = Rcom::Request.new(node: node, channel: 'auth')
|
109
104
|
|
110
|
-
|
105
|
+
service.get_key(user: 1)
|
111
106
|
```
|
112
107
|
|
113
|
-
-
|
108
|
+
- Response.
|
114
109
|
|
115
110
|
```ruby
|
116
111
|
node = Rcom::Node.new('local').connect
|
117
|
-
auth = Rcom::Rpc.new(node: node, service: 'auth')
|
118
112
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
request.on('user.password') do |params|
|
125
|
-
request.reply = 'not authorized'
|
113
|
+
class Server
|
114
|
+
def get_key(params)
|
115
|
+
user = params[:user]
|
116
|
+
return nil unless user == 1
|
117
|
+
return 'xxxccc'
|
126
118
|
end
|
127
119
|
end
|
120
|
+
|
121
|
+
service = Rcom::Response.new(
|
122
|
+
node: node,
|
123
|
+
channel: 'auth',
|
124
|
+
server: Server.new
|
125
|
+
)
|
126
|
+
|
127
|
+
service.serve
|
128
128
|
```
|
129
129
|
|
130
130
|
## Test.
|
data/lib/rcom/node.rb
CHANGED
@@ -1,18 +1,12 @@
|
|
1
1
|
module Rcom
|
2
|
-
# A node represents a Redis server and has an uri.
|
3
2
|
class Node
|
4
|
-
# @return [String]
|
5
3
|
attr_reader :uri
|
6
4
|
|
7
|
-
# @param uri [String] Example: 'local'
|
8
|
-
# @raise [ArgumentError] uri is not in .env.
|
9
5
|
def initialize(uri)
|
10
6
|
raise ArgumentError unless ENV[uri.upcase]
|
11
7
|
@uri = ENV[uri.upcase]
|
12
8
|
end
|
13
9
|
|
14
|
-
# Connects to Redis.
|
15
|
-
# @return [Redis]
|
16
10
|
def connect
|
17
11
|
Redis.new(url: uri)
|
18
12
|
end
|
data/lib/rcom/rpc.rb
CHANGED
@@ -1,79 +1,68 @@
|
|
1
1
|
module Rcom
|
2
|
-
|
3
|
-
|
4
|
-
# @return [Rcom::Node]
|
5
|
-
attr_reader :node
|
6
|
-
# @return [String]
|
7
|
-
attr_reader :service
|
2
|
+
class Request
|
3
|
+
attr_reader :node, :channel
|
8
4
|
|
9
|
-
# @param params [Hash]
|
10
|
-
# @option params :node [Rcom::Node] Example: Rcom::Node.new('local').connect
|
11
|
-
# @option params :service [String] Example: 'auth'
|
12
5
|
def initialize(params)
|
13
6
|
@node = params[:node]
|
14
|
-
@
|
7
|
+
@channel = params[:channel]
|
15
8
|
end
|
16
9
|
|
17
|
-
|
18
|
-
# @option params :route [String] Example: 'users.key'
|
19
|
-
# @option params :args Example: 1
|
20
|
-
# @return [reply, nil] Returns the reply or nil if the
|
21
|
-
# request can't be processed.
|
22
|
-
def request(params)
|
10
|
+
def method_missing(name, args)
|
23
11
|
begin
|
24
12
|
request = {
|
25
13
|
id: SecureRandom.hex,
|
26
|
-
|
27
|
-
args:
|
14
|
+
method: name,
|
15
|
+
args: args || ''
|
28
16
|
}
|
29
17
|
|
30
|
-
node.rpush(
|
18
|
+
node.rpush(channel, request.to_msgpack)
|
31
19
|
ch, response = node.brpop(request[:id], timeout=10)
|
32
20
|
|
33
|
-
MessagePack.unpack(
|
34
|
-
response,
|
35
|
-
symbolize_keys: true
|
36
|
-
)
|
21
|
+
MessagePack.unpack(response, symbolize_keys: true)
|
37
22
|
rescue
|
38
23
|
return nil
|
39
24
|
end
|
40
25
|
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Response
|
29
|
+
attr_reader :node, :channel, :server
|
41
30
|
|
42
|
-
|
43
|
-
|
44
|
-
|
31
|
+
def initialize(params)
|
32
|
+
@node = params[:node]
|
33
|
+
@channel = params[:channel]
|
34
|
+
@server = params[:server]
|
35
|
+
end
|
36
|
+
|
37
|
+
def serve
|
45
38
|
begin
|
46
39
|
loop do
|
47
|
-
ch, request = node.brpop(
|
40
|
+
ch, request = node.brpop(channel)
|
48
41
|
|
49
42
|
message = MessagePack.unpack(
|
50
43
|
request,
|
51
44
|
symbolize_keys: true
|
52
45
|
)
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
response = send_method(
|
47
|
+
message[:method],
|
48
|
+
message[:args]
|
49
|
+
)
|
56
50
|
|
57
|
-
node.rpush(message[:id],
|
51
|
+
node.rpush(message[:id], response.to_msgpack)
|
58
52
|
end
|
53
|
+
rescue
|
54
|
+
sleep 1
|
55
|
+
retry
|
59
56
|
rescue Interrupt => _
|
60
57
|
end
|
61
58
|
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# A router can match on a particular route.
|
65
|
-
class Router
|
66
|
-
attr_accessor :message, :reply
|
67
|
-
|
68
|
-
# @param message [Hash] The message received with the request.
|
69
|
-
def initialize(message)
|
70
|
-
@message = message
|
71
|
-
end
|
72
59
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
60
|
+
def send_method(method, args)
|
61
|
+
begin
|
62
|
+
server.send(method, args)
|
63
|
+
rescue
|
64
|
+
return nil
|
65
|
+
end
|
77
66
|
end
|
78
67
|
end
|
79
68
|
end
|
data/lib/rcom/task.rb
CHANGED
@@ -1,32 +1,25 @@
|
|
1
1
|
module Rcom
|
2
|
-
# Implements tasks and queues.
|
3
2
|
class Task
|
4
|
-
attr_reader :node, :
|
3
|
+
attr_reader :node, :channel
|
5
4
|
|
6
|
-
# @param params [Hash]
|
7
|
-
# @option params :node [Rcom::Node]
|
8
|
-
# @option params :queue [String] Example: 'messages'
|
9
5
|
def initialize(params)
|
10
6
|
@node = params[:node]
|
11
|
-
@
|
7
|
+
@channel = params[:channel]
|
12
8
|
end
|
13
9
|
|
14
|
-
# @param message [Hash]
|
15
|
-
# @return [true, nil] True if the message can be queued, otherwise nil.
|
16
10
|
def publish(message)
|
17
11
|
begin
|
18
|
-
node.lpush(
|
12
|
+
node.lpush(channel, message.to_msgpack)
|
19
13
|
return true
|
20
14
|
rescue
|
21
15
|
return nil
|
22
16
|
end
|
23
17
|
end
|
24
18
|
|
25
|
-
# @yieldparam message [Hash] the message received.
|
26
19
|
def subscribe
|
27
20
|
begin
|
28
21
|
loop do
|
29
|
-
ch, request = node.brpop(
|
22
|
+
ch, request = node.brpop(channel)
|
30
23
|
message = MessagePack.unpack(
|
31
24
|
request,
|
32
25
|
symbolize_keys: true
|
data/lib/rcom/topic.rb
CHANGED
@@ -1,31 +1,24 @@
|
|
1
1
|
module Rcom
|
2
|
-
# Implements pub/sub over topics.
|
3
2
|
class Topic
|
4
|
-
attr_reader :node, :
|
3
|
+
attr_reader :node, :channel
|
5
4
|
|
6
|
-
# @param params [Hash]
|
7
|
-
# @option params :node [Rcom::Node]
|
8
|
-
# @option params :key [String] Example: 'services'
|
9
5
|
def initialize(params)
|
10
6
|
@node = params[:node]
|
11
|
-
@key = params[:
|
7
|
+
@key = params[:channel]
|
12
8
|
end
|
13
9
|
|
14
|
-
# @param message [Hash]
|
15
|
-
# @return [true, nil] true if it can be published, otherwise nil.
|
16
10
|
def publish(message)
|
17
11
|
begin
|
18
|
-
node.publish(
|
12
|
+
node.publish(channel, message.to_msgpack)
|
19
13
|
return true
|
20
14
|
rescue
|
21
15
|
return nil
|
22
16
|
end
|
23
17
|
end
|
24
18
|
|
25
|
-
# @yieldparam message [Hash] the message received.
|
26
19
|
def subscribe
|
27
20
|
begin
|
28
|
-
node.subscribe(
|
21
|
+
node.subscribe(channel) do |on|
|
29
22
|
on.message do |channel, message|
|
30
23
|
message = MessagePack.unpack(
|
31
24
|
message,
|
@@ -34,6 +27,9 @@ module Rcom
|
|
34
27
|
yield message
|
35
28
|
end
|
36
29
|
end
|
30
|
+
rescue
|
31
|
+
sleep 1
|
32
|
+
retry
|
37
33
|
rescue Interrupt => _
|
38
34
|
end
|
39
35
|
end
|
data/lib/rcom/version.rb
CHANGED
data/rcom.gemspec
CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "yard"
|
24
23
|
|
25
24
|
spec.add_dependency "redis", "~> 3.1.0"
|
26
25
|
spec.add_dependency "msgpack", "~> 0.5.9"
|
data/test/spec/rpc_spec.rb
CHANGED
@@ -1,38 +1,70 @@
|
|
1
1
|
require_relative './_init'
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'Request' do
|
4
4
|
before do
|
5
5
|
ENV['LOCAL'] = 'redis://localhost'
|
6
6
|
@node = Rcom::Node.new('local').connect
|
7
|
-
@
|
7
|
+
@request = Rcom::Request.new(node: @node, channel: 'auth')
|
8
8
|
end
|
9
9
|
|
10
|
-
it 'represents a
|
11
|
-
@
|
10
|
+
it 'represents a request' do
|
11
|
+
@request.must_be_instance_of Rcom::Request
|
12
12
|
end
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
describe 'Response' do
|
16
|
+
before do
|
17
|
+
ENV['LOCAL'] = 'redis://localhost'
|
18
|
+
@node = Rcom::Node.new('local').connect
|
19
|
+
@response = Rcom::Response.new(
|
20
|
+
node: @node,
|
21
|
+
channel: 'auth',
|
22
|
+
server: nil
|
23
|
+
)
|
16
24
|
end
|
17
25
|
|
18
|
-
it '
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
consumer = 'bundle exec ruby test/bin/rpc_consumer.rb'
|
26
|
+
it 'represents a response' do
|
27
|
+
@response.must_be_instance_of Rcom::Response
|
28
|
+
end
|
29
|
+
end
|
23
30
|
|
24
|
-
|
25
|
-
|
31
|
+
describe 'Request-Response' do
|
32
|
+
before do
|
33
|
+
ENV['LOCAL'] = 'redis://localhost'
|
34
|
+
@node = Rcom::Node.new('local').connect
|
35
|
+
|
36
|
+
@service = Rcom::Request.new(node: @node, channel: 'auth')
|
37
|
+
|
38
|
+
@rpc_server = fork {
|
39
|
+
class Server
|
40
|
+
def get_key(params)
|
41
|
+
user = params[:user]
|
42
|
+
return nil unless user == 1
|
43
|
+
return 'xxxccc'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
auth = Rcom::Response.new(
|
47
|
+
node: @node,
|
48
|
+
channel: 'auth',
|
49
|
+
server: Server.new
|
50
|
+
)
|
51
|
+
auth.serve
|
52
|
+
}
|
53
|
+
|
54
|
+
Process.detach @rpc_server
|
26
55
|
sleep 1
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'cannot request method that does not exists' do
|
59
|
+
@service.get_nonexistent(1).must_equal nil
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'can request a method with the correct hash param' do
|
63
|
+
@service.get_key(user: 1).must_equal 'xxxccc'
|
64
|
+
end
|
27
65
|
|
28
|
-
# Spawn a request and record stdout,
|
29
|
-
# then kill both consumer and publisher.
|
30
|
-
Open3.popen3(publisher) do |stdin, stdout, stderr, thr|
|
31
|
-
response = stdout.gets
|
32
|
-
Process.kill('INT', thr.pid)
|
33
|
-
end
|
34
|
-
Process.kill('INT', consumer_pid)
|
35
66
|
|
36
|
-
|
67
|
+
after do
|
68
|
+
Process.kill('INT', @rpc_server)
|
37
69
|
end
|
38
70
|
end
|
data/test/spec/task_spec.rb
CHANGED
@@ -4,41 +4,35 @@ describe 'Task' do
|
|
4
4
|
before do
|
5
5
|
ENV['LOCAL'] = 'redis://localhost'
|
6
6
|
@node = Rcom::Node.new('local').connect
|
7
|
-
@task = Rcom::Task.new(node: @node,
|
7
|
+
@task = Rcom::Task.new(node: @node, channel: 'messages')
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'represents a Task' do
|
11
11
|
@task.must_be_instance_of Rcom::Task
|
12
12
|
end
|
13
13
|
|
14
|
-
it 'can
|
15
|
-
|
14
|
+
it 'can publishe a task and subscribe to receive it' do
|
15
|
+
original_message = {
|
16
16
|
id: 1,
|
17
17
|
key: 'xxxccc'
|
18
18
|
}
|
19
|
-
|
20
|
-
end
|
19
|
+
reader, writer = IO.pipe
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
@subscriber = fork {
|
22
|
+
@task.subscribe do |message|
|
23
|
+
writer.write message
|
24
|
+
end
|
26
25
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
Process.detach @subscriber
|
27
|
+
sleep 1
|
28
|
+
|
29
|
+
@task.publish(original_message)
|
30
|
+
sleep 1
|
30
31
|
|
31
|
-
|
32
|
-
# start the publisher and wait for the message
|
33
|
-
# on the consumer side. Process, then kill
|
34
|
-
# the long-running consumer.
|
35
|
-
Open3.popen3(consumer) do |stdin, stdout, stderr, wait_thr|
|
36
|
-
sleep 1
|
37
|
-
spawn(publisher)
|
38
|
-
completed_job = stdout.gets
|
39
|
-
Process.kill('INT', wait_thr.pid)
|
40
|
-
end
|
32
|
+
Process.kill('INT', @subscriber)
|
41
33
|
|
42
|
-
|
34
|
+
writer.close
|
35
|
+
eval(reader.read).must_equal original_message
|
36
|
+
reader.close
|
43
37
|
end
|
44
38
|
end
|
data/test/spec/topic_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe 'Topic' do
|
|
4
4
|
before do
|
5
5
|
ENV['LOCAL'] = 'redis://localhost'
|
6
6
|
@node = Rcom::Node.new('local').connect
|
7
|
-
@topic = Rcom::Topic.new(node: @node,
|
7
|
+
@topic = Rcom::Topic.new(node: @node, channel: 'users')
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'represents a Topic' do
|
@@ -19,27 +19,28 @@ describe 'Topic' do
|
|
19
19
|
@topic.publish(message).must_equal true
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
23
|
-
|
22
|
+
it 'can subscribe to a channel and receive a message' do
|
23
|
+
original_message = {
|
24
24
|
id: 1,
|
25
25
|
key: 'xxxccc'
|
26
26
|
}
|
27
|
-
|
28
|
-
|
29
|
-
subscriber =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
27
|
+
reader, writer = IO.pipe
|
28
|
+
|
29
|
+
@subscriber = fork {
|
30
|
+
@topic.subscribe do |message|
|
31
|
+
writer.write message
|
32
|
+
end
|
33
|
+
}
|
34
|
+
Process.detach @subscriber
|
35
|
+
sleep 1
|
36
|
+
|
37
|
+
@topic.publish(original_message)
|
38
|
+
sleep 1
|
39
|
+
|
40
|
+
Process.kill('INT', @subscriber)
|
41
|
+
|
42
|
+
writer.close
|
43
|
+
eval(reader.read).must_equal original_message
|
44
|
+
reader.close
|
44
45
|
end
|
45
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Lisci
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: yard
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: redis
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,12 +86,6 @@ files:
|
|
100
86
|
- lib/rcom/topic.rb
|
101
87
|
- lib/rcom/version.rb
|
102
88
|
- rcom.gemspec
|
103
|
-
- test/bin/rpc_consumer.rb
|
104
|
-
- test/bin/rpc_publisher.rb
|
105
|
-
- test/bin/task_consumer.rb
|
106
|
-
- test/bin/task_publisher.rb
|
107
|
-
- test/bin/topic_publisher.rb
|
108
|
-
- test/bin/topic_subscriber.rb
|
109
89
|
- test/spec/_init.rb
|
110
90
|
- test/spec/node_spec.rb
|
111
91
|
- test/spec/rpc_spec.rb
|
@@ -136,15 +116,8 @@ signing_key:
|
|
136
116
|
specification_version: 4
|
137
117
|
summary: Redis inter-service messaging.
|
138
118
|
test_files:
|
139
|
-
- test/bin/rpc_consumer.rb
|
140
|
-
- test/bin/rpc_publisher.rb
|
141
|
-
- test/bin/task_consumer.rb
|
142
|
-
- test/bin/task_publisher.rb
|
143
|
-
- test/bin/topic_publisher.rb
|
144
|
-
- test/bin/topic_subscriber.rb
|
145
119
|
- test/spec/_init.rb
|
146
120
|
- test/spec/node_spec.rb
|
147
121
|
- test/spec/rpc_spec.rb
|
148
122
|
- test/spec/task_spec.rb
|
149
123
|
- test/spec/topic_spec.rb
|
150
|
-
has_rdoc:
|
data/test/bin/rpc_consumer.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
ENV['LOCAL'] = 'redis://localhost'
|
3
|
-
|
4
|
-
require 'rcom'
|
5
|
-
|
6
|
-
node = Rcom::Node.new('local').connect
|
7
|
-
auth = Rcom::Rpc.new(node: node, service: 'auth')
|
8
|
-
|
9
|
-
auth.subscribe do |request|
|
10
|
-
request.on('user.key') do |params|
|
11
|
-
request.reply = 'xxxccc'
|
12
|
-
end
|
13
|
-
end
|
data/test/bin/rpc_publisher.rb
DELETED
data/test/bin/task_consumer.rb
DELETED
data/test/bin/task_publisher.rb
DELETED
data/test/bin/topic_publisher.rb
DELETED