Class: Temporalio::EnvConfig::ClientConfigProfile

Inherits:
Data
  • Object
show all
Defined in:
lib/temporalio/env_config.rb,
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.

Instance Attribute Summary collapse

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



188
189
190
# File 'lib/temporalio/env_config.rb', line 188

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

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address

Returns:

  • (Object)

    the current value of address



139
# File 'lib/temporalio/env_config.rb', line 139

ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta)

#api_keyObject (readonly)

Returns the value of attribute api_key

Returns:

  • (Object)

    the current value of api_key



139
# File 'lib/temporalio/env_config.rb', line 139

ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta)

#grpc_metaObject (readonly)

Returns the value of attribute grpc_meta

Returns:

  • (Object)

    the current value of grpc_meta



139
# File 'lib/temporalio/env_config.rb', line 139

ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta)

#namespaceObject (readonly)

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



139
# File 'lib/temporalio/env_config.rb', line 139

ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta)

#tlsObject (readonly)

Returns the value of attribute tls

Returns:

  • (Object)

    the current value of tls



139
# File 'lib/temporalio/env_config.rb', line 139

ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta)

Class Method Details

.from_h(hash) ⇒ ClientConfigProfile

Create a ClientConfigProfile from a hash

Parameters:

  • hash (Hash)

    Hash representation

Returns:



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

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:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/temporalio/env_config.rb', line 170

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



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/temporalio/env_config.rb', line 206

def to_client_connect_options
  positional_args = [address, namespace]
  tls_value = false
  if tls
    tls_value = tls.to_client_tls_options
  elsif api_key
    tls_value = true
  end

  keyword_args = {
    api_key: api_key,
    rpc_metadata: (grpc_meta if grpc_meta && !grpc_meta.empty?),
    tls: tls_value
  }.compact

  [positional_args, keyword_args]
end

#to_hHash

Convert to a hash that can be used for TOML serialization

Returns:

  • (Hash)

    Dictionary representation



194
195
196
197
198
199
200
201
202
# File 'lib/temporalio/env_config.rb', line 194

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