Sha256: 80afbe79910ceec2b1f64a328d0e79e5545c76af0faf8160783ad2cc14778fec

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module GrpcKit
  module Calls
    class Call
      Name = Struct.new(:name, :receiver)
      Reciver = Struct.new(:class)
      Klass = Struct.new(:service_name)
      attr_reader :method

      # @params stream [GrpcKit::Stream::ServerStream|GrpcKit::Stream::ClientStream]
      # @params config [GrpcKit::MethodConfig]
      # @params metadata [Hash]
      def initialize(stream:, config:, metadata:, timeout: nil)
        @config = config
        @metadata = metadata
        @method_name = @config.method_name
        @service_name = @config.service_name
        @protobuf = @config.protobuf
        @timeout = timeout
        @stream = stream

        # for compatible
        klass = Klass.new(@service_name)
        @method ||= Name.new(@method_name, Reciver.new(klass))
        @restrict = false
      end

      def restrict_mode
        @restrict = true
      end

      def normal_mode
        @restrict = false
      end

      def deadline
        @deadline ||= @timeout.to_absolute_time
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grpc_kit-0.1.8 lib/grpc_kit/calls.rb
grpc_kit-0.1.7 lib/grpc_kit/calls.rb
grpc_kit-0.1.6 lib/grpc_kit/calls.rb
grpc_kit-0.1.5 lib/grpc_kit/calls.rb