Module: HTTPX::Plugins::Hedging::ConnectionMethods
- Defined in:
- lib/httpx/plugins/hedging.rb,
sig/plugins/hedging.rbs
Instance Attribute Summary collapse
-
#hedge_connection ⇒ connectionHedging?
Returns the value of attribute hedge_connection.
-
#is_hedge_connection ⇒ Boolean
Returns the value of attribute is_hedge_connection.
Instance Method Summary collapse
- #addresses=(addrs) ⇒ Object
- #initialize ⇒ Object
-
#mergeable?(connection) ⇒ Boolean
connections should not merge with their hedge connections.
- #send(request) ⇒ Object
- #try_yield_connection {|arg0| ... } ⇒ T
- #try_yield_hedge_connection ⇒ Object
Instance Attribute Details
#hedge_connection ⇒ connectionHedging?
Returns the value of attribute hedge_connection.
214 215 216 |
# File 'lib/httpx/plugins/hedging.rb', line 214 def hedge_connection @hedge_connection end |
#is_hedge_connection ⇒ Boolean
Returns the value of attribute is_hedge_connection.
216 217 218 |
# File 'lib/httpx/plugins/hedging.rb', line 216 def is_hedge_connection @is_hedge_connection end |
Instance Method Details
#addresses=(addrs) ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/httpx/plugins/hedging.rb', line 223 def addresses=(addrs) try_yield_hedge_connection do |hedge_conn| super.tap do hedge_conn.addresses = addrs if hedge_conn end end end |
#initialize ⇒ Object
218 219 220 221 |
# File 'lib/httpx/plugins/hedging.rb', line 218 def initialize(*) super @is_hedge_connection = false end |
#mergeable?(connection) ⇒ Boolean
connections should not merge with their hedge connections
258 259 260 |
# File 'lib/httpx/plugins/hedging.rb', line 258 def mergeable?(connection) super && connection.hedge_connection != self end |
#send(request) ⇒ Object
262 263 264 265 266 267 268 269 |
# File 'lib/httpx/plugins/hedging.rb', line 262 def send(request) super.tap do if @hedge_connection && !request.hedge_request request.hedge_request = hedge_request = request.dup @hedge_connection.send(hedge_request) end end end |
#try_yield_connection {|arg0| ... } ⇒ T
33 |
# File 'sig/plugins/hedging.rbs', line 33
def try_yield_connection: [T] () { (connectionHedging) -> T } -> T
|
#try_yield_hedge_connection ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/httpx/plugins/hedging.rb', line 243 def try_yield_hedge_connection return yield(nil) unless (hedge_conn = @hedge_connection) @hedge_connection = nil begin hedge_conn.try_yield_hedge_connection do yield(hedge_conn) end ensure @hedge_connection = hedge_conn end end |