celluloid-zmq 0.10.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.12.0
2
+ ------
3
+ * Tracking release for Celluloid 0.12.0
4
+
1
5
  0.10.0
2
6
  ------
3
7
  * Factor celluloid-zmq into its own gem
data/README.md CHANGED
@@ -58,7 +58,7 @@ class Server
58
58
  end
59
59
 
60
60
  def run
61
- while true; handle_message! @socket.read; end
61
+ loop { handle_message! @socket.read }
62
62
  end
63
63
 
64
64
  def handle_message(message)
@@ -11,8 +11,8 @@ Gem::Specification.new do |gem|
11
11
  gem.name = "celluloid-zmq"
12
12
  gem.version = Celluloid::ZMQ::VERSION
13
13
 
14
- gem.add_dependency "celluloid", "~> 0.10.0"
15
- gem.add_dependency "celluloid-io", "~> 0.10.0"
14
+ gem.add_dependency "celluloid", "~> 0.12.0"
15
+ gem.add_dependency "celluloid-io", "~> 0.12.0"
16
16
  gem.add_dependency "ffi"
17
17
  gem.add_dependency "ffi-rzmq"
18
18
 
@@ -19,13 +19,15 @@ module Celluloid
19
19
  end
20
20
 
21
21
  # Obtain a 0MQ context (or lazily initialize it)
22
- def context(threads = 1)
22
+ def context(worker_threads = 1)
23
23
  return @context if @context
24
- @context = ::ZMQ::Context.new(threads)
25
- at_exit { @context.terminate }
26
- @context
24
+ @context = ::ZMQ::Context.new(worker_threads)
27
25
  end
28
26
  alias_method :init, :context
27
+
28
+ def terminate
29
+ @context.terminate
30
+ end
29
31
  end
30
32
 
31
33
  extend Forwardable
@@ -1,13 +1,12 @@
1
1
  module Celluloid
2
2
  module ZMQ
3
- attr_reader :linger
4
-
5
3
  class Socket
6
4
  # Create a new socket
7
5
  def initialize(type)
8
6
  @socket = Celluloid::ZMQ.context.socket ::ZMQ.const_get(type.to_s.upcase)
9
7
  @linger = 0
10
8
  end
9
+ attr_reader :linger
11
10
 
12
11
  # Connect to the given 0MQ address
13
12
  # Address should be in the form: tcp://1.2.3.4:5678/
@@ -79,19 +78,21 @@ module Celluloid
79
78
  # Writable 0MQ sockets have a send method
80
79
  module WritableSocket
81
80
  # Send a message to the socket
82
- def send(message)
83
- unless ::ZMQ::Util.resultcode_ok? @socket.send_string message
81
+ def write(*messages)
82
+ unless ::ZMQ::Util.resultcode_ok? @socket.send_strings messages.flatten
84
83
  raise IOError, "error sending 0MQ message: #{::ZMQ::Util.error_string}"
85
84
  end
86
85
 
87
- message
86
+ messages
88
87
  end
89
- alias_method :<<, :send
88
+ alias_method :<<, :write
89
+ alias_method :send, :write # deprecated
90
90
  end
91
91
 
92
92
  # ReqSockets are the counterpart of RepSockets (REQ/REP)
93
93
  class ReqSocket < Socket
94
94
  include ReadableSocket
95
+ include WritableSocket
95
96
 
96
97
  def initialize
97
98
  super :req
@@ -100,6 +101,7 @@ module Celluloid
100
101
 
101
102
  # RepSockets are the counterpart of ReqSockets (REQ/REP)
102
103
  class RepSocket < Socket
104
+ include ReadableSocket
103
105
  include WritableSocket
104
106
 
105
107
  def initialize
@@ -141,6 +143,18 @@ module Celluloid
141
143
  def initialize
142
144
  super :sub
143
145
  end
146
+
147
+ def subscribe(topic)
148
+ unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::SUBSCRIBE, topic)
149
+ raise IOError, "couldn't set subscribe: #{::ZMQ::Util.error_string}"
150
+ end
151
+ end
152
+
153
+ def unsubscribe(topic)
154
+ unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::UNSUBSCRIBE, topic)
155
+ raise IOError, "couldn't set unsubscribe: #{::ZMQ::Util.error_string}"
156
+ end
157
+ end
144
158
  end
145
159
  end
146
160
  end
@@ -1,5 +1,5 @@
1
1
  module Celluloid
2
2
  module ZMQ
3
- VERSION = "0.10.0"
3
+ VERSION = "0.12.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-zmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000 Z
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid
16
- requirement: &70300524096260 !ruby/object:Gem::Requirement
16
+ requirement: &70254147601380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.10.0
21
+ version: 0.12.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70300524096260
24
+ version_requirements: *70254147601380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: celluloid-io
27
- requirement: &70300524095640 !ruby/object:Gem::Requirement
27
+ requirement: &70254147600120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 0.10.0
32
+ version: 0.12.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70300524095640
35
+ version_requirements: *70254147600120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffi
38
- requirement: &70300524095260 !ruby/object:Gem::Requirement
38
+ requirement: &70254147599660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70300524095260
46
+ version_requirements: *70254147599660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ffi-rzmq
49
- requirement: &70300524094760 !ruby/object:Gem::Requirement
49
+ requirement: &70254147598820 !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: *70300524094760
57
+ version_requirements: *70254147598820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70300551724880 !ruby/object:Gem::Requirement
60
+ requirement: &70254147597640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70300551724880
68
+ version_requirements: *70254147597640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70300551724460 !ruby/object:Gem::Requirement
71
+ requirement: &70254147596600 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70300551724460
79
+ version_requirements: *70254147596600
80
80
  description: Celluloid bindings to the ffi-rzmq library
81
81
  email:
82
82
  - tony.arcieri@gmail.com
@@ -93,6 +93,7 @@ files:
93
93
  - lib/celluloid/zmq/waker.rb
94
94
  - lib/celluloid/zmq.rb
95
95
  - logo.png
96
+ - pkg/celluloid-zmq-0.10.0.gem
96
97
  - Rakefile
97
98
  - README.md
98
99
  - spec/celluloid/zmq/actor_spec.rb
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  requirements: []
120
121
  rubyforge_project:
121
- rubygems_version: 1.8.17
122
+ rubygems_version: 1.8.10
122
123
  signing_key:
123
124
  specification_version: 3
124
125
  summary: Celluloid::ZMQ provides concurrent Celluloid actors that can listen for 0MQ
@@ -127,3 +128,4 @@ test_files:
127
128
  - spec/celluloid/zmq/actor_spec.rb
128
129
  - spec/spec_helper.rb
129
130
  - .gitignore
131
+ has_rdoc: