Sha256: 1a0ccadfb82ddf2f58ae2a5c18a33249df2d4eb7f9658c99bfac99ac9ac5c28e
Contents?: true
Size: 1.38 KB
Versions: 55
Compression:
Stored size: 1.38 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 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 return @grpc_response if defined?(@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
55 entries across 55 versions & 1 rubygems