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

#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 ⇒ Exception? (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

#call ⇒ Object



178
179
180
181
182
# File 'lib/httpx/plugins/stream_bidi.rb', line 178

def call
  return if @closed

  @pipe_read.readpartial(1)
end

#closed_for_select? ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/httpx/plugins/stream_bidi.rb', line 161

def closed_for_select?
  @closed
end

#force_close ⇒ Object



198
199
200
# File 'lib/httpx/plugins/stream_bidi.rb', line 198

def force_close(*)
  terminate
end

#handle_socket_timeout(interval) ⇒ Object

noop (the owner connection will take of it)



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

def handle_socket_timeout(interval); end

#inflight? ⇒ Boolean

Returns:

  • (Boolean)


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

def inflight?
  !@closed
end

#initial_call ⇒ Object



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

def initial_call; end

#interests ⇒ Object



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

def interests
  return if @closed

  :r
end

#log(&_) ⇒ Object

noop



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

def log(**, &_); end

#on_error(error) ⇒ Object Also known as: on_io_error



210
211
212
213
# File 'lib/httpx/plugins/stream_bidi.rb', line 210

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



202
203
204
205
206
207
208
# File 'lib/httpx/plugins/stream_bidi.rb', line 202

def terminate
  return if @closed

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

#timeout ⇒ Object



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

def timeout; end

#to_io ⇒ Object



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

def to_io
  @pipe_read.to_io
end

#wakeup ⇒ void

This method returns an undefined value.



172
173
174
175
176
# File 'lib/httpx/plugins/stream_bidi.rb', line 172

def wakeup
  return if @closed

  @pipe_write.write("\0")
end