Sha256: 8a44448da529f531cb739c7a41809532be19ab6889566a2da0528f5d1293617f

Contents?: true

Size: 497 Bytes

Versions: 5

Compression:

Stored size: 497 Bytes

Contents

# frozen_string_literal: true

module Zapp
  module SocketPipe
    class Receiver
      attr_reader(:pipe, :raw_tcp_pipe)

      def initialize(pipe:)
        @pipe = pipe
        @raw_tcp_pipe = Ractor.new(Zapp.config, name: "raw-tcp-pipe") do |config|
          server = TCPServer.new(config.host, config.port)

          loop do
            Ractor.yield(server.accept)
          end
        end
      end

      def take
        Ractor.select(pipe, raw_tcp_pipe)[1]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zapp-0.2.6 lib/zapp/socket_pipe/receiver.rb
zapp-0.2.5 lib/zapp/socket_pipe/receiver.rb
zapp-0.2.4 lib/zapp/socket_pipe/receiver.rb
zapp-0.2.3 lib/zapp/socket_pipe/receiver.rb
zapp-0.2.2 lib/zapp/socket_pipe/receiver.rb