Sha256: 9537198fe14d3c71b79df04ec1c5290aab130c8e6f6908e93d61ad47c3f06003
Contents?: true
Size: 1.63 KB
Versions: 5
Compression:
Stored size: 1.63 KB
Contents
module NxtHttpClient class Client module BatchPatch attr_reader :callback_map, :ignore_around_callbacks def assign_batch_data(callback_map, ignore_around_callbacks) @callback_map = callback_map @ignore_around_callbacks = ignore_around_callbacks end def fire(url = '', **opts, &block) response_handler = build_response_handler(opts[:response_handler], &block) request = build_request(url, **opts.except(:response_handler)) callback_map[:request] = request setup_on_headers_callback(request, response_handler) setup_on_body_callback(request, response_handler) request.on_complete do |response| callback_map[:result] = callback_or_response(response, response_handler) rescue StandardError => e callback_map[:error] = e end if callbacks.any_around_callbacks? && ignore_around_callbacks != true raise( ArgumentError, <<~TXT `around_fire` callbacks are not supported when firing batches. \ Pass `ignore_around_callbacks: true` to `execute_in_batch` \ in order to acknowledge and muffle this. TXT ) end run_before_fire_callbacks(request, response_handler) request end def finish(request, result, error, raise_errors: true) result = run_after_fire_callbacks(request, request.response, result, error) case [error, raise_errors] in [nil, _] result in [_, true] raise error in [_, false] error end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems