Class: Rubyists::Dapr::Client::Configuration

Inherits:
Object
  • Object
show all
Includes:
Rubyists::Dapr::Client, SemanticLogger::Loggable
Defined in:
lib/dapr/client/configuration.rb

Overview

Handles publishing messages to Dapr pub/sub topics

Constant Summary collapse

ConfigurationRequest =

The proto class for the GetConfiguration request

::Dapr::Proto::Runtime::V1::GetConfigurationRequest
ConfigurationResponse =

The proto class for the GetConfiguration response

::Dapr::Proto::Runtime::V1::GetConfigurationResponse
DEFAULT_STORE_NAME =
'dapr-config'

Constants included from Rubyists::Dapr::Client

DAPR_PORT, DAPR_STUB, DAPR_URI, Runtime

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Rubyists::Dapr::Client

client, #client, singleton, #singleton

Constructor Details

#initialize(store_name, keys: [], metadata: {}) ⇒ Configuration

Initialize the Configuration object

Parameters:

  • store_name (String)

    The name of the Dapr Configuration component to use

  • keys (Array<String>) (defaults to: [])

    The keys to retrieve from the configuration store (empty means all)

  • metadata (Hash) (defaults to: {})

    Optional metadata to pass to the Dapr configuration store



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

def initialize(store_name, keys: [], metadata: {})
  @store_name = store_name
  @keys = Array(keys)
  @metadata = 
end

Instance Attribute Details

#keysObject (readonly)

The name of the configuration component, the keys we care about, and the metadata



15
16
17
# File 'lib/dapr/client/configuration.rb', line 15

def keys
  @keys
end

#metadataObject (readonly)

The name of the configuration component, the keys we care about, and the metadata



15
16
17
# File 'lib/dapr/client/configuration.rb', line 15

def 
  @metadata
end

#store_nameObject (readonly)

The name of the configuration component, the keys we care about, and the metadata



15
16
17
# File 'lib/dapr/client/configuration.rb', line 15

def store_name
  @store_name
end

Class Method Details

.get(keys = [], store_name: DEFAULT_STORE_NAME, metadata: {}) ⇒ Object



23
24
25
26
# File 'lib/dapr/client/configuration.rb', line 23

def self.get(keys = [], store_name: DEFAULT_STORE_NAME, metadata: {})
  configuration = new(store_name, keys:, metadata:)
  configuration.get
end

Instance Method Details

#getObject



39
40
41
42
# File 'lib/dapr/client/configuration.rb', line 39

def get
  logger.debug('Getting configuration', keys:, store_name:)
  singleton.get_configuration(ConfigurationRequest.new(store_name:, keys:, metadata:))
end