Sha256: e3453e3e3ecc0143c1eaf841b55dd839ca4def0dafcfa884280d82c10948b16b
Contents?: true
Size: 1.36 KB
Versions: 12
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module HTTPX module Plugins module GRPC # Encapsulates call information class Call attr_writer :decoder def initialize(response) @response = response @decoder = ->(z) { z } @consumed = false @grpc_response = nil end def inspect "#GRPC::Call(#{grpc_response})" end def to_s grpc_response.to_s end def metadata response.headers end def trailing_metadata return unless @consumed @response.trailing_metadata end private def grpc_response @grpc_response ||= if @response.respond_to?(:each) Enumerator.new do |y| Message.stream(@response).each do |message| y << @decoder.call(message) end @consumed = true end else @consumed = true @decoder.call(Message.unary(@response)) end end def respond_to_missing?(meth, *args, &blk) grpc_response.respond_to?(meth, *args) || super end def method_missing(meth, *args, &blk) return grpc_response.__send__(meth, *args, &blk) if grpc_response.respond_to?(meth) super end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems