Sha256: ad4249c429f2b04b8627964271de26ab5aa6083b2accfc048c4ebee519d8e43f

Contents?: true

Size: 751 Bytes

Versions: 3

Compression:

Stored size: 751 Bytes

Contents

module DeadlySerious
  module Engine
    class SocketVentRecvr < SocketChannel

      attr_reader :io_name

      def initialize(name, _config)
        super
        @io_name = format('tcp://%s:%d', host, port)
        @minion = master.spawn_minion do |ctx, counter|
          socket = ctx.socket(:DEALER)
          socket.identity = format('%d:%d', Process.pid, counter)
          socket.connect(@io_name)
          socket
        end
      end

      def each
        return enum_for(:each) unless block_given?
        @minion.send('') # I'm ready!
        while (msg = @minion.recv) != END_MSG
          yield msg
          @minion.send('') # More msg, pls!
        end
      end

      def close
        @minion.explode
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deadly_serious-2.0.0.pre.rc3 lib/deadly_serious/engine/channel/socket/socket_vent_recvr.rb
deadly_serious-2.0.0.pre.rc2 lib/deadly_serious/engine/channel/socket/socket_vent_recvr.rb
deadly_serious-2.0.0.pre.rc1 lib/deadly_serious/engine/channel/socket/socket_vent_recvr.rb