pigato 0.1.2 → 0.1.3

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: 084cf3ce0c185586f92f4801285553e68e23085d
4
- data.tar.gz: bdffbb4efc8e86d3ffb2ed669fade66987c4e8a9
3
+ metadata.gz: 006a5eeffba25d949d31e70896e14f45948c3398
4
+ data.tar.gz: 17181c572ada29a77a007636415bb20a87e785f4
5
5
  SHA512:
6
- metadata.gz: b6a2f6ccb48abb66956e8695079b07e53ca372b7ecb12ae6558935c5e3d10c4dda831a6035b0d055d401199bfec1ea894b84c0d1d8cd11db37896914437e1375
7
- data.tar.gz: 427d7dec7fe448f198a72f3c2c0eff322bf9729dd30c5d8724e3bd83d12fb1bb8a81b38bdaf5cf55305c78f2fa4cb8fc5451b68c96ab17bb65761e48ef4e882b
6
+ metadata.gz: 2df204b3748cf487b2fe3c177f2cd65ec9d52fd8bb721b493cb61d11b69838c53c1f4dced7eff1ccfe9dbbbc747648c495b4026fad135381696742a150e74529
7
+ data.tar.gz: 4426e095848a3907a79f6a6e06ed2b0f3f594df6bfb46a3b66e11b86d7d2b669dd765e9a8414486d39a2a92d9627981ef6a7b8e69060fa474c2df4a240a82270
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Pigato
1
+ # PIGATO-RUBY
2
+
3
+ * [Official PIGATO project page](http://prdn.github.io/pigato/)
4
+ * [Node.js and io.js broker/client/worker](https://github.com/prdn/pigato)
2
5
 
3
6
  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/pigato`. To experiment with that code, run `bin/console` for an interactive prompt.
4
7
 
@@ -21,8 +24,12 @@ Or install it yourself as:
21
24
  $ gem install pigato
22
25
 
23
26
  ## Usage
27
+ Example client/worker echo:
28
+
29
+ * `examples/echo_client.rb`
30
+ * `examples/echo_worker.rb`
24
31
 
25
- TODO: Write usage instructions here
32
+ In order to run the example you need to run Node.js PIGATO example Broker from the [main project](https://github.com/prdn/pigato/tree/master/examples)
26
33
 
27
34
  ## Development
28
35
 
data/lib/pigato/client.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "ffi-rzmq"
3
+ require "securerandom"
3
4
 
4
5
  class PigatoClient
5
6
 
@@ -15,7 +16,7 @@ class PigatoClient
15
16
  def send service, request, timeout = 2500
16
17
  request = [request.to_json]
17
18
 
18
- rid = 'RID' + (rand() * 1000000).to_s
19
+ rid = SecureRandom.uuid
19
20
  request = [Pigato::C_CLIENT, Pigato::W_REQUEST, service, rid].concat(request)
20
21
  @client.send_strings request
21
22
 
@@ -57,7 +58,7 @@ class PigatoClient
57
58
 
58
59
  @client = @context.socket ZMQ::DEALER
59
60
  @client.setsockopt ZMQ::LINGER, 0
60
- @client.setsockopt ZMQ::IDENTITY, "C" + (rand() * 10).to_s
61
+ @client.setsockopt ZMQ::IDENTITY, SecureRandom.uuid
61
62
  @client.connect @broker
62
63
  @poller.register @client, ZMQ::POLLIN
63
64
  end
@@ -1,3 +1,3 @@
1
1
  module Pigato
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/pigato/worker.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "ffi-rzmq"
3
+ require "securerandom"
3
4
 
4
5
  class PigatoWorker
5
6
  HEARTBEAT_LIVENESS = 3 # 3-5 is reasonable
@@ -87,7 +88,7 @@ class PigatoWorker
87
88
  end
88
89
 
89
90
  @worker = @context.socket ZMQ::DEALER
90
- @worker.setsockopt ZMQ::IDENTITY, 'WRK01'
91
+ @worker.setsockopt ZMQ::IDENTITY, SecureRandom.uuid
91
92
  @worker.setsockopt ZMQ::LINGER, 0
92
93
  @worker.connect @broker
93
94
  @poller.register @worker, ZMQ::POLLIN
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pigato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Ardoino