Class: HTTPX::Plugins::StreamBidi::Signal

Inherits:
Object
  • Object
show all
Includes:
_Selectable
Defined in:
lib/httpx/plugins/stream_bidi.rb,
sig/plugins/stream_bidi.rbs

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

Instance Method Summary collapse

Constructor Details

#initializeSignal

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

#errorException? (readonly)

Returns the value of attribute error.

Returns:

  • (Exception, nil)


149
150
151
# File 'lib/httpx/plugins/stream_bidi.rb', line 149

def error
  @error
end

Instance Method Details

#callObject



174
175
176
177
178
# File 'lib/httpx/plugins/stream_bidi.rb', line 174

def call
  return if @closed

  @pipe_read.readpartial(1)
end

#force_closeObject



194
195
196
# File 'lib/httpx/plugins/stream_bidi.rb', line 194

def force_close(*)
  terminate
end

#handle_socket_timeout(interval) ⇒ Object

noop (the owner connection will take of it)



214
# File 'lib/httpx/plugins/stream_bidi.rb', line 214

def handle_socket_timeout(interval); end

#inflight?Boolean

Returns:

  • (Boolean)


190
191
192
# File 'lib/httpx/plugins/stream_bidi.rb', line 190

def inflight?
  !@closed
end

#initial_callObject



180
# File 'lib/httpx/plugins/stream_bidi.rb', line 180

def initial_call; end

#interestsObject



182
183
184
185
186
# File 'lib/httpx/plugins/stream_bidi.rb', line 182

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 Also known as: on_io_error



206
207
208
209
# File 'lib/httpx/plugins/stream_bidi.rb', line 206

def on_error(error)
  @error = error
  terminate
end

#stateObject



157
158
159
# File 'lib/httpx/plugins/stream_bidi.rb', line 157

def state
  @closed ? :closed : :open
end

#terminateObject



198
199
200
201
202
203
204
# File 'lib/httpx/plugins/stream_bidi.rb', line 198

def terminate
  return if @closed

  @pipe_write.close
  @pipe_read.close
  @closed = true
end

#timeoutObject



188
# File 'lib/httpx/plugins/stream_bidi.rb', line 188

def timeout; end

#to_ioObject



164
165
166
# File 'lib/httpx/plugins/stream_bidi.rb', line 164

def to_io
  @pipe_read.to_io
end

#wakeupvoid

This method returns an undefined value.



168
169
170
171
172
# File 'lib/httpx/plugins/stream_bidi.rb', line 168

def wakeup
  return if @closed

  @pipe_write.write("\0")
end