Module: NxtHttpClient
- Defined in:
- lib/nxt_http_client.rb,
lib/nxt_http_client/error.rb,
lib/nxt_http_client/client.rb,
lib/nxt_http_client/config.rb,
lib/nxt_http_client/logger.rb,
lib/nxt_http_client/headers.rb,
lib/nxt_http_client/version.rb,
lib/nxt_http_client/undefined.rb,
lib/nxt_http_client/client_dsl.rb,
lib/nxt_http_client/fire_callbacks.rb,
lib/nxt_http_client/batch_execution.rb,
lib/nxt_http_client/response_handler.rb,
lib/nxt_http_client/client/batch_patch.rb
Defined Under Namespace
Modules: ClientDsl Classes: Client, Config, Error, FireCallbacks, Logger, ResponseHandler, Undefined
Constant Summary collapse
- CONFIGURABLE_OPTIONS =
{ request_options: ActiveSupport::HashWithIndifferentAccess.new, base_url: '', x_request_id_proc: nil, # Helper to set the Content-Type request header and automatically convert request bodies to JSON json_request: false, # Helper to set the Accept request header and automatically convert success response bodies to JSON json_response: false, raise_response_errors: false, bearer_auth: nil, basic_auth: nil, timeouts: nil, }.freeze
- XRequestId =
'X-Request-ID'.freeze
- ApplicationJson =
'application/json'
- VERSION =
"2.1.0"
Class Method Summary collapse
Class Method Details
.execute_in_batch(*client_instances, ignore_around_callbacks: false, raise_errors: true) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nxt_http_client/batch_execution.rb', line 2 def self.execute_in_batch(*client_instances, ignore_around_callbacks: false, raise_errors: true) client_map = Hash.new do |hash, key| hash[key] = { request: nil, error: nil, result: nil } end client_instances.each do |client| client.singleton_class.include(NxtHttpClient::Client::BatchPatch) client.assign_batch_data(client_map[client], ignore_around_callbacks) end hydra = Typhoeus::Hydra.new client_instances.each do |client| client.call.tap do |request| hydra.queue(request) end end hydra.run client_map.map do |client, response_data| client.finish(response_data[:request], response_data[:result], response_data[:error], raise_errors: raise_errors) end end |