Class: HTTPX::Plugins::StreamBidi::Signal
- Inherits:
-
Object
- Object
- HTTPX::Plugins::StreamBidi::Signal
- Defined in:
- lib/httpx/plugins/stream_bidi.rb
Overview
Proxy to wake up the session main loop when one of the connections has buffered data to write. It abides by the HTTPX::_Selectable API, which allows it to be registered in the selector alongside actual HTTP-based HTTPX::Connection objects.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #call ⇒ Object
-
#handle_socket_timeout(interval) ⇒ Object
noop (the owner connection will take of it).
-
#initialize ⇒ Signal
constructor
A new instance of Signal.
- #interests ⇒ Object
-
#log(&_) ⇒ Object
noop.
- #on_error(error) ⇒ Object
- #state ⇒ Object
- #terminate ⇒ Object
- #timeout ⇒ Object
- #to_io ⇒ Object
- #wakeup ⇒ Object
Constructor Details
#initialize ⇒ Signal
Returns a new instance of Signal.
122 123 124 125 126 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 122 def initialize @closed = false @error = nil @pipe_read, @pipe_write = IO.pipe end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
120 121 122 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 120 def error @error end |
Instance Method Details
#call ⇒ Object
145 146 147 148 149 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 145 def call return if @closed @pipe_read.readpartial(1) end |
#handle_socket_timeout(interval) ⇒ Object
noop (the owner connection will take of it)
171 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 171 def handle_socket_timeout(interval); end |
#interests ⇒ Object
151 152 153 154 155 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 151 def interests return if @closed :r end |
#log(&_) ⇒ Object
noop
133 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 133 def log(**, &_); end |
#on_error(error) ⇒ Object
165 166 167 168 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 165 def on_error(error) @error = error terminate end |
#state ⇒ Object
128 129 130 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 128 def state @closed ? :closed : :open end |
#terminate ⇒ Object
159 160 161 162 163 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 159 def terminate @pipe_write.close @pipe_read.close @closed = true end |
#timeout ⇒ Object
157 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 157 def timeout; end |
#to_io ⇒ Object
135 136 137 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 135 def to_io @pipe_read.to_io end |
#wakeup ⇒ Object
139 140 141 142 143 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 139 def wakeup return if @closed @pipe_write.write("\0") end |