Class: Temporalio::EnvConfig::ClientConfigProfile
- Inherits:
-
Data
- Object
- Data
- Temporalio::EnvConfig::ClientConfigProfile
- 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
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#grpc_meta ⇒ Object
readonly
Returns the value of attribute grpc_meta.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#tls ⇒ Object
readonly
Returns the value of attribute tls.
Class Method Summary collapse
-
.from_h(hash) ⇒ ClientConfigProfile
Create a ClientConfigProfile from a hash.
-
.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.
Instance Method Summary collapse
-
#initialize(address: nil, namespace: nil, api_key: nil, tls: nil, grpc_meta: {}) ⇒ ClientConfigProfile
constructor
Create a ClientConfigProfile instance with defaults.
-
#to_client_connect_options ⇒ Array
Create a client connect config from this profile.
-
#to_h ⇒ Hash
Convert to a hash that can be used for TOML serialization.
Constructor Details
#initialize(address: nil, namespace: nil, api_key: nil, tls: nil, grpc_meta: {}) ⇒ ClientConfigProfile
Create a ClientConfigProfile instance with defaults
190 191 192 |
# File 'lib/temporalio/env_config.rb', line 190 def initialize(address: nil, namespace: nil, api_key: nil, tls: nil, grpc_meta: {}) super end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address
141 |
# File 'lib/temporalio/env_config.rb', line 141 ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta) |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key
141 |
# File 'lib/temporalio/env_config.rb', line 141 ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta) |
#grpc_meta ⇒ Object (readonly)
Returns the value of attribute grpc_meta
141 |
# File 'lib/temporalio/env_config.rb', line 141 ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta) |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace
141 |
# File 'lib/temporalio/env_config.rb', line 141 ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta) |
#tls ⇒ Object (readonly)
Returns the value of attribute tls
141 |
# File 'lib/temporalio/env_config.rb', line 141 ClientConfigProfile = Data.define(:address, :namespace, :api_key, :tls, :grpc_meta) |
Class Method Details
.from_h(hash) ⇒ ClientConfigProfile
Create a ClientConfigProfile from a hash
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.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# 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_options ⇒ Array
Create a client connect config from this profile
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/temporalio/env_config.rb', line 208 def positional_args = [address, namespace] tls_value = false if tls tls_value = tls. elsif api_key tls_value = true end keyword_args = { api_key: api_key, rpc_metadata: ( if && !.empty?), tls: tls_value }.compact [positional_args, keyword_args] end |
#to_h ⇒ Hash
Convert to a hash that can be used for TOML serialization
196 197 198 199 200 201 202 203 204 |
# File 'lib/temporalio/env_config.rb', line 196 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: && .empty? ? nil : }.compact end |