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).
- #inflight? ⇒ Boolean
-
#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.
151 152 153 154 155 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 151 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.
149 150 151 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 149 def error @error end |
Instance Method Details
#call ⇒ Object
174 175 176 177 178 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 174 def call return if @closed @pipe_read.readpartial(1) end |
#handle_socket_timeout(interval) ⇒ Object
noop (the owner connection will take of it)
206 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 206 def handle_socket_timeout(interval); end |
#inflight? ⇒ Boolean
188 189 190 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 188 def inflight? !@closed end |
#interests ⇒ Object
180 181 182 183 184 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 180 def interests return if @closed :r end |
#log(&_) ⇒ Object
noop
162 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 162 def log(**, &_); end |
#on_error(error) ⇒ Object
200 201 202 203 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 200 def on_error(error) @error = error terminate end |
#state ⇒ Object
157 158 159 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 157 def state @closed ? :closed : :open end |
#terminate ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 192 def terminate return if @closed @pipe_write.close @pipe_read.close @closed = true end |
#timeout ⇒ Object
186 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 186 def timeout; end |
#to_io ⇒ Object
164 165 166 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 164 def to_io @pipe_read.to_io end |
#wakeup ⇒ Object
168 169 170 171 172 |
# File 'lib/httpx/plugins/stream_bidi.rb', line 168 def wakeup return if @closed @pipe_write.write("\0") end |