Class: WsdlMapper::Runtime::AsyncHttpBackend
- Inherits:
-
BackendBase
- Object
- BackendBase
- WsdlMapper::Runtime::AsyncHttpBackend
- Includes:
- Middlewares
- Defined in:
- lib/wsdl_mapper/runtime/async_http_backend.rb
Overview
Middleware Stack
Default Configuration
The default stack is composed of the following middlewares:
message.factory
: Middlewares::AsyncMessageFactoryrequest.factory
: Middlewares::AsyncRequestFactorydispatcher
: Middlewares::AsyncDispatcherresponse.factory
: Middlewares::AsyncResponseFactory
Instance Attribute Summary
Attributes inherited from BackendBase
Instance Method Summary (collapse)
-
- (AsyncHttpBackend) disable_logging
Disables logging by removing the logging middlewares from the stack.
-
- (Concurrent::Promise) dispatch(operation, *args)
Takes an
operation
and arguments, wraps them in a new Concurrent::Promise, passes them to the BackendBase#stack and returns the response promise. -
- (Concurrent::Promise) dispatch_async(operation, promise)
Passes a promise to the stack and returns the response promise.
-
- (AsyncHttpBackend) enable_logging(logger = Logger.new(STDOUT), log_level: Logger::DEBUG)
Enables request and response logging.
-
- (AsyncHttpBackend) initialize(connection: Faraday.new, executor: nil)
constructor
A new instance of AsyncHttpBackend.
Constructor Details
- (AsyncHttpBackend) initialize(connection: Faraday.new, executor: nil)
Returns a new instance of AsyncHttpBackend
25 26 27 28 29 30 31 32 33 |
# 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 |
Instance Method Details
- (AsyncHttpBackend) disable_logging
Disables logging by removing the logging middlewares from the stack. Returns self.
47 48 49 50 51 |
# File 'lib/wsdl_mapper/runtime/async_http_backend.rb', line 47 def disable_logging stack.remove 'request.logger' stack.remove 'response.logger' self end |
- (Concurrent::Promise) dispatch(operation, *args)
Takes an operation
and arguments, wraps them in a new Concurrent::Promise,
passes them to the BackendBase#stack and returns the response promise.
58 59 60 61 |
# 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 |
- (Concurrent::Promise) dispatch_async(operation, promise)
Passes a promise to the stack and returns the response promise.
67 68 69 |
# File 'lib/wsdl_mapper/runtime/async_http_backend.rb', line 67 def dispatch_async(operation, promise) stack.execute([operation, promise]).last end |
- (AsyncHttpBackend) enable_logging(logger = Logger.new(STDOUT), log_level: Logger::DEBUG)
Enables request and response logging. Returns self.
39 40 41 42 43 |
# 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 |