Methods
Public Class
Public Instance
Public Class methods
new()
[show source]
# File lib/httpx/selector.rb 19 def initialize 20 @timers = Timers.new 21 @selectables = [] 22 @is_timer_interval = false 23 end
Public Instance methods
deregister(io)
deregisters io
from selectables.
[show source]
# File lib/httpx/selector.rb 104 def deregister(io) 105 @selectables.delete(io) 106 end
each(&blk)
[show source]
# File lib/httpx/selector.rb 25 def each(&blk) 26 @selectables.each(&blk) 27 end
each_connection(&block)
[show source]
# File lib/httpx/selector.rb 78 def each_connection(&block) 79 return enum_for(__method__) unless block 80 81 @selectables.each do |c| 82 case c 83 when Resolver::Resolver 84 c.each_connection(&block) 85 when Connection 86 yield c 87 end 88 end 89 end
find_connection(request_uri, options)
[show source]
# File lib/httpx/selector.rb 91 def find_connection(request_uri, options) 92 each_connection.find do |connection| 93 connection.match?(request_uri, options) 94 end 95 end
find_mergeable_connection(connection)
[show source]
# File lib/httpx/selector.rb 97 def find_mergeable_connection(connection) 98 each_connection.find do |ch| 99 ch != connection && ch.mergeable?(connection) 100 end 101 end
find_resolver(options)
[show source]
# File lib/httpx/selector.rb 70 def find_resolver(options) 71 res = @selectables.find do |c| 72 c.is_a?(Resolver::Resolver) && options == c.options 73 end 74 75 res.multi if res 76 end
next_tick()
[show source]
# File lib/httpx/selector.rb 29 def next_tick 30 catch(:jump_tick) do 31 timeout = next_timeout 32 if timeout && timeout.negative? 33 @timers.fire 34 throw(:jump_tick) 35 end 36 37 begin 38 select(timeout, &:call) 39 @timers.fire 40 rescue TimeoutError => e 41 @timers.fire(e) 42 end 43 end 44 rescue StandardError => e 45 each_connection do |c| 46 c.emit(:error, e) 47 end 48 rescue Exception # rubocop:disable Lint/RescueException 49 each_connection do |conn| 50 conn.force_reset 51 conn.disconnect 52 end 53 54 raise 55 end
register(io)
register io
.
[show source]
# File lib/httpx/selector.rb 109 def register(io) 110 return if @selectables.include?(io) 111 112 @selectables << io 113 end
terminate()
[show source]
# File lib/httpx/selector.rb 57 def terminate 58 # array may change during iteration 59 selectables = @selectables.reject(&:inflight?) 60 61 selectables.each(&:terminate) 62 63 until selectables.empty? 64 next_tick 65 66 selectables &= @selectables 67 end 68 end