Sha256: f91d37a87a43e8778289479b7e659beeb3dfc14da1530b908cb58c2b63e9b2c3

Contents?: true

Size: 1.64 KB

Versions: 16

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

require_relative '../client'

module Rubyists
  module Dapr
    module Client
      # Handles publishing messages to Dapr pub/sub topics
      class Configuration
        # Include the client module
        include Client
        include SemanticLogger::Loggable

        # The name of the configuration component, the keys we care about, and the metadata
        attr_reader :store_name, :keys, :metadata

        # The proto class for the GetConfiguration request
        ConfigurationRequest = ::Dapr::Proto::Runtime::V1::GetConfigurationRequest
        # The proto class for the GetConfiguration response
        ConfigurationResponse = ::Dapr::Proto::Runtime::V1::GetConfigurationResponse
        DEFAULT_STORE_NAME = 'dapr-config'

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

        # Initialize the Configuration object
        #
        # @param store_name [String]  The name of the Dapr Configuration component to use
        # @param keys [Array<String>] The keys to retrieve from the configuration store (empty means all)
        # @param metadata [Hash] Optional metadata to pass to the Dapr configuration store
        def initialize(store_name, keys: [], metadata: {})
          @store_name = store_name
          @keys = Array(keys)
          @metadata = metadata
        end

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dapr-0.5.0 lib/dapr/client/configuration.rb
dapr-0.4.3 lib/dapr/client/configuration.rb
dapr-0.4.2 lib/dapr/client/configuration.rb
dapr-0.4.1 lib/dapr/client/configuration.rb
dapr-0.4.0 lib/dapr/client/configuration.rb
dapr-0.3.3 lib/dapr/client/configuration.rb
dapr-0.3.2 lib/dapr/client/configuration.rb
dapr-0.3.1 lib/dapr/client/configuration.rb
dapr-0.3.0 lib/dapr/client/configuration.rb
dapr-0.2.11 lib/dapr/client/configuration.rb
dapr-0.2.9 lib/dapr/client/configuration.rb
dapr-0.2.8 lib/dapr/client/configuration.rb
dapr-0.2.7 lib/dapr/client/configuration.rb
dapr-0.2.6 lib/dapr/client/configuration.rb
dapr-0.2.4 lib/dapr/client/configuration.rb
dapr-0.2.2 lib/dapr/client/configuration.rb