Class: Zapp::SocketPipe::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/zapp/socket_pipe/receiver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipe:) ⇒ Receiver

Returns a new instance of Receiver.



8
9
10
11
12
13
14
15
16
17
# File 'lib/zapp/socket_pipe/receiver.rb', line 8

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

Instance Attribute Details

#pipeObject (readonly)

Returns the value of attribute pipe.



6
7
8
# File 'lib/zapp/socket_pipe/receiver.rb', line 6

def pipe
  @pipe
end

#raw_tcp_pipeObject (readonly)

Returns the value of attribute raw_tcp_pipe.



6
7
8
# File 'lib/zapp/socket_pipe/receiver.rb', line 6

def raw_tcp_pipe
  @raw_tcp_pipe
end

Instance Method Details

#takeObject



19
20
21
# File 'lib/zapp/socket_pipe/receiver.rb', line 19

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