cztop 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2f6944c31fc9ad2963801d45a819492a0c4a82c
4
- data.tar.gz: cf4cacb4b356309058278b871143fb22c1ba53fa
3
+ metadata.gz: 96f2495047d3a6101b3dd40b8b840609e524d110
4
+ data.tar.gz: 4784cc4fc2f0334d2eb8dc59db6a703ad6807478
5
5
  SHA512:
6
- metadata.gz: 49e3cfd581c7424139a818450aa46b063a244610e96ef488371e2e70583a595b57e5c373799b58ac42c291f92e9c5bacb83f8f26fadf7363a2c6dd05e24ef775
7
- data.tar.gz: a3cf1ea8a5b50b522eb0c7a7505c11fd068100fead2cd141410f9ae5dfb64f69f8a79f5ba3008dcd62b46ae95f258a5b1db30901188916ee863bd0e99198e717
6
+ metadata.gz: 7cad245ae10e5925122107b97d304df4b1ff0ab7835aeb3d64ac4a558c37b0ad4db323d4ab7ce38b9241f920f5e793cd2497decee16318c3855d00865d43d4d9
7
+ data.tar.gz: b61227b5ffc632697054b96d65480cc16bc9a05a42d275b6890d0248811d73aff84c10c3ab75bb55239f4b4aa08edfb157f86f789e4edcf3f7ab44308c9573ce
data/.travis.yml CHANGED
@@ -5,15 +5,16 @@ cache:
5
5
  - $HOME/.ccache
6
6
  - $HOME/.bundle
7
7
  rvm:
8
- - 2.3.0
9
- - 2.2.4
10
- - 2.1.8
11
- - 2.0.0-p648
8
+ - 2.3.1
9
+ - 2.2.5
12
10
  - jruby-head
13
11
  - rbx
14
12
  env:
15
13
  # recognized by czmq-ffi-gen's ci-scripts
16
14
  - CZMQ_VERSION=HEAD ZMQ_VERSION=HEAD
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: rbx
17
18
  before_install:
18
19
  - PATH="/usr/lib/ccache:$PATH" # enable ccache
19
20
  - export LD_LIBRARY_PATH=$HOME/lib # custom libs (for execution)
data/CHANGES.md CHANGED
@@ -1,3 +1,12 @@
1
+ 0.5.0 (28/06/2016)
2
+ -----
3
+ * new example (weather PUB/SUB)
4
+ * add option to enable IPv6 on sockets
5
+ * avoid $DEBUG warnings
6
+ * fix specs on Rubinius
7
+ * better documentation
8
+ * minor CI improvements
9
+
1
10
  0.4.0 (13/04/2016)
2
11
  -----
3
12
  * CZTop::Poller learns the following methods for convenience and compatibility:
data/Gemfile CHANGED
@@ -8,4 +8,7 @@ gemspec
8
8
  group :development do
9
9
  gem 'rubocop', require: false
10
10
  gem 'coveralls', require: false, platform: :mri
11
+
12
+ # >= 3.1 doesn't work on Rubinius, see guard/listen#391
13
+ gem 'listen', '~> 3.0.x', require: false
11
14
  end
data/README.md CHANGED
@@ -57,7 +57,7 @@ Here are some some of the goals I have/had in mind for this library:
57
57
  - [x] 100% test coverage
58
58
  - [x] provide a portable Z85 implementation
59
59
  * unlike [fpesce/z85](https://github.com/fpesce/z85), which is a C extension
60
- - [ ] use it to replace the [Celluloid::ZMQ](https://github.com/celluloid/celluloid-zmq) part of [Celluloid](https://github.com/celluloid/celluloid)
60
+ - [x] use it to replace the [Celluloid::ZMQ](https://github.com/celluloid/celluloid-zmq) part of [Celluloid](https://github.com/celluloid/celluloid)
61
61
  * [celluloid/celluloid-zmq#56](https://github.com/celluloid/celluloid-zmq/issues/56)
62
62
  - [ ] implement some of the missing (CZMQ based) Ruby examples in the [ZMQ Guide](http://zguide.zeromq.org/page:all)
63
63
 
@@ -124,11 +124,9 @@ More information in the [API documentation](http://www.rubydoc.info/github/paddo
124
124
  * there are `#routing_id` and `#routing_id=` on the following classes:
125
125
  * CZTop::Message
126
126
  * CZTop::Frame
127
- * requires ZMQ >= 4.2
128
127
  * ZMTP 3.1 heartbeat ready
129
128
  * `socket.options.heartbeat_ivl = 2000`
130
129
  * `socket.options.heartbeat_timeout = 8000`
131
- * requires ZMQ >= 4.2
132
130
 
133
131
  ## Requirements
134
132
 
@@ -150,6 +148,11 @@ To install on OSX using homebrew, run:
150
148
  If you're running Linux, go check [this page](http://zeromq.org/distro:_start)
151
149
  to get more help. Make sure to install CZMQ, not only ZMQ.
152
150
 
151
+ **Note:** Currently (as of May 2016), when compiling ZMQ from master, it may
152
+ be required to pass `--enable-drafts` to `./configure` to make sure all the
153
+ `zmq_poller_*()` functions are available. However, this doesn't seem to be the
154
+ case on all systems.
155
+
153
156
  ### Supported Ruby versions
154
157
 
155
158
  See [.travis.yml](https://github.com/paddor/cztop/blob/master/.travis.yml) for a list of Ruby versions against which CZTop
@@ -157,7 +160,7 @@ is tested.
157
160
 
158
161
  At the time of writing, these include:
159
162
 
160
- * MRI (2.3, 2.2.4, 2.1.8, 2.0.0)
163
+ * MRI (2.3, 2.2)
161
164
  * Rubinius (HEAD)
162
165
  * JRuby 9000 (HEAD)
163
166
 
@@ -2,7 +2,7 @@
2
2
  set -e
3
3
  mkdir -p vendor
4
4
  cd vendor
5
- git clone https://github.com/paddor/czmq-ffi-gen
5
+ git clone --depth 1 https://github.com/paddor/czmq-ffi-gen
6
6
  cd czmq-ffi-gen
7
7
  ci-scripts/install-libsodium
8
8
  ci-scripts/install-libzmq
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Weather update server, based on ZMQ's zguide.
4
+ # Binds PUB socket to ipc:///tmp/weather_pubsub_example
5
+ # Publishes random weather updates
6
+ #
7
+
8
+ require 'cztop'
9
+
10
+ # create and bind socket
11
+ socket = CZTop::Socket::PUB.new("ipc:///tmp/weather_pubsub_example")
12
+ puts "<<< Socket bound to #{socket.last_endpoint.inspect}"
13
+
14
+ while true
15
+ # Generate values for zipcodes
16
+ zipcode = rand(100000)
17
+ temperature = rand(215) - 80
18
+ relhumidity = rand(50) + 10
19
+
20
+ update = "%05d %d %d" % [zipcode, temperature, relhumidity]
21
+ puts update
22
+
23
+ socket << update
24
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Weather update client, based on that from ZMQ's zguide.
4
+ # Connects SUB socket to ipc:///tmp/weather_pubsub_example
5
+ # Collects weather updates and finds avg temp in zipcode
6
+ #
7
+
8
+ require 'cztop'
9
+
10
+ COUNT = 100
11
+
12
+ # Create socket, connect to publisher.
13
+ socket = CZTop::Socket::SUB.new("ipc:///tmp/weather_pubsub_example")
14
+ puts ">>> Socket Connected"
15
+
16
+ # Subscribe to zipcode. Default: Chicago - 60606
17
+ filter = ARGV.size > 0 ? ARGV[0] : "60606"
18
+ socket.subscribe(filter)
19
+
20
+ # gather & process COUNT updates.
21
+ print "Gathering #{COUNT} samples."
22
+ total_temp = 0
23
+ 1.upto(COUNT) do |update_nbr|
24
+ msg = socket.receive
25
+
26
+ zipcode, temperature, relhumidity = msg[0].split.map(&:to_i)
27
+ total_temp += temperature
28
+ # just to show that we're doing something...
29
+ print "." if update_nbr % 5 == 0
30
+ end
31
+ print "\n"
32
+
33
+ puts "Average temperatuer for zipcode #{filter} was #{total_temp / COUNT}F."
data/lib/cztop/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CZTop
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -22,7 +22,6 @@ class CZTop::Z85::Pipe
22
22
  #
23
23
  # @return [Integer] number of bytes read (binary data)
24
24
  def encode
25
- padded = false
26
25
  @strategy.new(@source, @sink, ENCODE_READ_SZ) do |chunk, prev_chunk|
27
26
  @bin_bytes += chunk.bytesize if chunk
28
27
  if prev_chunk && chunk
@@ -32,10 +32,10 @@ module CZTop
32
32
  # @raise [NoMethodError] if option name can't be recognized
33
33
  def [](option_name)
34
34
  # NOTE: beware of predicates, especially #CURVE_server? & friends
35
- m = public_methods.reject { |m| m =~ /=$/ }
35
+ meth = public_methods.reject { |m| m =~ /=$/ }
36
36
  .find { |m| m =~ /^#{option_name}\??$/i }
37
- raise NoMethodError, option_name if m.nil?
38
- __send__(m)
37
+ raise NoMethodError, option_name if meth.nil?
38
+ __send__(meth)
39
39
  end
40
40
 
41
41
  # Fuzzy option setter. This is to make it easier when porting
@@ -44,9 +44,9 @@ module CZTop
44
44
  # @param new_value [String, Integer] new value
45
45
  # @raise [NoMethodError] if option name can't be recognized
46
46
  def []=(option_name, new_value)
47
- m = public_methods.find { |m| m =~ /^#{option_name}=$/i }
48
- raise NoMethodError, option_name if m.nil?
49
- __send__(m, new_value)
47
+ meth = public_methods.find { |m| m =~ /^#{option_name}=$/i }
48
+ raise NoMethodError, option_name if meth.nil?
49
+ __send__(meth, new_value)
50
50
  end
51
51
 
52
52
  include CZMQ::FFI
@@ -273,13 +273,23 @@ module CZTop
273
273
  Zsock.set_linger(@zocket, new_value)
274
274
  end
275
275
 
276
+ # @return [Boolean] current value of ipv6
277
+ def ipv6?() Zsock.ipv6(@zocket) != 0 end
278
+ # Set the IPv6 option for the socket. A value of true means IPv6 is
279
+ # enabled on the socket, while false means the socket will use only
280
+ # IPv4. When IPv6 is enabled the socket will connect to, or accept
281
+ # connections from, both IPv4 and IPv6 hosts.
282
+ # Default is false.
283
+ # @param new_value [Boolean] new value for ipv6
284
+ def ipv6=(new_value)
285
+ Zsock.set_ipv6(@zocket, new_value ? 1 : 0)
286
+ end
276
287
  # TODO: a reasonable subset of these
277
288
  #// Get socket options
278
289
  #int zsock_gssapi_server (void *self);
279
290
  #int zsock_gssapi_plaintext (void *self);
280
291
  #char * zsock_gssapi_principal (void *self);
281
292
  #char * zsock_gssapi_service_principal (void *self);
282
- #int zsock_ipv6 (void *self);
283
293
  #int zsock_immediate (void *self);
284
294
  #int zsock_type (void *self);
285
295
  #int zsock_affinity (void *self);
@@ -311,7 +321,6 @@ module CZTop
311
321
  #void zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
312
322
  #void zsock_set_gssapi_principal (void *self, const char * gssapi_principal);
313
323
  #void zsock_set_gssapi_service_principal (void *self, const char * gssapi_service_principal);
314
- #void zsock_set_ipv6 (void *self, int ipv6);
315
324
  #void zsock_set_immediate (void *self, int immediate);
316
325
  #void zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
317
326
  #void zsock_set_affinity (void *self, int affinity);
data/perf/README.md CHANGED
@@ -4,8 +4,8 @@ This directory contains simple performance measurement utilities:
4
4
 
5
5
  - `inproc_lat.rb` measures the latency of the inproc transport
6
6
  - `inproc_thr.rb` measures the throughput of the inproc transport
7
- - `local_lat.rb` and `remote_lat.rb` measure the latency other transports
8
- - `local_thr.rb` and `remote_thr.rb` measure the throughput other transports (TODO)
7
+ - `local_lat.rb` and `remote_lat.rb` measure the latency of other transports
8
+ - `local_thr.rb` and `remote_thr.rb` measure the throughput of other transports (TODO)
9
9
 
10
10
  ## Example Output
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cztop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: czmq-ffi-gen
@@ -243,6 +243,8 @@ files:
243
243
  - examples/taxi_system/generate_keys.rb
244
244
  - examples/taxi_system/start_broker.sh
245
245
  - examples/taxi_system/start_clients.sh
246
+ - examples/weather_pub_sub/pub.rb
247
+ - examples/weather_pub_sub/sub.rb
246
248
  - exe/z85decode
247
249
  - exe/z85encode
248
250
  - lib/cztop.rb