em-zmq-tp10 0.1.9 → 0.1.10

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.
@@ -2,14 +2,20 @@ module EventMachine
2
2
  module Protocols
3
3
  module Zmq2
4
4
  module ConnectionMixin
5
+ # use watching on outbound queue when possible
6
+ # rely on https://github.com/eventmachine/eventmachine/pull/317 if were accepted
7
+ # or on https://github.com/funny-falcon/eventmachine/tree/sent_data
8
+ # use timers otherwise
5
9
  def sent_data
6
10
  @socket.peer_free(@peer_identity, self) if not_too_busy?
7
11
  end
8
12
 
9
13
  def not_too_busy?
10
- free = _not_too_busy?
11
- self.notify_when_free = !free
12
- free
14
+ !error? && (!@socket.do_balance || begin
15
+ free = _not_too_busy?
16
+ self.notify_when_free = !free
17
+ free
18
+ end)
13
19
  end
14
20
 
15
21
  def post_init
@@ -26,6 +32,7 @@ module EventMachine
26
32
  end
27
33
 
28
34
  def unbind
35
+ self.notify_when_free= false
29
36
  if @peer_identity
30
37
  @socket.unregister_peer(@peer_identity)
31
38
  end
@@ -11,6 +11,7 @@ module EM
11
11
  class Socket
12
12
  attr :identity, :hwm
13
13
  attr_accessor :hwm_strategy
14
+ attr_accessor :do_balance
14
15
  GENERATED = '%GN%'.freeze
15
16
 
16
17
  # Accept options, which are dependend on socket type
@@ -31,6 +32,7 @@ module EM
31
32
  @hwm = opts[:hwm] || HWM_INFINITY
32
33
  @hwm_strategy = opts[:hwm_strategy] || :drop_last
33
34
  @identity = opts[:identity] || EMPTY
35
+ @do_balance = opts.fetch(:do_balance, true)
34
36
  @peers = {}
35
37
  @free_peers = {}
36
38
  @connections = {}
@@ -41,30 +41,15 @@ module EventMachine
41
41
  #
42
42
  # It is not for end user usage
43
43
  class SocketConnection < EM::Connection
44
- include ConnectionMixin
45
44
  # :stopdoc:
45
+ include ConnectionMixin
46
+
46
47
  def initialize(socket)
47
48
  @socket = socket
48
49
  @recv_buffer = ''
49
50
  @recv_frames = [[]]
50
51
  end
51
52
 
52
- def unbind(err)
53
- self.notify_when_free= false
54
- if @peer_identity
55
- @socket.unregister_peer(@peer_identity)
56
- end
57
- @socket.not_connected(self)
58
- end
59
-
60
- # use watching on outbound queue when possible
61
- # rely on https://github.com/eventmachine/eventmachine/pull/317 if were accepted
62
- # or on https://github.com/funny-falcon/eventmachine/tree/sent_data
63
- # use timers otherwise
64
- def sent_data
65
- @socket.peer_free(@peer_identity, self) if not_too_busy?
66
- end
67
-
68
53
  if method_defined?(:outbound_data_count)
69
54
  def _not_too_busy?
70
55
  outbound_data_count < 32
@@ -91,13 +76,6 @@ module EventMachine
91
76
  end
92
77
  end
93
78
 
94
- def not_too_busy?
95
- unless error?
96
- free = _not_too_busy?
97
- self.notify_when_free = !free
98
- free
99
- end
100
- end
101
79
 
102
80
  def receive_data(data)
103
81
  parse_frames(data)
@@ -1,7 +1,7 @@
1
1
  module EventMachine
2
2
  module Protocols
3
3
  module Zmq2
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.10'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-zmq-tp10
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-01 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine