Class: Momento::GrpcConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/momento/config/transport/grpc_configuration.rb

Overview

Encapsulates gRPC configuration tunables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deadline, num_grpc_channels = 1) ⇒ GrpcConfiguration

Returns a new instance of GrpcConfiguration.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/momento/config/transport/grpc_configuration.rb', line 21

def initialize(deadline, num_grpc_channels = 1)
  unless deadline.is_a? Integer
    raise Momento::Error::InvalidArgumentError,
      'Client timeout must be an integer'
  end
  if (deadline.is_a? Integer) && (deadline < 1)
    raise Momento::Error::InvalidArgumentError,
      'Client timeout must be positive'
  end

  @deadline = deadline
  @num_grpc_channels = num_grpc_channels
end

Instance Attribute Details

#deadlineObject (readonly)

Number of milliseconds the client is willing to wait for an RPC to complete before it is terminated with a DeadlineExceeded error



6
7
8
# File 'lib/momento/config/transport/grpc_configuration.rb', line 6

def deadline
  @deadline
end

#num_grpc_channelsObject (readonly)

Number of gRPC channels to create. Each channel can multiplex up to 100 concurrent requests. The default is 1, and this should not be overridden unless you are making a high volume of requests.



11
12
13
# File 'lib/momento/config/transport/grpc_configuration.rb', line 11

def num_grpc_channels
  @num_grpc_channels
end

Instance Method Details

#with_deadline(deadline) ⇒ Object



13
14
15
# File 'lib/momento/config/transport/grpc_configuration.rb', line 13

def with_deadline(deadline)
  return GrpcConfiguration.new(deadline, @num_grpc_channels)
end

#with_num_grpc_channels(num_grpc_channels) ⇒ Object



17
18
19
# File 'lib/momento/config/transport/grpc_configuration.rb', line 17

def with_num_grpc_channels(num_grpc_channels)
  return GrpcConfiguration.new(@deadline, num_grpc_channels)
end