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 +4 -4
- data/README.md +9 -2
- data/lib/pigato/client.rb +3 -2
- data/lib/pigato/version.rb +1 -1
- data/lib/pigato/worker.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 006a5eeffba25d949d31e70896e14f45948c3398
|
4
|
+
data.tar.gz: 17181c572ada29a77a007636415bb20a87e785f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2df204b3748cf487b2fe3c177f2cd65ec9d52fd8bb721b493cb61d11b69838c53c1f4dced7eff1ccfe9dbbbc747648c495b4026fad135381696742a150e74529
|
7
|
+
data.tar.gz: 4426e095848a3907a79f6a6e06ed2b0f3f594df6bfb46a3b66e11b86d7d2b669dd765e9a8414486d39a2a92d9627981ef6a7b8e69060fa474c2df4a240a82270
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
#
|
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
|
-
|
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 =
|
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,
|
61
|
+
@client.setsockopt ZMQ::IDENTITY, SecureRandom.uuid
|
61
62
|
@client.connect @broker
|
62
63
|
@poller.register @client, ZMQ::POLLIN
|
63
64
|
end
|
data/lib/pigato/version.rb
CHANGED
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,
|
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
|