Method: Orchestrate::Client#in_parallel

Defined in:
lib/orchestrate/client.rb

#in_parallel {|accumulator| ... } ⇒ Object

Note:

This method is not Thread-safe. Requests generated from the same client in different threads while #in_parallel is running will behave unpredictably. Use #dup to create per-thread clients.

Performs requests in parallel. Requires using a Faraday adapter that supports parallel requests.

Examples:

Performing three requests at once

responses = client.in_parallel do |r|
  r[:some_items] = client.list(:site_globals)
  r[:user] = client.get(:users, current_user_key)
  r[:user_feed] = client.list_events(:users, current_user_key, :notices)
end

Yield Parameters:

  • accumulator (Hash)

    A place to store the results of the parallel responses.

See Also:

  • See the Readme for more examples.

416
417
418
419
420
421
422
# File 'lib/orchestrate/client.rb', line 416

def in_parallel(&block)
  accumulator = {}
  http.in_parallel do
    block.call(accumulator)
  end
  accumulator
end