Module: HTTPX::Plugins::FiberConcurrency::ConnectionMethods

Defined in:
lib/httpx/plugins/fiber_concurrency.rb,
sig/plugins/fiber_concurrency.rbs

Instance Method Summary collapse

Instance Method Details

#closed_for_select? ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
82
83
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 79

def closed_for_select?
  # @fiber-switch-guard
  # a closed connection still holding requests will reconnect once the fiber closing its socket resumes.
  super && @pending.empty?
end

#current_context? ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 67

def current_context?
  @pending.any?(&:current_context?) || (
    @sibling && @sibling.pending.any?(&:current_context?)
  )
end

#initial_call ⇒ Object



73
74
75
76
77
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 73

def initial_call
  return unless current_context?

  super
end

#interests ⇒ Object



117
118
119
120
121
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 117

def interests
  idling if (@state == :closed) && !no_more_requests?

  super
end

#on_connect_error(e) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 99

def on_connect_error(e)
  return super unless e.is_a?(IOError) && e.message.include?("stream closed in another thread")

  # @fiber-switch-guard
  # sockets closed during fiber scheduler switches are raised in separate fibers than the fiber the
  # socket may be used in. this check verifies that this is actually about this socket.
  unless to_io.closed? && !backlog?
    call
    return
  end

  super
end

#on_io_error(e) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 85

def on_io_error(e)
  return super unless e.is_a?(IOError) && e.message.include?("stream closed in another thread")

  # @fiber-switch-guard
  # sockets closed during fiber scheduler switches are raised in separate fibers than the fiber the
  # socket may be used in. this check verifies that this is actually about this socket.
  unless to_io.closed? && !backlog?
    call
    return
  end

  super
end

#pending_count ⇒ Object



113
114
115
# File 'lib/httpx/plugins/fiber_concurrency.rb', line 113

def pending_count
  @pending.count(&:current_context?)
end

#send ⇒ void

This method returns an undefined value.

Parameters:

  • request (request)


21
# File 'sig/plugins/fiber_concurrency.rbs', line 21

def send: (request request) -> void