Module: Rubyists::Dapr::Client

Includes:
SemanticLogger::Loggable
Included in:
Configuration, Lock, Publisher, State
Defined in:
lib/dapr/client.rb,
lib/dapr/client/lock.rb,
lib/dapr/client/state.rb,
lib/dapr/client/publisher.rb,
lib/dapr/client/configuration.rb

Overview

The namespace for the Dapr client

Defined Under Namespace

Classes: Configuration, DummyClient, Lock, Publisher, State

Constant Summary collapse

Runtime =
::Dapr::Proto::Runtime::V1
DAPR_PORT =
ENV.fetch('DAPR_GRPC_PORT', nil)
DAPR_URI =
ENV.fetch('DAPR_GRPC_HOST', 'localhost')
DAPR_STUB =
Runtime::Dapr::Stub

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.client(dapr_port: DAPR_PORT, dapr_uri: DAPR_URI) ⇒ Object



19
20
21
22
23
24
# File 'lib/dapr/client.rb', line 19

def self.client(dapr_port: DAPR_PORT, dapr_uri: DAPR_URI)
  return DummyClient.new if dapr_port.nil?

  logger.info "Creating Dapr client for #{dapr_uri}:#{dapr_port}"
  DAPR_STUB.new("#{dapr_uri}:#{dapr_port}", :this_channel_is_insecure)
end

.singletonObject



26
27
28
# File 'lib/dapr/client.rb', line 26

def self.singleton
  @singleton ||= client
end

Instance Method Details

#clientObject



30
31
32
# File 'lib/dapr/client.rb', line 30

def client
  Rubyists::Dapr::Client.client
end

#singletonObject



34
35
36
# File 'lib/dapr/client.rb', line 34

def singleton
  @singleton ||= Rubyists::Dapr::Client.singleton
end