zyre 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: bc86fa098a17006c4e470186fb0f98910f0d443ef62351f18aa2c1f8962c9bcc
4
- data.tar.gz: aac8d6fa401e07df184f74fa0f9ef4e31e46bb91997b5af9eafe71f8048460c8
3
+ metadata.gz: e427448e7167b7f7d7dfb181f6be8d0f99f34f6d2e5db0df91483a1a3c0283fe
4
+ data.tar.gz: 4444b34e17f9751aace7634320756521c6ff922aeddef3d70b369449fb4cea8b
5
5
  SHA512:
6
- metadata.gz: 6d44fcc7a7c5b63a6e471957d5361ea9595b34b2d35f458f61cb6ee5e19db8f624e5e857203fac49992dab6160937e57571069057894ec2d8e2c51801744e88f
7
- data.tar.gz: d5be9dc4fd921a16679850d505bb8d81ad1bcd3029ad7b1ec84277957653c345f0ebdcedf3e7a9139111a7320fccdc797f1a316ff74c2860b3b56c098ffc546f
6
+ metadata.gz: '038d430e4345f383a4634daeaaeb51103ccb34fb2d370b55cb9a0fd5fe93b27fb94299f94b61139d1ea7faa2059203cae14578addbb49c4b2d441fc1474624d4'
7
+ data.tar.gz: 50503df7839c8d98c83d6f17bf2e4bfafef429949314b578fbbb35dce7245809439d417975b718d50e34d34ce019057273133506fb54fdc36a4a8f43f4e9df48
Binary file
data.tar.gz.sig CHANGED
Binary file
data/History.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Release History for zyre
2
2
 
3
3
  ---
4
+
5
+ ## v0.3.0 [2020-11-16] Michael Granger <ged@faeriemud.org>
6
+
7
+ Improvements:
8
+
9
+ - Fixed use of binary data in event frames.
10
+
11
+
4
12
  ## v0.2.0 [2020-11-09] Michael Granger <ged@faeriemud.org>
5
13
 
6
14
  Improvements:
@@ -443,12 +443,10 @@ rzyre_event_msg( VALUE self ) {
443
443
 
444
444
  if ( msg ) {
445
445
  zframe_t *frame = zmsg_first( msg );
446
- char *str = zframe_strdup( frame );
446
+ byte *data = zframe_data( frame );
447
447
 
448
- rval = rb_enc_str_new( str, zframe_size(frame), rb_ascii8bit_encoding() );
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;
@@ -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( call_ptr->msg_parts, i );
94
- zmsg_addstr( call_ptr->msg, StringValueCStr(msg_part) );
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;
@@ -12,7 +12,7 @@ module Zyre
12
12
 
13
13
 
14
14
  # Gem version (semver)
15
- VERSION = '0.2.0'
15
+ VERSION = '0.3.0'
16
16
 
17
17
 
18
18
  # Set up a logger for Zyre classes
@@ -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 )
@@ -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.2.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-09 00:00:00.000000000 Z
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