class Seahorse::Client::AsyncResponse

def context

Returns:
  • (RequestContext) -
def context
  @response.context
end

def error

Returns:
  • (StandardError, nil) -
def error
  @response.error
end

def initialize(options = {})

def initialize(options = {})
  @response = Response.new(context: options[:context])
  @stream = options[:stream]
  @stream_mutex = options[:stream_mutex]
  @close_condition = options[:close_condition]
  @sync_queue = options[:sync_queue]
end

def join!

def join!
  if error && context.config.raise_response_errors
    raise error
  elsif @stream
    # close callback is waiting
    # for the "sync_signal"
    @sync_queue << "sync_signal"
    @stream.close
    @response
  end
end

def on(range, &block)

Returns:
  • (self) -

Parameters:
  • status_code_range (Range) -- The block will be
  • status_code (Integer) -- The block will be

Overloads:
  • on(status_code_range, &block)
  • on(status_code, &block)
def on(range, &block)
  @response.on(range, &block)
  self
end

def on_complete(&block)

Other tags:
    Api: - private
def on_complete(&block)
  @response.on_complete(&block)
  self
end

def successful?

Returns:
  • (Boolean) - Returns `true` if the response is complete with
def successful?
  @response.error.nil?
end

def wait

def wait
  if error && context.config.raise_response_errors
    raise error
  elsif @stream
    # have a sync signal that #signal can be blocked on
    # else, if #signal is called before #wait
    # will be waiting for a signal never arrives
    @sync_queue << "sync_signal"
    # now #signal is unlocked for
    # signaling close condition when ready
    @stream_mutex.synchronize {
      @close_condition.wait(@stream_mutex)
    }
    @response
  end
end