Class: Temporalio::EnvConfig::ClientConfigProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/env_config.rb

Overview

A client configuration profile loaded from environment and files.

This class represents a complete client configuration profile that can be loaded from TOML files and environment variables, and converted to client connection options.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address: nil, namespace: nil, api_key: nil, tls: nil, grpc_meta: {}) ⇒ ClientConfigProfile

Create a ClientConfigProfile instance with defaults



196
197
198
# File 'lib/temporalio/env_config.rb', line 196

def initialize(address: nil, namespace: nil, api_key: nil, tls: nil, grpc_meta: {})
  super
end

Class Method Details

.from_h(hash) ⇒ ClientConfigProfile

Create a ClientConfigProfile from a hash

Parameters:

  • hash (Hash)

    Hash representation

Returns:



152
153
154
155
156
157
158
159
160
# File 'lib/temporalio/env_config.rb', line 152

def self.from_h(hash)
  new(
    address: hash[:address],
    namespace: hash[:namespace],
    api_key: hash[:api_key],
    tls: ClientConfigTLS.from_h(hash[:tls]),
    grpc_meta: hash[:grpc_meta] || {}
  )
end

.load(profile: nil, config_source: nil, disable_file: false, disable_env: false, config_file_strict: false, override_env_vars: nil) ⇒ ClientConfigProfile

Load a single client profile from given sources, applying env overrides.

Parameters:

  • profile (String, nil) (defaults to: nil)

    Profile to load from the config

  • config_source (Pathname, String, nil) (defaults to: nil)

    Configuration source - Pathname for file path, String for TOML content

  • disable_file (Boolean) (defaults to: false)

    If true, file loading is disabled

  • disable_env (Boolean) (defaults to: false)

    If true, environment variable loading and overriding is disabled

  • config_file_strict (Boolean) (defaults to: false)

    If true, will error on unrecognized keys

  • override_env_vars (Hash, nil) (defaults to: nil)

    Environment variables to use for loading and overrides

Returns:



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/temporalio/env_config.rb', line 172

def self.load(
  profile: nil,
  config_source: nil,
  disable_file: false,
  disable_env: false,
  config_file_strict: false,
  override_env_vars: nil
)
  path, data = EnvConfig._source_to_path_and_data(config_source)

  raw_profile = Internal::Bridge::EnvConfig.load_client_connect_config(
    profile,
    path,
    data,
    disable_file,
    disable_env,
    config_file_strict,
    override_env_vars || {}
  )

  from_h(raw_profile)
end

Instance Method Details

#to_client_connect_optionsArray

Create a client connect config from this profile

Returns:

  • (Array)

    Tuple of [positional_args, keyword_args] that can be splatted to Client.connect



214
215
216
217
218
219
220
221
222
223
# File 'lib/temporalio/env_config.rb', line 214

def to_client_connect_options
  positional_args = [address, namespace].compact
  keyword_args = {
    api_key: api_key,
    tls: tls&.to_client_tls_options,
    rpc_metadata: (grpc_meta if grpc_meta && !grpc_meta.empty?)
  }.compact

  [positional_args, keyword_args]
end

#to_hHash

Convert to a hash that can be used for TOML serialization

Returns:

  • (Hash)

    Dictionary representation



202
203
204
205
206
207
208
209
210
# File 'lib/temporalio/env_config.rb', line 202

def to_h
  {
    address: address,
    namespace: namespace,
    api_key: api_key,
    tls: tls&.to_h&.then { |tls_hash| tls_hash.empty? ? nil : tls_hash }, # steep:ignore
    grpc_meta: grpc_meta && grpc_meta.empty? ? nil : grpc_meta
  }.compact
end