class Px::Service::Client::Multiplexer
Attributes
hydra[RW]
states[RW]
Public Class Methods
new(params = {})
click to toggle source
# File lib/px/service/client/multiplexer.rb, line 6 def initialize(params = {}) self.hydra = Typhoeus::Hydra.new(params) end
Public Instance Methods
context() { || ... }
click to toggle source
# File lib/px/service/client/multiplexer.rb, line 10 def context Fiber.new{ yield }.resume self end
do(request_or_future, retries: RetriableResponseFuture::DEFAULT_RETRIES)
click to toggle source
Queue a request on the multiplexer, with retry
# File lib/px/service/client/multiplexer.rb, line 17 def do(request_or_future, retries: RetriableResponseFuture::DEFAULT_RETRIES) response = request_or_future if request_or_future.is_a?(Typhoeus::Request) response = RetriableResponseFuture.new(request_or_future, retries: retries) elsif !request_or_future.is_a?(RetriableResponseFuture) || request_or_future.completed? return request_or_future end # Will automatically queue the request on the hydra response.hydra = hydra response end
run()
click to toggle source
Start the multiplexer.
# File lib/px/service/client/multiplexer.rb, line 32 def run hydra.run end