zyre 0.2.0 → 0.3.0
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.md +8 -0
- data/ext/zyre_ext/event.c +2 -4
- data/ext/zyre_ext/zyre_ext.c +6 -3
- data/lib/zyre.rb +1 -1
- data/spec/zyre/event_spec.rb +13 -0
- data/spec/zyre/node_spec.rb +62 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e427448e7167b7f7d7dfb181f6be8d0f99f34f6d2e5db0df91483a1a3c0283fe
|
4
|
+
data.tar.gz: 4444b34e17f9751aace7634320756521c6ff922aeddef3d70b369449fb4cea8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038d430e4345f383a4634daeaaeb51103ccb34fb2d370b55cb9a0fd5fe93b27fb94299f94b61139d1ea7faa2059203cae14578addbb49c4b2d441fc1474624d4'
|
7
|
+
data.tar.gz: 50503df7839c8d98c83d6f17bf2e4bfafef429949314b578fbbb35dce7245809439d417975b718d50e34d34ce019057273133506fb54fdc36a4a8f43f4e9df48
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.md
CHANGED
data/ext/zyre_ext/event.c
CHANGED
@@ -443,12 +443,10 @@ rzyre_event_msg( VALUE self ) {
|
|
443
443
|
|
444
444
|
if ( msg ) {
|
445
445
|
zframe_t *frame = zmsg_first( msg );
|
446
|
-
|
446
|
+
byte *data = zframe_data( frame );
|
447
447
|
|
448
|
-
rval = rb_enc_str_new(
|
448
|
+
rval = rb_enc_str_new( (const char *)data, zframe_size(frame), rb_ascii8bit_encoding() );
|
449
449
|
rb_obj_freeze( rval );
|
450
|
-
|
451
|
-
free( str );
|
452
450
|
}
|
453
451
|
|
454
452
|
return rval;
|
data/ext/zyre_ext/zyre_ext.c
CHANGED
@@ -87,11 +87,14 @@ static VALUE
|
|
87
87
|
rzyre_add_frames_to_zmsg( VALUE call )
|
88
88
|
{
|
89
89
|
add_frames_to_zmsg_call_t *call_ptr = (add_frames_to_zmsg_call_t *)call;
|
90
|
-
VALUE msg_part;
|
90
|
+
VALUE msg_part, msg_str;
|
91
|
+
zframe_t *frame;
|
91
92
|
|
92
93
|
for ( long i = 0 ; i < RARRAY_LEN(call_ptr->msg_parts) ; i++ ) {
|
93
|
-
msg_part = rb_ary_entry(
|
94
|
-
|
94
|
+
msg_part = rb_ary_entry(call_ptr->msg_parts, i);
|
95
|
+
msg_str = StringValue( msg_part );
|
96
|
+
frame = zframe_new( RSTRING_PTR(msg_part), RSTRING_LEN(msg_part) );
|
97
|
+
zmsg_append( call_ptr->msg, &frame );
|
95
98
|
}
|
96
99
|
|
97
100
|
return Qtrue;
|
data/lib/zyre.rb
CHANGED
data/spec/zyre/event_spec.rb
CHANGED
@@ -136,6 +136,19 @@ RSpec.describe( Zyre::Event ) do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
|
139
|
+
it "can generate a SHOUT event with binary data in its msg" do
|
140
|
+
data = "\xBF\x8D\x00\x9D\xDDg\x03_\xF2Nr\x01\xF0I8Au\x95\xC6L\xD37".b +
|
141
|
+
"\xFFt\xC7\xE1\xC0<l\x17\xA2N\xE3".b
|
142
|
+
|
143
|
+
result = described_class.synthesize( :SHOUT, peer_uuid, group: 'stream', msg: data )
|
144
|
+
|
145
|
+
expect( result ).to be_a( described_class::Shout )
|
146
|
+
expect( result.peer_uuid ).to eq( peer_uuid )
|
147
|
+
expect( result.group ).to eq( 'stream' )
|
148
|
+
expect( result.msg ).to eq( data )
|
149
|
+
end
|
150
|
+
|
151
|
+
|
139
152
|
it "raises when creating a WHISPER with no msg" do
|
140
153
|
expect {
|
141
154
|
described_class.synthesize( :WHISPER, peer_uuid )
|
data/spec/zyre/node_spec.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../spec_helper'
|
4
4
|
|
5
|
+
require 'securerandom'
|
5
6
|
require 'zyre/node'
|
6
7
|
|
7
8
|
|
@@ -17,6 +18,13 @@ RSpec.describe( Zyre::Node ) do
|
|
17
18
|
I sound my barbaric yawp over the roofs of the world.
|
18
19
|
END_SHOUT
|
19
20
|
|
21
|
+
TEST_BINARY_STRING_PARTS = [
|
22
|
+
SecureRandom.bytes( 128 ),
|
23
|
+
"\x00".b,
|
24
|
+
SecureRandom.bytes( 128 )
|
25
|
+
]
|
26
|
+
TEST_BINARY_STRING = TEST_BINARY_STRING_PARTS.join( '' )
|
27
|
+
|
20
28
|
|
21
29
|
it "can be created anonymously" do
|
22
30
|
node = described_class.new
|
@@ -236,6 +244,60 @@ RSpec.describe( Zyre::Node ) do
|
|
236
244
|
end
|
237
245
|
|
238
246
|
|
247
|
+
it "can shout a binary message to a group of nodes" do
|
248
|
+
node1 = started_node()
|
249
|
+
node2 = started_node()
|
250
|
+
node3 = started_node()
|
251
|
+
|
252
|
+
node1.join( 'stream' )
|
253
|
+
node2.join( 'stream' )
|
254
|
+
node3.join( 'stream' )
|
255
|
+
|
256
|
+
2.times do
|
257
|
+
node1.wait_for( :JOIN, group: 'stream' )
|
258
|
+
end
|
259
|
+
node1.shout( 'stream', TEST_BINARY_STRING )
|
260
|
+
|
261
|
+
ev = node2.wait_for( :SHOUT, group: 'stream' )
|
262
|
+
expect( ev ).to be_a( Zyre::Event::Shout )
|
263
|
+
expect( ev ).to_not be_multipart
|
264
|
+
expect( ev.msg ).to eq( TEST_BINARY_STRING )
|
265
|
+
|
266
|
+
ev = node3.wait_for( :SHOUT, group: 'stream' )
|
267
|
+
expect( ev ).to be_a( Zyre::Event::Shout )
|
268
|
+
expect( ev ).to_not be_multipart
|
269
|
+
expect( ev.msg ).to eq( TEST_BINARY_STRING )
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
it "can shout a multipart binary message to a group of nodes" do
|
274
|
+
node1 = started_node()
|
275
|
+
node2 = started_node()
|
276
|
+
node3 = started_node()
|
277
|
+
|
278
|
+
node1.join( 'stream' )
|
279
|
+
node2.join( 'stream' )
|
280
|
+
node3.join( 'stream' )
|
281
|
+
|
282
|
+
2.times do
|
283
|
+
node1.wait_for( :JOIN, group: 'stream' )
|
284
|
+
end
|
285
|
+
node1.shout( 'stream', *TEST_BINARY_STRING_PARTS )
|
286
|
+
|
287
|
+
ev = node2.wait_for( :SHOUT, group: 'stream' )
|
288
|
+
expect( ev ).to be_a( Zyre::Event::Shout )
|
289
|
+
expect( ev ).to be_multipart
|
290
|
+
expect( ev.msg ).to eq( TEST_BINARY_STRING_PARTS[0] )
|
291
|
+
expect( ev.multipart_msg ).to eq( TEST_BINARY_STRING_PARTS )
|
292
|
+
|
293
|
+
ev = node3.wait_for( :SHOUT, group: 'stream' )
|
294
|
+
expect( ev ).to be_a( Zyre::Event::Shout )
|
295
|
+
expect( ev ).to be_multipart
|
296
|
+
expect( ev.msg ).to eq( TEST_BINARY_STRING_PARTS[0] )
|
297
|
+
expect( ev.multipart_msg ).to eq( TEST_BINARY_STRING_PARTS )
|
298
|
+
end
|
299
|
+
|
300
|
+
|
239
301
|
it "handles unstringifiable messages gracefully" do
|
240
302
|
node1 = started_node()
|
241
303
|
node1.join( 'ROOFTOP' )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zyre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
83uuAYSy65yXDGXXPVBeKPVnYrqp91pqpS5Nh7wfuiCrE8lgU8PATh7K4BV1UhAT
|
34
34
|
0MHbAT42wTYkfUj3
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2020-11-
|
36
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
37
37
|
dependencies:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: loggability
|
metadata.gz.sig
CHANGED
Binary file
|