Class: Biryani::Stream
- Inherits:
-
Object
- Object
- Biryani::Stream
- Defined in:
- lib/biryani/stream.rb
Instance Attribute Summary collapse
-
#rx ⇒ Object
Returns the value of attribute rx.
Instance Method Summary collapse
-
#initialize(tx, stream_id, proc) ⇒ Stream
constructor
A new instance of Stream.
Constructor Details
#initialize(tx, stream_id, proc) ⇒ Stream
Returns a new instance of Stream.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/biryani/stream.rb', line 8 def initialize(tx, stream_id, proc) @rx = Ractor.new(tx, stream_id, proc) do |tx, stream_id, proc| unless (req = Ractor.recv).nil? res = HTTP::Response.default begin proc.call(req, res) res.validate rescue StandardError => e puts e.backtrace res = HTTP::Response.internal_server_error end tx.send([res, stream_id], move: true) end end end |
Instance Attribute Details
#rx ⇒ Object
Returns the value of attribute rx.
3 4 5 |
# File 'lib/biryani/stream.rb', line 3 def rx @rx end |