Class: Restify::Adapter::PooledEM
- Includes:
- Logging
- Defined in:
- lib/restify/adapter/pooled_em.rb
Defined Under Namespace
Classes: Pool
Instance Method Summary collapse
-
#call_native(request, writer) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/BlockLength.
-
#initialize(**kwargs) ⇒ PooledEM
constructor
A new instance of PooledEM.
Methods included from Logging
#_fmt, #_log_prefix, #debug, #logger
Methods inherited from Base
Constructor Details
Instance Method Details
#call_native(request, writer) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/BlockLength
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/restify/adapter/pooled_em.rb', line 206 def call_native(request, writer) next_tick do defer = @pool.get(request) defer.errback do |error| writer.reject(error) end defer.callback do |conn| req = conn.send request.method.downcase, keepalive: true, redirects: 3, path: request.uri.normalized_path, query: request.uri.normalized_query, body: request.body, head: request.headers req.callback do writer.fulfill Response.new( request, req.last_effective_url, req.response_header.status, req.response_header, req.response ) if req.response_header['CONNECTION'] == 'close' @pool.remove(conn) else @pool << conn end end req.errback do @pool.remove(conn) writer.reject(req.error) end rescue Exception => e # rubocop:disable Lint/RescueException @pool.remove(conn) writer.reject(e) end end end |