bunny_rpc 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -7
- data/bunny_rpc.gemspec +1 -1
- data/lib/bunny_rpc/server.rb +6 -4
- data/lib/bunny_rpc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd160175ce59dccd9251b7fb0430a12ee1287e24
|
4
|
+
data.tar.gz: 9cef2ac8ab3d4fdfb73eb7daf3ee9b5b77ed51a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e14d971a2f21941fb4a031c4944437011694002ce74557aa2e8b90d33e93092ca825c9115b3d5582d3737f6752ffc16ff8262a4c6bee42ce9ef61b6a859f64
|
7
|
+
data.tar.gz: 8505da8fe4d9f80acb1aff57a1bff46e27df4e95cef50543119d3de5871a441e440bd65f8478ce85f93cbfd874d753180308981e2ce5783e77e37bf174ae4c7a
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# BunnyRpc
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
rabbitmq RPC on bunny
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -24,22 +22,32 @@ Or install it yourself as:
|
|
24
22
|
|
25
23
|
### Client
|
26
24
|
|
25
|
+
```
|
27
26
|
require 'bunny_rpc'
|
28
27
|
|
29
28
|
client = BunnyRpc::Client.new
|
30
29
|
|
31
|
-
|
30
|
+
client.publish('okokokokok', 'queue1')
|
31
|
+
|
32
|
+
client.close
|
33
|
+
```
|
32
34
|
|
33
35
|
### Server
|
34
36
|
|
37
|
+
```
|
35
38
|
require 'bunny_rpc'
|
36
39
|
|
37
|
-
|
40
|
+
server = BunnyRpc::Server.new
|
38
41
|
|
39
|
-
|
42
|
+
server.subscribe('queue1') do |data|
|
40
43
|
puts data
|
41
44
|
|
42
45
|
payload = 'get it !'
|
43
46
|
|
44
|
-
|
47
|
+
server.publish(payload)
|
45
48
|
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## TODO
|
52
|
+
|
53
|
+
* 添加超时机制
|
data/bunny_rpc.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/menghuanwd/bunny_rpc'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.add_dependency 'bunny', '~> 2.3
|
17
|
+
spec.add_dependency 'bunny', '~> 2.3'
|
18
18
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
20
|
spec.bindir = 'exe'
|
data/lib/bunny_rpc/server.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module BunnyRpc
|
2
2
|
class Server
|
3
|
-
attr_accessor :reply_correlation_id, :reply_to
|
3
|
+
attr_accessor :reply_correlation_id, :reply_to, :queue_name
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@queue_name = queue_name
|
5
|
+
def initialize(options={})
|
7
6
|
@options = options
|
8
7
|
end
|
9
8
|
|
@@ -15,7 +14,10 @@ module BunnyRpc
|
|
15
14
|
)
|
16
15
|
end
|
17
16
|
|
18
|
-
def subscribe
|
17
|
+
def subscribe(queue_name)
|
18
|
+
raise 'no queue name' if queue_name.nil?
|
19
|
+
|
20
|
+
@queue_name = queue_name
|
19
21
|
queue.subscribe(block: true) do |_, properties, payload|
|
20
22
|
@reply_to = properties.reply_to
|
21
23
|
@reply_correlation_id = properties.correlation_id
|
data/lib/bunny_rpc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunny_rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- menghuanwd
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.3
|
19
|
+
version: '2.3'
|
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: 2.3
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|