em-zmq-tp10 0.1.17 → 0.1.18
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 +7 -0
 - data/README.md +157 -146
 - data/lib/em/protocols/zmq2/socket.rb +5 -1
 - data/lib/em/protocols/zmq2/version.rb +1 -1
 - metadata +16 -22
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: be62a1ea0af2e99a3b6a974a2a3e2da94d4a548b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e11e1a7b60f8736e5686dc16a3b735e7c5292bc4
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8fbde09f3e2ae2d9fc1912365c7fcbdc66abc7ea72a9113d8e3a0aa834fe7a1bd9314ee92759cf11c15faa79103a99262610e4950137cd0cbc9ceaa032105094
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 67e2778866ed15fac8c1ce186a4b0d0f7b47be93958319c5d8377743fe73cc1992ab97ccfb69dd280640fdf59fad71c93263a5b4338653a522f613ab98257916
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -48,95 +48,99 @@ And you could do any crazy thing using base `EM::Protocols::Zmq2::Socket` class 
     | 
|
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
            ### Dealer
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 52 
     | 
    
         
            +
            class MyPreDealer < EM::Protocols::Zmq2::PreDealer
         
     | 
| 
      
 53 
     | 
    
         
            +
              def receive_message(message)
         
     | 
| 
      
 54 
     | 
    
         
            +
                puts "Message received: #{message.inspect}"
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
      
 57 
     | 
    
         
            +
            dealer = MyPreDealer.new
         
     | 
| 
      
 58 
     | 
    
         
            +
            dealer.connect('tcp://127.0.0.1:8000')
         
     | 
| 
      
 59 
     | 
    
         
            +
            dealer.bind('unix://dealer.sock')
         
     | 
| 
      
 60 
     | 
    
         
            +
            EM.schedule {
         
     | 
| 
      
 61 
     | 
    
         
            +
              if !dealer.send_message(['asdf','fdas'])
         
     | 
| 
      
 62 
     | 
    
         
            +
                puts "Could not send message (no free peers)"
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
            }
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            class MyDealer < EM::Protocols::Zmq2::Dealer
         
     | 
| 
      
 67 
     | 
    
         
            +
              def receive_message(message)
         
     | 
| 
      
 68 
     | 
    
         
            +
                puts "Message received: #{message.inspect}"
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
            end
         
     | 
| 
      
 71 
     | 
    
         
            +
            dealer = MyDealer.new(hwm: 1000, hwm_strategy: :drop_last)
         
     | 
| 
      
 72 
     | 
    
         
            +
            dealer.connect('tcp://127.0.0.1:8000')
         
     | 
| 
      
 73 
     | 
    
         
            +
            EM.schedule {
         
     | 
| 
      
 74 
     | 
    
         
            +
              if !dealer.send_message(['asdf','fdas'])
         
     | 
| 
      
 75 
     | 
    
         
            +
                puts "No free peers and outgoing queue is full"
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
            }
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            dealer = EM::Protocols::Zmq2::DealerCb.new do |message|
         
     | 
| 
      
 80 
     | 
    
         
            +
               puts "Receive message #{message.inspect}"
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
      
 82 
     | 
    
         
            +
            dealer.connect('ipc://rep')
         
     | 
| 
      
 83 
     | 
    
         
            +
            EM.schedule {
         
     | 
| 
      
 84 
     | 
    
         
            +
              dealer.send_message(['hello','world'])
         
     | 
| 
      
 85 
     | 
    
         
            +
            }
         
     | 
| 
      
 86 
     | 
    
         
            +
            ```
         
     | 
| 
       85 
87 
     | 
    
         | 
| 
       86 
88 
     | 
    
         
             
            ### Req
         
     | 
| 
       87 
89 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
      
 90 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 91 
     | 
    
         
            +
            class MyPreReq < EM::Protocols::Zmq2::PreReq
         
     | 
| 
      
 92 
     | 
    
         
            +
              def receive_reply(message, data, request_id)
         
     | 
| 
      
 93 
     | 
    
         
            +
                puts "Received message #{message} and stored data #{data}"
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
            end
         
     | 
| 
      
 96 
     | 
    
         
            +
            req = MyPreReq.new
         
     | 
| 
      
 97 
     | 
    
         
            +
            req.bind(...)
         
     | 
| 
      
 98 
     | 
    
         
            +
            req.connect(...)
         
     | 
| 
      
 99 
     | 
    
         
            +
            if request_id = req.send_request(['this is', 'message'], 'saved_data')
         
     | 
| 
      
 100 
     | 
    
         
            +
              puts "Message sent"
         
     | 
| 
      
 101 
     | 
    
         
            +
            else
         
     | 
| 
      
 102 
     | 
    
         
            +
              puts "there is no free peer"
         
     | 
| 
      
 103 
     | 
    
         
            +
            end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
            class MyReq < EM::Protocols::Zmq2::PreReq
         
     | 
| 
      
 106 
     | 
    
         
            +
              def receive_reply(message, data, request_id)
         
     | 
| 
      
 107 
     | 
    
         
            +
                puts "Received message #{message} and stored data #{data}"
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
            end
         
     | 
| 
      
 110 
     | 
    
         
            +
            req = MyReq.new
         
     | 
| 
      
 111 
     | 
    
         
            +
            req.bind(...)
         
     | 
| 
      
 112 
     | 
    
         
            +
            req.connect(...)
         
     | 
| 
      
 113 
     | 
    
         
            +
            if request_id = req.send_request(['hi'], 'ho')
         
     | 
| 
      
 114 
     | 
    
         
            +
              puts "Message sent"
         
     | 
| 
      
 115 
     | 
    
         
            +
            end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            req = EM::Protocols::Zmq2::ReqCb.new
         
     | 
| 
      
 118 
     | 
    
         
            +
            req.bind('ipc://req')
         
     | 
| 
      
 119 
     | 
    
         
            +
            timer = nil
         
     | 
| 
      
 120 
     | 
    
         
            +
            request_id = req.send_request(['hello', 'world']) do |message|
         
     | 
| 
      
 121 
     | 
    
         
            +
              EM.cancel_timer(timer)
         
     | 
| 
      
 122 
     | 
    
         
            +
              puts "Message #{message}"
         
     | 
| 
      
 123 
     | 
    
         
            +
            end
         
     | 
| 
      
 124 
     | 
    
         
            +
            if request_id
         
     | 
| 
      
 125 
     | 
    
         
            +
              timer = EM.add_timer(1) {
         
     | 
| 
      
 126 
     | 
    
         
            +
                req.cancel_request(request_id)
         
     | 
| 
      
 127 
     | 
    
         
            +
              }
         
     | 
| 
      
 128 
     | 
    
         
            +
            end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
            req = EM::Protocols::Zmq2::ReqDefer.new
         
     | 
| 
      
 131 
     | 
    
         
            +
            req.bind('ipc://req')
         
     | 
| 
      
 132 
     | 
    
         
            +
            data = {hi: 'ho'}
         
     | 
| 
      
 133 
     | 
    
         
            +
            deferable = req.send_request(['hello', 'world'], data) do |reply, data|
         
     | 
| 
      
 134 
     | 
    
         
            +
              puts "Reply received #{reply} #{data}"
         
     | 
| 
      
 135 
     | 
    
         
            +
            end
         
     | 
| 
      
 136 
     | 
    
         
            +
            deferable.timeout 1
         
     | 
| 
      
 137 
     | 
    
         
            +
            deferable.errback do
         
     | 
| 
      
 138 
     | 
    
         
            +
              puts "Message canceled"
         
     | 
| 
      
 139 
     | 
    
         
            +
            end
         
     | 
| 
      
 140 
     | 
    
         
            +
            deferable.callback do |reply, data|
         
     | 
| 
      
 141 
     | 
    
         
            +
              puts "Another callback #{reply} #{data}"
         
     | 
| 
      
 142 
     | 
    
         
            +
            end
         
     | 
| 
      
 143 
     | 
    
         
            +
            ```
         
     | 
| 
       140 
144 
     | 
    
         | 
| 
       141 
145 
     | 
    
         
             
            ### Router
         
     | 
| 
       142 
146 
     | 
    
         | 
| 
         @@ -144,51 +148,55 @@ Router stores peer identity in a message, as ZMQ router do. 
     | 
|
| 
       144 
148 
     | 
    
         
             
            And it sends message to a peer, which idenitity equals to first message string.
         
     | 
| 
       145 
149 
     | 
    
         
             
            `PreRouter` does no any queue caching, `Router` saves message in queue per peer, controlled by highwatermark strategy.
         
     | 
| 
       146 
150 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
      
 151 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 152 
     | 
    
         
            +
            class MyPreRouter < EM::Protocols::Zmq2::PreRouter
         
     | 
| 
      
 153 
     | 
    
         
            +
              def receive_message(message)
         
     | 
| 
      
 154 
     | 
    
         
            +
                puts "Received message #{message} (and it contains envelope)"
         
     | 
| 
      
 155 
     | 
    
         
            +
              end
         
     | 
| 
      
 156 
     | 
    
         
            +
            end
         
     | 
| 
      
 157 
     | 
    
         
            +
            router = MyPreRouter.new
         
     | 
| 
      
 158 
     | 
    
         
            +
            router.bind(...)
         
     | 
| 
      
 159 
     | 
    
         
            +
            router.send_message(message)
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
            class MyRouter < EM::Protocols::Zmq2::Router
         
     | 
| 
      
 162 
     | 
    
         
            +
              def receive_message(message)
         
     | 
| 
      
 163 
     | 
    
         
            +
                puts "Received message #{message}"
         
     | 
| 
      
 164 
     | 
    
         
            +
                message[-1] = 'reply'
         
     | 
| 
      
 165 
     | 
    
         
            +
                send_message(message)
         
     | 
| 
      
 166 
     | 
    
         
            +
              end
         
     | 
| 
      
 167 
     | 
    
         
            +
            end
         
     | 
| 
      
 168 
     | 
    
         
            +
            router = MyPreRouter.new(hwm: 1000, hwm_strategy: :drop_first)
         
     | 
| 
      
 169 
     | 
    
         
            +
            router.bind(...)
         
     | 
| 
      
 170 
     | 
    
         
            +
            router.send_message(message)
         
     | 
| 
      
 171 
     | 
    
         
            +
            ```
         
     | 
| 
       166 
172 
     | 
    
         | 
| 
       167 
173 
     | 
    
         
             
            ### Rep
         
     | 
| 
       168 
174 
     | 
    
         | 
| 
       169 
175 
     | 
    
         
             
            REP differs from Router mainly in methods signature.
         
     | 
| 
       170 
176 
     | 
    
         | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
      
 177 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 178 
     | 
    
         
            +
            class EchoBangPreRep < EM::Protocols::Zmq2::PreRep
         
     | 
| 
      
 179 
     | 
    
         
            +
              def receive_request(message, envelope)
         
     | 
| 
      
 180 
     | 
    
         
            +
                message << "!"
         
     | 
| 
      
 181 
     | 
    
         
            +
                if send_reply(message, envelope)
         
     | 
| 
      
 182 
     | 
    
         
            +
                  puts "reply sent successfuly"
         
     | 
| 
      
 183 
     | 
    
         
            +
                end
         
     | 
| 
      
 184 
     | 
    
         
            +
              end
         
     | 
| 
      
 185 
     | 
    
         
            +
            end
         
     | 
| 
      
 186 
     | 
    
         
            +
            rep = EchoBangPreRep.new
         
     | 
| 
      
 187 
     | 
    
         
            +
            rep.bind('ipc://rep')
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
            class EchoBangRep < EM::Protocols::Zmq2::Rep
         
     | 
| 
      
 190 
     | 
    
         
            +
              def receive_request(message, envelope)
         
     | 
| 
      
 191 
     | 
    
         
            +
                message << "!"
         
     | 
| 
      
 192 
     | 
    
         
            +
                if send_reply(message, envelope)
         
     | 
| 
      
 193 
     | 
    
         
            +
                  puts "reply sent successfuly"
         
     | 
| 
      
 194 
     | 
    
         
            +
                end
         
     | 
| 
      
 195 
     | 
    
         
            +
              end
         
     | 
| 
      
 196 
     | 
    
         
            +
            end
         
     | 
| 
      
 197 
     | 
    
         
            +
            rep = EchoBangRep.new
         
     | 
| 
      
 198 
     | 
    
         
            +
            rep.bind('ipc://rep')
         
     | 
| 
      
 199 
     | 
    
         
            +
            ```
         
     | 
| 
       192 
200 
     | 
    
         | 
| 
       193 
201 
     | 
    
         
             
            ### Sub
         
     | 
| 
       194 
202 
     | 
    
         | 
| 
         @@ -197,19 +205,21 @@ Note that as in ZMQ 2.x filtering occurs on Sub side. 
     | 
|
| 
       197 
205 
     | 
    
         | 
| 
       198 
206 
     | 
    
         
             
            Since subscriptions could be defined with callback passed to `:subscribe` option, `subscribe` or `subscribe_many` methods, you could use this class without overloading.
         
     | 
| 
       199 
207 
     | 
    
         | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
             
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
      
 208 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 209 
     | 
    
         
            +
            class MySub < EM::Protocols::Zmq2::Sub
         
     | 
| 
      
 210 
     | 
    
         
            +
              def receive_message(message)
         
     | 
| 
      
 211 
     | 
    
         
            +
                puts "default handler"
         
     | 
| 
      
 212 
     | 
    
         
            +
              end
         
     | 
| 
      
 213 
     | 
    
         
            +
            end
         
     | 
| 
      
 214 
     | 
    
         
            +
            sub = MySub.new(subscribe: ['this', 'that'])
         
     | 
| 
      
 215 
     | 
    
         
            +
            sub.subscribe /^callback/i, do |message|
         
     | 
| 
      
 216 
     | 
    
         
            +
              puts "Callback subscribe #{message}"
         
     | 
| 
      
 217 
     | 
    
         
            +
            end
         
     | 
| 
      
 218 
     | 
    
         
            +
            sub.subscribe_many(
         
     | 
| 
      
 219 
     | 
    
         
            +
              proc{|s| s.end_with?("END")} => proc{|message| puts "TILL END #{message}"},
         
     | 
| 
      
 220 
     | 
    
         
            +
              '' => nil # also to default
         
     | 
| 
      
 221 
     | 
    
         
            +
            )
         
     | 
| 
      
 222 
     | 
    
         
            +
            ```
         
     | 
| 
       213 
223 
     | 
    
         | 
| 
       214 
224 
     | 
    
         
             
            ### Pub
         
     | 
| 
       215 
225 
     | 
    
         | 
| 
         @@ -219,14 +229,15 @@ Since subscriptions could be defined with callback passed to `:subscribe` option 
     | 
|
| 
       219 
229 
     | 
    
         | 
| 
       220 
230 
     | 
    
         
             
            Since there is no incoming data, there is no need to overload methods.
         
     | 
| 
       221 
231 
     | 
    
         | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
                  pub = EM::Protocols::Zmq2::Pub.new
         
     | 
| 
       227 
     | 
    
         
            -
                  pub.bind(...)
         
     | 
| 
       228 
     | 
    
         
            -
                  pub.send_message(['hi', 'you'])
         
     | 
| 
      
 232 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 233 
     | 
    
         
            +
            pub = EM::Protocols::Zmq2::PrePub.new
         
     | 
| 
      
 234 
     | 
    
         
            +
            pub.bind(...)
         
     | 
| 
      
 235 
     | 
    
         
            +
            pub.send_message(['hi', 'you'])
         
     | 
| 
       229 
236 
     | 
    
         | 
| 
      
 237 
     | 
    
         
            +
            pub = EM::Protocols::Zmq2::Pub.new
         
     | 
| 
      
 238 
     | 
    
         
            +
            pub.bind(...)
         
     | 
| 
      
 239 
     | 
    
         
            +
            pub.send_message(['hi', 'you'])
         
     | 
| 
      
 240 
     | 
    
         
            +
            ```
         
     | 
| 
       230 
241 
     | 
    
         | 
| 
       231 
242 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       232 
243 
     | 
    
         | 
| 
         @@ -12,7 +12,11 @@ module EM 
     | 
|
| 
       12 
12 
     | 
    
         
             
                    attr :identity, :hwm
         
     | 
| 
       13 
13 
     | 
    
         
             
                    attr_accessor :hwm_strategy
         
     | 
| 
       14 
14 
     | 
    
         
             
                    attr_accessor :do_balance
         
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
      
 15 
     | 
    
         
            +
                    if String.method_defined?(:b)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      GENERATED = '%GN%'.b.freeze
         
     | 
| 
      
 17 
     | 
    
         
            +
                    else
         
     | 
| 
      
 18 
     | 
    
         
            +
                      GENERATED = '%GN%'.force_encoding('BINARY').freeze
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
       16 
20 
     | 
    
         | 
| 
       17 
21 
     | 
    
         
             
                    # Accept options, which are dependend on socket type
         
     | 
| 
       18 
22 
     | 
    
         
             
                    # Common options are:
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,48 +1,43 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: em-zmq-tp10
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
              version: 0.1.17
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.18
         
     | 
| 
       6 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
7 
     | 
    
         
             
            - Sokolov Yura 'funny-falcon'
         
     | 
| 
       9 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-05-18 00:00:00.000000000 Z
         
     | 
| 
       13 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
     | 
    
         
            -
               
     | 
| 
      
 14 
     | 
    
         
            +
              name: eventmachine
         
     | 
| 
       16 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       17 
     | 
    
         
            -
                none: false
         
     | 
| 
       18 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
     | 
    
         
            -
                - -  
     | 
| 
      
 17 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       20 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       21 
19 
     | 
    
         
             
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
       22 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       23 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       24 
     | 
    
         
            -
                none: false
         
     | 
| 
       25 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       26 
     | 
    
         
            -
                - -  
     | 
| 
      
 24 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       27 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       28 
26 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       29 
     | 
    
         
            -
              name: eventmachine
         
     | 
| 
       30 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       31 
     | 
    
         
            -
               
     | 
| 
      
 28 
     | 
    
         
            +
              name: ffi-rzmq
         
     | 
| 
       32 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       33 
     | 
    
         
            -
                none: false
         
     | 
| 
       34 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       35 
     | 
    
         
            -
                - -  
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       36 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       37 
33 
     | 
    
         
             
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
       38 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       39 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       40 
     | 
    
         
            -
                none: false
         
     | 
| 
       41 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       42 
     | 
    
         
            -
                - -  
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       43 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       44 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       45 
     | 
    
         
            -
              name: ffi-rzmq
         
     | 
| 
       46 
41 
     | 
    
         
             
            description: Implementation of ZMQ2.x transport protocol - ZMTP1.0
         
     | 
| 
       47 
42 
     | 
    
         
             
            email:
         
     | 
| 
       48 
43 
     | 
    
         
             
            - funny.falcon@gmail.com
         
     | 
| 
         @@ -50,7 +45,7 @@ executables: [] 
     | 
|
| 
       50 
45 
     | 
    
         
             
            extensions: []
         
     | 
| 
       51 
46 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       52 
47 
     | 
    
         
             
            files:
         
     | 
| 
       53 
     | 
    
         
            -
            - .gitignore
         
     | 
| 
      
 48 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
       54 
49 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       55 
50 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       56 
51 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -81,27 +76,26 @@ files: 
     | 
|
| 
       81 
76 
     | 
    
         
             
            - tests/test_router.rb
         
     | 
| 
       82 
77 
     | 
    
         
             
            homepage: https://github.com/funny-falcon/em-zmq-tp10
         
     | 
| 
       83 
78 
     | 
    
         
             
            licenses: []
         
     | 
| 
      
 79 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
       84 
80 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       85 
81 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       86 
82 
     | 
    
         
             
            require_paths:
         
     | 
| 
       87 
83 
     | 
    
         
             
            - lib
         
     | 
| 
       88 
84 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       89 
     | 
    
         
            -
              none: false
         
     | 
| 
       90 
85 
     | 
    
         
             
              requirements:
         
     | 
| 
       91 
     | 
    
         
            -
              - -  
     | 
| 
      
 86 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       92 
87 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       93 
88 
     | 
    
         
             
                  version: 1.9.2
         
     | 
| 
       94 
89 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       95 
     | 
    
         
            -
              none: false
         
     | 
| 
       96 
90 
     | 
    
         
             
              requirements:
         
     | 
| 
       97 
     | 
    
         
            -
              - -  
     | 
| 
      
 91 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       98 
92 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       99 
93 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       100 
94 
     | 
    
         
             
            requirements: []
         
     | 
| 
       101 
95 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       102 
     | 
    
         
            -
            rubygems_version:  
     | 
| 
      
 96 
     | 
    
         
            +
            rubygems_version: 2.4.4
         
     | 
| 
       103 
97 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       104 
     | 
    
         
            -
            specification_version:  
     | 
| 
      
 98 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
       105 
99 
     | 
    
         
             
            summary: Implementation of ZMQ2.1 transport protocol and main socket types using EventMachine
         
     | 
| 
       106 
100 
     | 
    
         
             
              for managing TCP/UNIX connections, doing nonblocking writes and calling callback
         
     | 
| 
       107 
101 
     | 
    
         
             
              on incoming messages.
         
     |