class WsdlMapper::Runtime::AsyncHttpBackend
## Middleware Stack ### Default Configuration The default stack is composed of the following middlewares: 
-
`message.factory`: {WsdlMapper::Runtime::Middlewares::AsyncMessageFactory}
-
`request.factory`: {WsdlMapper::Runtime::Middlewares::AsyncRequestFactory}
-
`dispatcher`: {WsdlMapper::Runtime::Middlewares::AsyncDispatcher}
-
`response.factory`: {WsdlMapper::Runtime::Middlewares::AsyncResponseFactory}
Public Class Methods
# 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
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
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
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
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