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 Method Summary collapse

Constructor Details

#initializeSignal

Returns a new instance of Signal.



120
121
122
123
# File 'lib/httpx/plugins/stream_bidi.rb', line 120

def initialize
  @closed = false
  @pipe_read, @pipe_write = ::IO.pipe
end

Instance Method Details

#callObject



142
143
144
145
146
# File 'lib/httpx/plugins/stream_bidi.rb', line 142

def call
  return if @closed

  @pipe_read.readpartial(1)
end

#handle_socket_timeout(interval) ⇒ Object

noop (the owner connection will take of it)



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

def handle_socket_timeout(interval); end

#interestsObject



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

def interests
  return if @closed

  :r
end

#logObject

noop



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

def log(**); end

#stateObject



125
126
127
# File 'lib/httpx/plugins/stream_bidi.rb', line 125

def state
  @closed ? :closed : :open
end

#terminateObject



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

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

#timeoutObject



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

def timeout; end

#to_ioObject



132
133
134
# File 'lib/httpx/plugins/stream_bidi.rb', line 132

def to_io
  @pipe_read.to_io
end

#wakeupObject



136
137
138
139
140
# File 'lib/httpx/plugins/stream_bidi.rb', line 136

def wakeup
  return if @closed

  @pipe_write.write("\0")
end