lib/grumlin/request_dispatcher.rb
def add_response(response) # rubocop:disable Metrics/AbcSize
      request_id = response[:requestId]
      raise UnknownRequestError unless ongoing_request?(request_id)

      begin
        request = @requests[request_id]

        check_errors!(response[:status], request[:request])

        case SUCCESS[response.dig(:status, :code)]
        when :success
          request[:result] << response.dig(:result, :data)
          request[:channel] << request[:result]
          close_request(request_id)
        when :partial_content then request[:result] << response.dig(:result, :data)
        when :no_content
          request[:channel] << []
          close_request(request_id)
        end
      rescue StandardError => e
        request[:channel].exception(e)
        close_request(request_id)
      end
    end
# builds a response object, when it's ready sends it to the client via a channel
# TODO: sometimes response does not include requestID, no idea how to handle it so far.
builds a response object, when it's ready sends it to the client via a channel
TODO: sometimes response does not include requestID, no idea how to handle it so far.
builds a response object when it ' s ready sends it to the client via a channel TODO : sometimes response does not include requestID no idea how to handle it so far .
def add_response(response) 
      request_id = response[:requestId]
      raise UnknownRequestError unless ongoing_request?(request_id)
      begin
        request = @requests[request_id]
        check_errors!(response[:status], request[:request])
        case SUCCESS[response.dig(:status, :code)]
        when :success
          request[:result] << response.dig(:result, :data)
          request[:channel] << request[:result]
          close_request(request_id)
        when :partial_content then request[:result] << response.dig(:result, :data)
        when :no_content
          request[:channel] << []
          close_request(request_id)
        end
      rescue StandardError => e
        request[:channel].exception(e)
        close_request(request_id)
      end
    end
def add_response ( response ) request_id = response [ :requestId ] raise UnknownRequestError unless ongoing_request? ( request_id ) begin request = @requests [ request_id ] check_errors! ( response [ :status ] , request [ :request ] ) case SUCCESS [ response . dig ( :status , :code ) ] when :success request [ :result ] << response . dig ( :result , :data ) request [ :channel ] << request [ :result ] close_request ( request_id ) when :partial_content then request [ :result ] << response . dig ( :result , :data ) when :no_content request [ :channel ] << [ ] close_request ( request_id ) end rescue StandardError => e request [ :channel ] . exception ( e ) close_request ( request_id ) end end
builds a response object, when it's ready sends it to the client via a channel
TODO: sometimes response does not include requestID, no idea how to handle it so far.
builds a response object when it ' s ready sends it to the client via a channel TODO : sometimes response does not include requestID no idea how to handle it so far .
# rubocop:disable Metrics/AbcSize
response