Class: Zapp::SocketPipe::Receiver
- Inherits:
-
Object
- Object
- Zapp::SocketPipe::Receiver
- Defined in:
- lib/zapp/socket_pipe/receiver.rb
Instance Attribute Summary collapse
-
#pipe ⇒ Object
readonly
Returns the value of attribute pipe.
-
#raw_tcp_pipe ⇒ Object
readonly
Returns the value of attribute raw_tcp_pipe.
Instance Method Summary collapse
-
#initialize(pipe:) ⇒ Receiver
constructor
A new instance of Receiver.
- #take ⇒ Object
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
#pipe ⇒ Object (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_pipe ⇒ Object (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
#take ⇒ Object
19 20 21 |
# File 'lib/zapp/socket_pipe/receiver.rb', line 19 def take Ractor.select(pipe, raw_tcp_pipe)[1] end |