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

Inherits:
Object
  • Object
show all
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

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

#errorObject (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

#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

#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

Returns:

  • (Boolean)


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

def inflight?
  !@closed
end

#interestsObject



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

#stateObject



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

def state
  @closed ? :closed : :open
end

#terminateObject



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

#timeoutObject



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

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

#wakeupObject



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

def wakeup
  return if @closed

  @pipe_write.write("\0")
end