Method: RightScale::OfflineHandler#queue_request

Defined in:
lib/right_agent/offline_handler.rb

#queue_request(kind, type, payload, target, token, expires_at, &callback) ⇒ Object

Queue given request in memory

Parameters

kind(Symbol)

Kind of request: :send_push or :send_request

type(String)

Dispatch route for the request; typically identifies actor and action

payload(Object)

Data to be sent with marshalling en route

target(Hash|NilClass)

Target for request

token(String)

Token uniquely identifying request

expires_at(Integer)

Time in seconds in Unix-epoch when this request expires and

is to be ignored by the receiver; value 0 means never expire

Block

Optional block used to process response asynchronously with the following parameter:

result(Result):: Response with an OperationResult of SUCCESS, RETRY, NON_DELIVERY, or ERROR

Return

true

Always return true



178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/right_agent/offline_handler.rb', line 178

def queue_request(kind, type, payload, target, token, expires_at, &callback)
  request = {:kind => kind, :type => type, :payload => payload, :target => target,
             :token => token, :expires_at => expires_at, :callback => callback}
  Log.info("[offline] Queuing request: #{request.inspect}")
  vote_to_restart if (@restart_vote_count += 1) >= MAX_QUEUED_REQUESTS
  if @state == :initializing
    # We are in the initialization callback, requests should be put at the head of the queue
    @queue.unshift(request)
  else
    @queue << request
  end
  true
end