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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85b3814ee9e2fd9a8071c13f473144edb7b3c884
4
- data.tar.gz: 575cab001d663544971e53a18d7bd85b93ebe987
3
+ metadata.gz: bd160175ce59dccd9251b7fb0430a12ee1287e24
4
+ data.tar.gz: 9cef2ac8ab3d4fdfb73eb7daf3ee9b5b77ed51a7
5
5
  SHA512:
6
- metadata.gz: 7dd3daad75a0a18d4aa7ed11d42a0cf62d30b9e0d69adf4116256d1243758cc936e3df015b83a766770c4de5cadb932d6cf0ebeb18e7b1b306ef475f9d0255c1
7
- data.tar.gz: d18a2333bfdc23ab0bb846b3b862c83bf88cb332ed8170d58986774df5c63594db4a3e6c42443629bbdcaa295e29727d4f1c92345f37f5c9d76088a4151fac5b
6
+ metadata.gz: b2e14d971a2f21941fb4a031c4944437011694002ce74557aa2e8b90d33e93092ca825c9115b3d5582d3737f6752ffc16ff8262a4c6bee42ce9ef61b6a859f64
7
+ data.tar.gz: 8505da8fe4d9f80acb1aff57a1bff46e27df4e95cef50543119d3de5871a441e440bd65f8478ce85f93cbfd874d753180308981e2ce5783e77e37bf174ae4c7a
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # BunnyRpc
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bunny_rpc`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- result = client.publish('playload')
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
- client = BunnyRpc::Server.new('queue1')
40
+ server = BunnyRpc::Server.new
38
41
 
39
- client.subscribe do |data|
42
+ server.subscribe('queue1') do |data|
40
43
  puts data
41
44
 
42
45
  payload = 'get it !'
43
46
 
44
- client.publish(payload)
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.0'
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'
@@ -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(queue_name, options={})
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
@@ -1,3 +1,3 @@
1
1
  module BunnyRpc
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
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.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.0
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.0
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement