funl 0.9 → 0.10

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: cdf695bf2792321cf4d8ae6b30bf9e7a38f0683d
4
- data.tar.gz: 2db5994e89d97ee992e5db334ac87f77a2e7c621
3
+ metadata.gz: c491fc8d90f7485317ebbcba49cecff09a44fce4
4
+ data.tar.gz: 7d3b5410cd213fb3fe2726468b7de706271e1763
5
5
  SHA512:
6
- metadata.gz: c6b15c970952e3c3e494749bbab721e0c51021e8e8bc48b6e90bb06a14d4baf05e4c33ecef110dcabd714dd35ef174023a3f423a90757cb20d3581a956aa4d82
7
- data.tar.gz: 20afc5d4ecf8d603f00e6c7b7564741278587fddc36ce225eaa28e971f648eb2daa12fb9842f6c99f6c53fd4e62ab1f6249dae2a133dcacbbc4abfcc5161bc6b
6
+ metadata.gz: 11d75b5b52d65820eb8d4ada2aee92760b19c37c956cea4dc6b168a2b20d653b82ef024b151ea4f0531b5f84404bd003e713208456922cef489081243b97125c
7
+ data.tar.gz: b25d03eed8d97b812107e9aaf3bb5974094dea2d47510e2e3063a1e85f3f93d05197e8144c4c2c109303a33b6c9629b899516c8660da1dd1fc6e06dc81d0b834
@@ -12,7 +12,7 @@ class BenchmarkTask
12
12
  @name = name
13
13
  @params = params
14
14
  end
15
-
15
+
16
16
  def inspect
17
17
  ps = params.map{|k,v| "#{k}: #{v}" }
18
18
  pstr = ps.empty? ? "" : " " + ps.join(', ')
@@ -103,10 +103,10 @@ class BenchmarkEnv
103
103
  task.run method(:make_stream)
104
104
  t1 = Process.times
105
105
  @mseq_ctrl << "dt"
106
-
106
+
107
107
  @mseq_ctrl.read
108
108
  dt = @mseq_ctrl.read
109
-
109
+
110
110
  time = t1.utime + t1.stime - (t0.utime + t0.stime)
111
111
  printf "%6.3f %6.3f | %p\n", time, dt, task
112
112
  rescue => ex
@@ -6,7 +6,7 @@ class MessageRateBenchmarkTask < BenchmarkTask
6
6
  n_msg = params[:n_msg] || 10
7
7
  n_cli = params[:n_cli] || 2
8
8
  cycle_sender = params[:cycle_sender] || false
9
-
9
+
10
10
  streams = n_cli.times.map {|i| make_stream[i]}
11
11
  threads = n_cli.times.map do |i|
12
12
  Thread.new do
@@ -15,14 +15,14 @@ class MessageRateBenchmarkTask < BenchmarkTask
15
15
  end
16
16
  end
17
17
  end
18
-
18
+
19
19
  n_msg.times do |i|
20
20
  stream = cycle_sender ? streams[i % n_cli] : streams[0]
21
21
  stream <<
22
22
  Message[client: "1", local: i, global: nil, delta: nil,
23
23
  tags: nil, blob: nil]
24
24
  end
25
-
25
+
26
26
  threads.each {|th| th.join}
27
27
  end
28
28
  end
@@ -39,7 +39,7 @@ if __FILE__ == $0
39
39
  # b_sel << MessageRateBenchmarkTask.new("msg rate", n_msg: 1000, n_cli: 100)
40
40
 
41
41
  b_sel.run
42
-
42
+
43
43
  puts
44
44
 
45
45
  b_nio = BenchmarkEnv.new("msg-rate", mseq_class: MessageSequencerNio)
@@ -26,7 +26,7 @@ module Funl
26
26
  MessagePack.dump arg
27
27
  end
28
28
  end
29
-
29
+
30
30
  # Returns something which responds to #dump(obj) and #load(str).
31
31
  def self.for type, symbolize_keys: false
32
32
  case type
@@ -37,7 +37,7 @@ module Funl
37
37
  @seq = client_stream_for(seq)
38
38
  @cseq = client_stream_for(cseq)
39
39
  @arcio = arc
40
-
40
+
41
41
  @sub_tracker = SubscriptionTracker.new(self)
42
42
  end
43
43
 
@@ -49,7 +49,7 @@ module Funl
49
49
  yield if block_given?
50
50
  seq_read_greeting
51
51
  end
52
-
52
+
53
53
  def subscribed_all
54
54
  @sub_tracker.subscribed_all
55
55
  end
@@ -88,7 +88,7 @@ module Funl
88
88
  def unsubscribe_all
89
89
  @sub_tracker.unsubscribe_all
90
90
  end
91
-
91
+
92
92
  # Maintain subscription status. Must be called by the user (or subclass)
93
93
  # of this class, most likely in the thread created by #start.
94
94
  def handle_ack ack
@@ -96,7 +96,7 @@ module Funl
96
96
  op_type, tags = ack.control_op
97
97
  @sub_tracker.update op_type, tags
98
98
  end
99
-
99
+
100
100
  def cseq_read_client_id
101
101
  log.debug "getting client_id from cseq"
102
102
  @client_id = cseq.read["client_id"]
@@ -3,7 +3,7 @@ module Funl::HistoryClient
3
3
 
4
4
  # The last N messages are kept.
5
5
  HISTORY_SIZE = 1000
6
-
6
+
7
7
  def initialize *args, history_size: HISTORY_SIZE, **opts
8
8
  super *args, **opts
9
9
  @history_size = history_size
@@ -5,31 +5,29 @@ module Funl
5
5
  class MessageSequencerNio < MessageSequencer
6
6
  private
7
7
 
8
- attr_reader :selector
9
-
10
8
  def init_selector
11
9
  @selector = NIO::Selector.new
12
10
  if server
13
- monitor = selector.register server, :r
11
+ monitor = @selector.register server, :r
14
12
  monitor.value = proc {accept_conn}
15
13
  end
16
14
  end
17
15
 
18
16
  def register_stream stream
19
- monitor = selector.register stream, :r
17
+ monitor = @selector.register stream, :r
20
18
  monitor.value = proc {read_conn stream}
21
19
  end
22
20
 
23
21
  def deregister_stream stream
24
- selector.deregister stream
22
+ @selector.deregister stream
25
23
  end
26
24
 
27
25
  def registered_stream? stream
28
- selector.registered? stream
26
+ @selector.registered? stream
29
27
  end
30
28
 
31
29
  def select_streams
32
- selector.select do |monitor|
30
+ @selector.select do |monitor|
33
31
  monitor.value.call(monitor)
34
32
  end
35
33
  end
@@ -4,26 +4,24 @@ module Funl
4
4
  class MessageSequencerSelect < MessageSequencer
5
5
  private
6
6
 
7
- attr_reader :streams
8
-
9
7
  def init_selector
10
8
  @streams = []
11
9
  end
12
10
 
13
11
  def register_stream stream
14
- streams << stream
12
+ @streams << stream
15
13
  end
16
14
 
17
15
  def deregister_stream stream
18
- streams.delete stream
16
+ @streams.delete stream
19
17
  end
20
-
18
+
21
19
  def registered_stream? stream
22
- streams.include? stream
20
+ @streams.include? stream
23
21
  end
24
22
 
25
23
  def select_streams
26
- readables, _ = select [server, *streams]
24
+ readables, _ = select [server, *@streams]
27
25
 
28
26
  readables.each do |readable|
29
27
  case readable
@@ -22,12 +22,12 @@ module Funl
22
22
  def self.new *a
23
23
  if self == MessageSequencer
24
24
  require 'funl/message-sequencer-select'
25
- MessageSequencerSelect.new *a
25
+ MessageSequencerSelect.new(*a)
26
26
  else
27
27
  super
28
28
  end
29
29
  end
30
-
30
+
31
31
  def initialize server, *conns, log: Logger.new($stderr),
32
32
  stream_type: ObjectStream::MSGPACK_TYPE,
33
33
  message_class: Message,
@@ -47,7 +47,7 @@ module Funl
47
47
  conns.each do |conn|
48
48
  try_conn conn
49
49
  end
50
-
50
+
51
51
  @subscribers_to_all = [] # [conn, ...]
52
52
  @subscribers = Hash.new {|h, tag| h[tag] = []} # tag => [conn, ...]
53
53
  @tags = Hash.new {|h, conn| h[conn] = []} # conn => [tag, ...]
@@ -72,7 +72,7 @@ module Funl
72
72
  def wait
73
73
  server_thread.join
74
74
  end
75
-
75
+
76
76
  def run
77
77
  loop do
78
78
  select_streams
@@ -130,7 +130,7 @@ module Funl
130
130
  case op_type
131
131
  when SUBSCRIBE_ALL
132
132
  @subscribers_to_all |= [stream]
133
-
133
+
134
134
  when SUBSCRIBE
135
135
  tags.each do |tag|
136
136
  @subscribers[tag] |= [stream]
@@ -26,16 +26,16 @@ module Funl
26
26
 
27
27
  # Application-defined payload data. See blobber.rb.
28
28
  attr_accessor :blob
29
-
29
+
30
30
  def initialize(*args)
31
31
  @client_id, @local_tick, @global_tick, @delta, @tags, @blob = *args
32
32
  end
33
-
33
+
34
34
  def self.[](
35
35
  client: nil, local: nil, global: nil, delta: nil, tags: nil, blob: nil)
36
36
  new client, local, global, delta, tags, blob
37
37
  end
38
-
38
+
39
39
  def self.control op_type, *args
40
40
  Message.new.tap {|m| m.client_id = [op_type, *args]}
41
41
  end
@@ -44,7 +44,7 @@ module Funl
44
44
  def control?
45
45
  @client_id.kind_of? Array
46
46
  end
47
-
47
+
48
48
  # Array of [op_type, *args] for the control operation.
49
49
  def control_op
50
50
  @client_id
@@ -60,7 +60,7 @@ module Funl
60
60
  ].join(", ")
61
61
  "<Message: #{s}#{t}>"
62
62
  end
63
-
63
+
64
64
  def to_a
65
65
  [@client_id, @local_tick, @global_tick, @delta, @tags, @blob]
66
66
  end
@@ -75,11 +75,11 @@ module Funl
75
75
  @blob = other.blob
76
76
  end
77
77
  alias eql? ==
78
-
78
+
79
79
  def hash
80
80
  @client_id.hash ^ @local_tick.hash ^ @global_tick.hash
81
81
  end
82
-
82
+
83
83
  # Call with Packer, nil, or IO. If +pk+ is nil, returns string. If +pk+ is
84
84
  # a Packer, returns the Packer, which will need to be flushed. If +pk+ is
85
85
  # IO, returns nil.
@@ -94,28 +94,28 @@ module Funl
94
94
  pk.write @tags
95
95
  pk.write @blob
96
96
  return pk
97
-
97
+
98
98
  else # nil or IO
99
99
  MessagePack.pack(self, pk)
100
100
  end
101
101
  end
102
-
102
+
103
103
  def to_json
104
104
  to_a.to_json
105
105
  end
106
106
 
107
107
  def self.from_serialized ary
108
- new *ary
108
+ new(*ary)
109
109
  end
110
110
 
111
111
  def self.from_msgpack(src)
112
112
  case src
113
113
  when MessagePack::Unpacker
114
114
  new(*src.read)
115
-
115
+
116
116
  when IO, StringIO
117
117
  from_msgpack(MessagePack::Unpacker.new(src))
118
-
118
+
119
119
  else # String
120
120
  from_msgpack(MessagePack::Unpacker.new.feed(src))
121
121
  end
@@ -25,7 +25,7 @@ module Funl
25
25
  end
26
26
  end
27
27
  end
28
-
28
+
29
29
  def message_server_stream_for io, type: stream_type, **opts
30
30
  ObjectStreamWrapper.new(io, type: type, **opts).tap do |stream|
31
31
  stream.consume do |h|
@@ -6,7 +6,7 @@ module Funl
6
6
  class SubscriptionTracker
7
7
  attr_reader :client
8
8
  attr_reader :subscribed_all
9
-
9
+
10
10
  def subscribed_tags
11
11
  @subscribed_tags.dup
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Funl
2
- VERSION = "0.9"
2
+ VERSION = "0.10"
3
3
  end
@@ -13,11 +13,11 @@ class TestClientSequencer < Minitest::Test
13
13
  @log = Logger.new($stderr)
14
14
  log.level = Logger::WARN
15
15
  end
16
-
16
+
17
17
  def teardown
18
18
  FileUtils.remove_entry @dir
19
19
  end
20
-
20
+
21
21
  def test_initial_conns
22
22
  as = []; bs = []
23
23
  3.times {a, b = UNIXSocket.pair; as << a; bs << b}
@@ -28,7 +28,7 @@ class TestClientSequencer < Minitest::Test
28
28
  assert_equal i, client_id
29
29
  end
30
30
  end
31
-
31
+
32
32
  def test_later_conns
33
33
  svr = UNIXServer.new(@path)
34
34
  cseq = Funl::ClientSequencer.new svr, log: log
@@ -22,31 +22,31 @@ class TestClient < Minitest::Test
22
22
  @cseq_sock = UNIXServer.new(@cseq_path)
23
23
  @cseq = ClientSequencer.new @cseq_sock, log: log
24
24
  @cseq.start
25
-
25
+
26
26
  @seq_sock = UNIXServer.new(@seq_path)
27
27
  @seq = MessageSequencer.new @seq_sock, log: log
28
28
  @seq.start
29
-
29
+
30
30
  @client = Client.new(
31
31
  seq: UNIXSocket.new(@seq_path),
32
32
  cseq: UNIXSocket.new(@cseq_path),
33
33
  log: log)
34
-
34
+
35
35
  @client.start
36
36
  end
37
-
37
+
38
38
  def teardown
39
39
  cseq.stop rescue nil
40
40
  seq.stop rescue nil
41
41
  FileUtils.remove_entry @dir
42
42
  end
43
-
43
+
44
44
  def test_client_state_at_start
45
45
  assert_equal(0, client.client_id)
46
46
  assert_equal(0, client.start_tick)
47
47
  assert_equal(Funl::Blobber::MSGPACK_TYPE, client.blob_type)
48
48
  end
49
-
49
+
50
50
  def test_subscription_tracking
51
51
  Thread.new do
52
52
  client.subscribe ["foo"]
@@ -55,7 +55,7 @@ class TestClient < Minitest::Test
55
55
  ack = client.seq.read
56
56
  assert ack.control?
57
57
  assert_equal 0, ack.global_tick
58
-
58
+
59
59
  assert_equal [], client.subscribed_tags
60
60
  client.handle_ack ack
61
61
  Thread.pass
@@ -68,7 +68,7 @@ class TestClient < Minitest::Test
68
68
  ack = client.seq.read
69
69
  assert ack.control?
70
70
  assert_equal 0, ack.global_tick
71
-
71
+
72
72
  assert_equal ["foo"], client.subscribed_tags
73
73
  client.handle_ack ack
74
74
  Thread.pass
@@ -81,7 +81,7 @@ class TestClient < Minitest::Test
81
81
  ack = client.seq.read
82
82
  assert ack.control?
83
83
  assert_equal 0, ack.global_tick
84
-
84
+
85
85
  assert_equal false, client.subscribed_all
86
86
  client.handle_ack ack
87
87
  Thread.pass
@@ -93,7 +93,7 @@ class TestClient < Minitest::Test
93
93
  ack = client.seq.read
94
94
  assert ack.control?
95
95
  assert_equal 0, ack.global_tick
96
-
96
+
97
97
  assert_equal true, client.subscribed_all
98
98
  client.handle_ack ack
99
99
  Thread.pass
@@ -17,7 +17,7 @@ require 'minitest/autorun'
17
17
 
18
18
  class TestMessageSequencer < Minitest::Test
19
19
  attr_reader :log
20
-
20
+
21
21
  def mseq_class; MessageSequencer; end
22
22
 
23
23
  def setup
@@ -27,11 +27,11 @@ class TestMessageSequencer < Minitest::Test
27
27
  log.level = Logger::WARN
28
28
  @n_clients = 3
29
29
  end
30
-
30
+
31
31
  def teardown
32
32
  FileUtils.remove_entry @dir
33
33
  end
34
-
34
+
35
35
  def test_initial_conns
36
36
  as = []; bs = []
37
37
  @n_clients.times {a, b = UNIXSocket.pair; as << a; bs << b}
@@ -43,7 +43,7 @@ class TestMessageSequencer < Minitest::Test
43
43
  assert_equal 0, global_tick
44
44
  end
45
45
  end
46
-
46
+
47
47
  def test_later_conns
48
48
  stream_type = ObjectStream::MSGPACK_TYPE
49
49
  svr = UNIXServer.new(@path)
@@ -53,7 +53,7 @@ class TestMessageSequencer < Minitest::Test
53
53
  mseq.start
54
54
  sleep
55
55
  end
56
-
56
+
57
57
  log.progname = "client"
58
58
  streams = (0...@n_clients).map do
59
59
  conn = UNIXSocket.new(@path)
@@ -70,30 +70,30 @@ class TestMessageSequencer < Minitest::Test
70
70
 
71
71
  stream
72
72
  end
73
-
73
+
74
74
  m1 = Message[
75
75
  client: 0, local: 12, global: 34,
76
76
  delta: 1, tags: ["foo"], blob: "BLOB"]
77
77
  send_msg(src: streams[0], message: m1, dst: streams, expected_tick: 1)
78
-
78
+
79
79
  if @n_clients > 1
80
80
  m2 = Message[
81
81
  client: 1, local: 23, global: 45,
82
82
  delta: 4, tags: ["bar"], blob: "BLOB"]
83
83
  send_msg(src: streams[1], message: m2, dst: streams, expected_tick: 2)
84
84
  end
85
-
85
+
86
86
  ensure
87
87
  Process.kill "TERM", pid if pid
88
88
  end
89
89
 
90
90
  def send_msg(src: nil, message: nil, dst: nil, expected_tick: nil)
91
91
  src << message
92
-
92
+
93
93
  replies = dst.map do |stream|
94
94
  stream.read
95
95
  end
96
-
96
+
97
97
  assert_equal @n_clients, replies.size
98
98
 
99
99
  replies.each do |r|
@@ -7,7 +7,7 @@ require 'minitest/autorun'
7
7
 
8
8
  class TestMessage < Minitest::Test
9
9
  attr_reader :m, :sio
10
-
10
+
11
11
  def setup
12
12
  @m = Funl::Message.new
13
13
  m.client_id = 12
@@ -17,55 +17,55 @@ class TestMessage < Minitest::Test
17
17
  m.tags = [ "aaa", "bbb" ]
18
18
  m.blob = "BLOB"
19
19
  end
20
-
20
+
21
21
  def test_from_serialized
22
22
  a = m.to_a
23
23
  m2 = Funl::Message.from_serialized a
24
24
  assert_equal(m, m2)
25
25
  end
26
-
26
+
27
27
  def test_to_msgpack
28
28
  assert_kind_of(String, m.to_msgpack(nil))
29
29
  assert_kind_of(String, m.to_msgpack)
30
30
  assert_equal(MessagePack.pack(m), m.to_msgpack(nil))
31
31
  assert_equal(MessagePack.pack(m), m.to_msgpack)
32
32
  end
33
-
33
+
34
34
  def test_to_msgpack_packer
35
35
  pk = MessagePack::Packer.new
36
36
  assert_kind_of(MessagePack::Packer, m.to_msgpack(pk))
37
37
  assert_equal(pk, m.to_msgpack(pk))
38
38
  end
39
-
39
+
40
40
  def test_to_msgpack_io
41
41
  src, dst = UNIXSocket.pair
42
42
  assert_nil(m.to_msgpack(src))
43
43
  src.close
44
44
  assert_equal(MessagePack.pack(m), dst.read)
45
45
  end
46
-
46
+
47
47
  def test_pack_io
48
48
  src, dst = UNIXSocket.pair
49
49
  MessagePack.pack(m, src)
50
50
  src.close
51
51
  assert_equal(MessagePack.pack(m), dst.read)
52
52
  end
53
-
53
+
54
54
  def test_pack_unpack
55
55
  assert_equal(m.to_a, MessagePack.unpack(MessagePack.pack(m)))
56
56
  end
57
-
57
+
58
58
  def test_from_msgpack_str
59
59
  assert_equal(m, Funl::Message.from_msgpack(MessagePack.pack(m)))
60
60
  end
61
-
61
+
62
62
  def test_from_msgpack_stringio
63
63
  sio = StringIO.new
64
64
  MessagePack.pack(m, sio)
65
65
  sio.rewind
66
66
  assert_equal(m, Funl::Message.from_msgpack(sio))
67
67
  end
68
-
68
+
69
69
  def test_from_msgpack_io
70
70
  src, dst = UNIXSocket.pair
71
71
  MessagePack.pack(m, src)
@@ -11,7 +11,7 @@ class TestReflect < Minitest::Test
11
11
  def setup
12
12
  @log = Logger.new($stderr)
13
13
  log.level = Logger::WARN
14
-
14
+
15
15
  client_socks = []
16
16
  server_socks = []
17
17
  2.times do
@@ -19,21 +19,21 @@ class TestReflect < Minitest::Test
19
19
  client_socks << cl
20
20
  server_socks << sv
21
21
  end
22
-
22
+
23
23
  dummy, _ = UNIXSocket.pair
24
24
 
25
25
  @mseq = MessageSequencer.new dummy, *server_socks, log: log
26
26
  mseq.start
27
-
27
+
28
28
  @streams = client_socks.each_with_index.map do |s,i|
29
29
  stream = ObjectStreamWrapper.new(s, type: mseq.stream_type)
30
30
  stream.write_to_outbox({"client_id" => "client #{i}"})
31
- global_tick = stream.read["tick"]
31
+ stream.read["tick"]
32
32
  stream.expect Message
33
33
  stream
34
34
  end
35
35
  end
36
-
36
+
37
37
  def teardown
38
38
  mseq.stop rescue nil
39
39
  end
@@ -45,14 +45,14 @@ class TestReflect < Minitest::Test
45
45
  assert ack.control?
46
46
  assert_equal 0, ack.global_tick
47
47
  reflect = true
48
-
48
+
49
49
  snd << Message[
50
50
  client: 0, local: 1, global: 0, delta: 1,
51
51
  tags: [reflect, "bar"], blob: ""]
52
52
  snd << Message[
53
53
  client: 0, local: 2, global: 0, delta: 2,
54
54
  tags: [reflect, "foo"], blob: ""]
55
-
55
+
56
56
  m = rcv.read
57
57
  assert_equal 2, m.global_tick
58
58
  assert_equal ["foo"], m.tags
@@ -7,7 +7,7 @@ require 'minitest/autorun'
7
7
 
8
8
  class TestStream < Minitest::Test
9
9
  include Funl::Stream
10
-
10
+
11
11
  attr_reader :client_id
12
12
  attr_reader :stream_type
13
13
  attr_reader :message_class
@@ -23,16 +23,16 @@ class TestStream < Minitest::Test
23
23
 
24
24
  @sio = StringIO.new
25
25
  end
26
-
26
+
27
27
  def test_greeting
28
28
  client = client_stream_for @sio
29
29
  client.write "message"
30
-
30
+
31
31
  @sio.rewind
32
32
 
33
33
  server = server_stream_for @sio
34
34
  m = server.read
35
-
35
+
36
36
  assert_equal "message", m
37
37
  assert_equal "client #{client_id}", server.peer_name
38
38
  end
@@ -11,7 +11,7 @@ class TestSubscribe < Minitest::Test
11
11
  def setup
12
12
  @log = Logger.new($stderr)
13
13
  log.level = Logger::WARN
14
-
14
+
15
15
  client_socks = []
16
16
  server_socks = []
17
17
  2.times do
@@ -19,21 +19,21 @@ class TestSubscribe < Minitest::Test
19
19
  client_socks << cl
20
20
  server_socks << sv
21
21
  end
22
-
22
+
23
23
  dummy, _ = UNIXSocket.pair
24
24
 
25
25
  @mseq = MessageSequencer.new dummy, *server_socks, log: log
26
26
  mseq.start
27
-
27
+
28
28
  @streams = client_socks.each_with_index.map do |s,i|
29
29
  stream = ObjectStreamWrapper.new(s, type: mseq.stream_type)
30
30
  stream.write_to_outbox({"client_id" => "client #{i}"})
31
- global_tick = stream.read["tick"]
31
+ stream.read["tick"]
32
32
  stream.expect Message
33
33
  stream
34
34
  end
35
35
  end
36
-
36
+
37
37
  def teardown
38
38
  mseq.stop rescue nil
39
39
  end
@@ -44,19 +44,19 @@ class TestSubscribe < Minitest::Test
44
44
  ack = rcv.read
45
45
  assert ack.control?
46
46
  assert_equal 0, ack.global_tick
47
-
47
+
48
48
  snd << Message[
49
49
  client: 0, local: 0, global: 0, delta: 1,
50
50
  tags: ["bar"], blob: ""]
51
51
  snd << Message[
52
52
  client: 0, local: 0, global: 0, delta: 2,
53
53
  tags: ["foo"], blob: ""]
54
-
54
+
55
55
  m = rcv.read
56
56
  assert_equal 2, m.global_tick
57
57
  assert_equal ["foo"], m.tags
58
58
  end
59
-
59
+
60
60
  def test_multiple_tag
61
61
  snd, rcv = @streams
62
62
  rcv << Message.control(SUBSCRIBE, ["foo", "bar"])
@@ -64,14 +64,14 @@ class TestSubscribe < Minitest::Test
64
64
  assert ack.control?
65
65
  assert_equal 0, ack.global_tick
66
66
  assert_equal ["foo", "bar"], ack.control_op[1]
67
-
67
+
68
68
  snd << Message[
69
69
  client: 0, local: 0, global: 0, delta: 1,
70
70
  tags: ["bar"], blob: ""]
71
71
  snd << Message[
72
72
  client: 0, local: 0, global: 0, delta: 2,
73
73
  tags: ["foo"], blob: ""]
74
-
74
+
75
75
  m = rcv.read
76
76
  assert_equal 1, m.global_tick
77
77
  assert_equal ["bar"], m.tags
@@ -79,9 +79,9 @@ class TestSubscribe < Minitest::Test
79
79
  assert_equal 2, m.global_tick
80
80
  assert_equal ["foo"], m.tags
81
81
  end
82
-
82
+
83
83
  def test_multiple_receiver
84
- snd, rcv = @streams
84
+ snd, rcv = @streams; rcv = nil
85
85
  @streams.each do |stream|
86
86
  stream << Message.control(SUBSCRIBE, ["foo"])
87
87
  ack = stream.read
@@ -89,11 +89,11 @@ class TestSubscribe < Minitest::Test
89
89
  assert_equal 0, ack.global_tick
90
90
  assert_equal ["foo"], ack.control_op[1]
91
91
  end
92
-
92
+
93
93
  snd << Message[
94
94
  client: 0, local: 0, global: 0, delta: 1,
95
95
  tags: ["foo"], blob: ""]
96
-
96
+
97
97
  @streams.each do |stream|
98
98
  m = stream.read
99
99
  assert_equal 1, m.global_tick
@@ -108,11 +108,11 @@ class TestSubscribe < Minitest::Test
108
108
  assert ack.control?
109
109
  assert_equal 0, ack.global_tick
110
110
  assert_equal ["foo"], ack.control_op[1]
111
-
111
+
112
112
  snd << Message[
113
113
  client: 0, local: 0, global: 0, delta: 1,
114
114
  tags: ["foo"], blob: ""]
115
-
115
+
116
116
  m = rcv.read
117
117
  assert_equal 1, m.global_tick
118
118
  assert_equal ["foo"], m.tags
@@ -122,27 +122,27 @@ class TestSubscribe < Minitest::Test
122
122
  assert ack.control?
123
123
  assert_equal 1, ack.global_tick
124
124
  assert_equal ["foo"], ack.control_op[1]
125
-
125
+
126
126
  snd << Message[
127
127
  client: 0, local: 0, global: 0, delta: 1,
128
128
  tags: ["foo"], blob: ""]
129
129
  Thread.pass
130
-
130
+
131
131
  rcv << Message.control(SUBSCRIBE, ["foo"])
132
132
  ack = rcv.read
133
133
  assert ack.control?
134
134
  assert_equal 2, ack.global_tick
135
135
  assert_equal ["foo"], ack.control_op[1]
136
-
136
+
137
137
  snd << Message[
138
138
  client: 0, local: 0, global: 0, delta: 1,
139
139
  tags: ["foo"], blob: ""]
140
-
140
+
141
141
  m = rcv.read
142
142
  assert_equal 3, m.global_tick
143
143
  assert_equal ["foo"], m.tags
144
144
  end
145
-
145
+
146
146
  def test_subscribe_all
147
147
  snd, rcv = @streams
148
148
  rcv << Message.control(SUBSCRIBE_ALL)
@@ -150,11 +150,11 @@ class TestSubscribe < Minitest::Test
150
150
  assert ack.control?
151
151
  assert_equal 0, ack.global_tick
152
152
  assert_equal nil, ack.control_op[1]
153
-
153
+
154
154
  snd << Message[
155
155
  client: 0, local: 0, global: 0, delta: 1,
156
156
  tags: ["foo"], blob: ""]
157
-
157
+
158
158
  m = rcv.read
159
159
  assert_equal 1, m.global_tick
160
160
  assert_equal ["foo"], m.tags
@@ -164,27 +164,27 @@ class TestSubscribe < Minitest::Test
164
164
  assert ack.control?
165
165
  assert_equal 1, ack.global_tick
166
166
  assert_equal nil, ack.control_op[1]
167
-
167
+
168
168
  snd << Message[
169
169
  client: 0, local: 0, global: 0, delta: 1,
170
170
  tags: ["foo"], blob: ""]
171
171
  Thread.pass
172
-
172
+
173
173
  rcv << Message.control(SUBSCRIBE_ALL)
174
174
  ack = rcv.read
175
175
  assert ack.control?
176
176
  assert_equal 2, ack.global_tick
177
177
  assert_equal nil, ack.control_op[1]
178
-
178
+
179
179
  snd << Message[
180
180
  client: 0, local: 0, global: 0, delta: 1,
181
181
  tags: ["foo"], blob: ""]
182
-
182
+
183
183
  m = rcv.read
184
184
  assert_equal 3, m.global_tick
185
185
  assert_equal ["foo"], m.tags
186
186
  end
187
-
187
+
188
188
  def test_redundant_subscribe
189
189
  snd, rcv = @streams
190
190
  2.times do
@@ -192,19 +192,19 @@ class TestSubscribe < Minitest::Test
192
192
  ack = rcv.read
193
193
  assert ack.control?
194
194
  end
195
-
195
+
196
196
  snd << Message[
197
197
  client: 0, local: 0, global: 0, delta: 1,
198
198
  tags: ["foo"], blob: "1"]
199
199
  snd << Message[
200
200
  client: 0, local: 0, global: 0, delta: 2,
201
201
  tags: ["foo"], blob: "2"]
202
-
202
+
203
203
  m = rcv.read
204
204
  assert_equal 1, m.global_tick
205
205
  assert_equal ["foo"], m.tags
206
206
  assert_equal "1", m.blob
207
-
207
+
208
208
  m = rcv.read
209
209
  assert_equal 2, m.global_tick
210
210
  assert_equal ["foo"], m.tags
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funl
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel VanderWerf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: object-stream
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.0'
41
41
  description: Sequences messages.
42
42
  email: vjoel@users.sourceforge.net
43
43
  executables: []
@@ -88,9 +88,9 @@ require_paths:
88
88
  - lib
89
89
  required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ">="
91
+ - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: '0'
93
+ version: '2.0'
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ">="
@@ -98,17 +98,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.2.2
101
+ rubygems_version: 2.4.1
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Sequences messages
105
105
  test_files:
106
- - test/test-message-sequencer.rb
107
- - test/test-client-sequencer.rb
108
106
  - test/test-reflect.rb
109
- - test/test-message.rb
110
107
  - test/test-stream.rb
108
+ - test/test-message.rb
109
+ - test/test-message-sequencer.rb
111
110
  - test/test-subscribe.rb
112
111
  - test/test-client.rb
112
+ - test/test-client-sequencer.rb
113
113
  - test/test-blobber.rb
114
114
  has_rdoc: