class WsdlMapper::Runtime::AsyncHttpBackend

## Middleware Stack ### Default Configuration The default stack is composed of the following middlewares: ![Diagram](/docs/file/doc/diag/async_backend.png)

  1. `message.factory`: {WsdlMapper::Runtime::Middlewares::AsyncMessageFactory}

  2. `request.factory`: {WsdlMapper::Runtime::Middlewares::AsyncRequestFactory}

  3. `dispatcher`: {WsdlMapper::Runtime::Middlewares::AsyncDispatcher}

  4. `response.factory`: {WsdlMapper::Runtime::Middlewares::AsyncResponseFactory}

Public Class Methods

new(connection: Faraday.new, executor: nil) click to toggle source
Calls superclass method
# File lib/wsdl_mapper/runtime/async_http_backend.rb, line 25
def initialize(connection: Faraday.new, executor: nil)
  super()
  @executor = executor

  stack.add 'message.factory', AsyncMessageFactory.new
  stack.add 'request.factory', AsyncRequestFactory.new
  stack.add 'dispatcher', AsyncDispatcher.new(connection)
  stack.add 'response.factory', AsyncResponseFactory.new
end

Public Instance Methods

disable_logging() click to toggle source

Disables logging by removing the logging middlewares from the stack. Returns self. @return [AsyncHttpBackend]

# File lib/wsdl_mapper/runtime/async_http_backend.rb, line 47
def disable_logging
  stack.remove 'request.logger'
  stack.remove 'response.logger'
  self
end
dispatch(operation, *args) click to toggle source

Takes an `operation` and arguments, wraps them in a new {Concurrent::Promise}, passes them to the {#stack} and returns the response promise. @param [WsdlMapper::Runtime::Operation] operation @param [Array] args @return [Concurrent::Promise] The unscheduled response promise.

# File lib/wsdl_mapper/runtime/async_http_backend.rb, line 58
def dispatch(operation, *args)
  promise = Concurrent::Promise.new(executor: @executor) { args }
  dispatch_async operation, promise
end
dispatch_async(operation, promise) click to toggle source

Passes a promise to the stack and returns the response promise. @param [WsdlMapper::Runtime::Operation] operation @param [Concurrent::Promise] promise A promise for the request arguments. @return [Concurrent::Promise] The unscheduled response promise.

# File lib/wsdl_mapper/runtime/async_http_backend.rb, line 67
def dispatch_async(operation, promise)
  stack.execute([operation, promise]).last
end
enable_logging(logger = Logger.new(STDOUT), log_level: Logger::DEBUG) click to toggle source

Enables request and response logging. Returns self. @param [Logger] logger Logger instance to use. @param [Logger::DEBUG, Logger::INFO, Logger::FATAL, Logger::ERROR, Logger::WARN] log_level @return [AsyncHttpBackend]

# File lib/wsdl_mapper/runtime/async_http_backend.rb, line 39
def enable_logging(logger = Logger.new(STDOUT), log_level: Logger::DEBUG)
  stack.after 'request.factory', 'request.logger', AsyncRequestLogger.new(logger, log_level: log_level)
  stack.before 'response.factory', 'response.logger', AsyncResponseLogger.new(logger, log_level: log_level)
  self
end