Class: Tasker::Configuration
- Inherits:
-
Object
- Object
- Tasker::Configuration
- Defined in:
- lib/tasker/configuration.rb
Overview
Configuration class for the Tasker gem
Handles global configuration options with nested configuration blocks for better organization and discoverability.
All configuration types are now implemented using dry-struct for type safety, immutability, and consistent validation patterns.
Defined Under Namespace
Classes: ConfigurationProxy, TelemetryConfigurationProxy
Instance Method Summary collapse
-
#auth {|ConfigurationProxy| ... } ⇒ Tasker::Types::AuthConfig
Configure authentication and authorization settings.
-
#authentication ⇒ Tasker::Types::AuthConfig
Alias for auth configuration for backward compatibility.
-
#backoff {|ConfigurationProxy| ... } ⇒ Tasker::Types::BackoffConfig
Configure backoff calculation settings.
-
#cache {|ConfigurationProxy| ... } ⇒ Tasker::Types::CacheConfig
Configure intelligent cache strategy settings.
-
#database {|ConfigurationProxy| ... } ⇒ Tasker::Types::DatabaseConfig
Configure database settings.
-
#dependency_graph {|ConfigurationProxy| ... } ⇒ Tasker::Types::DependencyGraphConfig
Configure dependency graph calculation settings.
-
#dup ⇒ Object
Create a deep copy of the configuration.
-
#engine {|ConfigurationProxy| ... } ⇒ Tasker::Types::EngineConfig
Configure core engine settings.
-
#execution {|ConfigurationProxy| ... } ⇒ Tasker::Types::ExecutionConfig
Configure step execution and concurrency settings.
-
#health {|ConfigurationProxy| ... } ⇒ Tasker::Types::HealthConfig
Configure health check settings.
-
#initialize ⇒ Configuration
constructor
Initialize a new configuration with default values.
-
#reset! ⇒ Object
Reset configuration to defaults (useful for testing).
-
#telemetry {|TelemetryConfigurationProxy| ... } ⇒ Tasker::Types::TelemetryConfig
Configure telemetry and observability settings.
-
#validate_required_settings ⇒ true
Validate required configuration settings for system health Used by health check endpoints to ensure system is properly configured.
Constructor Details
#initialize ⇒ Configuration
Initialize a new configuration with default values
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/tasker/configuration.rb', line 88 def initialize # Initialize nested configurations using dry-struct types @auth_config = Tasker::Types::AuthConfig.new @database_config = Tasker::Types::DatabaseConfig.new @telemetry_config = Tasker::Types::TelemetryConfig.new @engine_config = Tasker::Types::EngineConfig.new @health_config = Tasker::Types::HealthConfig.new @dependency_graph_config = Tasker::Types::DependencyGraphConfig.new @backoff_config = Tasker::Types::BackoffConfig.new @execution_config = Tasker::Types::ExecutionConfig.new @cache_config = Tasker::Types::CacheConfig.new end |
Instance Method Details
#auth {|ConfigurationProxy| ... } ⇒ Tasker::Types::AuthConfig
Configure authentication and authorization settings
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/tasker/configuration.rb', line 135 def auth if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @auth_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @auth_config = Tasker::Types::AuthConfig.new(yield_config.to_h) end @auth_config end |
#authentication ⇒ Tasker::Types::AuthConfig
Alias for auth configuration for backward compatibility
148 149 150 |
# File 'lib/tasker/configuration.rb', line 148 def authentication @auth_config end |
#backoff {|ConfigurationProxy| ... } ⇒ Tasker::Types::BackoffConfig
Configure backoff calculation settings
231 232 233 234 235 236 237 238 239 240 |
# File 'lib/tasker/configuration.rb', line 231 def backoff if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @backoff_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @backoff_config = Tasker::Types::BackoffConfig.new(yield_config.to_h) end @backoff_config end |
#cache {|ConfigurationProxy| ... } ⇒ Tasker::Types::CacheConfig
Configure intelligent cache strategy settings
261 262 263 264 265 266 267 268 269 270 |
# File 'lib/tasker/configuration.rb', line 261 def cache if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @cache_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @cache_config = Tasker::Types::CacheConfig.new(yield_config.to_h) end @cache_config end |
#database {|ConfigurationProxy| ... } ⇒ Tasker::Types::DatabaseConfig
Configure database settings
156 157 158 159 160 161 162 163 164 165 |
# File 'lib/tasker/configuration.rb', line 156 def database if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @database_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @database_config = Tasker::Types::DatabaseConfig.new(yield_config.to_h) end @database_config end |
#dependency_graph {|ConfigurationProxy| ... } ⇒ Tasker::Types::DependencyGraphConfig
Configure dependency graph calculation settings
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/tasker/configuration.rb', line 216 def dependency_graph if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @dependency_graph_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @dependency_graph_config = Tasker::Types::DependencyGraphConfig.new(yield_config.to_h) end @dependency_graph_config end |
#dup ⇒ Object
Create a deep copy of the configuration
Since dry-struct types are immutable, we don't need to duplicate them
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/tasker/configuration.rb', line 117 def dup new_config = super new_config.instance_variable_set(:@auth_config, @auth_config) new_config.instance_variable_set(:@database_config, @database_config) new_config.instance_variable_set(:@telemetry_config, @telemetry_config) new_config.instance_variable_set(:@engine_config, @engine_config) new_config.instance_variable_set(:@health_config, @health_config) new_config.instance_variable_set(:@dependency_graph_config, @dependency_graph_config) new_config.instance_variable_set(:@backoff_config, @backoff_config) new_config.instance_variable_set(:@execution_config, @execution_config) new_config.instance_variable_set(:@cache_config, @cache_config) new_config end |
#engine {|ConfigurationProxy| ... } ⇒ Tasker::Types::EngineConfig
Configure core engine settings
186 187 188 189 190 191 192 193 194 195 |
# File 'lib/tasker/configuration.rb', line 186 def engine if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @engine_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @engine_config = Tasker::Types::EngineConfig.new(yield_config.to_h) end @engine_config end |
#execution {|ConfigurationProxy| ... } ⇒ Tasker::Types::ExecutionConfig
Configure step execution and concurrency settings
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/tasker/configuration.rb', line 246 def execution if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @execution_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @execution_config = Tasker::Types::ExecutionConfig.new(yield_config.to_h) end @execution_config end |
#health {|ConfigurationProxy| ... } ⇒ Tasker::Types::HealthConfig
Configure health check settings
201 202 203 204 205 206 207 208 209 210 |
# File 'lib/tasker/configuration.rb', line 201 def health if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @health_config.to_h yield_config = ConfigurationProxy.new(current_values) yield(yield_config) @health_config = Tasker::Types::HealthConfig.new(yield_config.to_h) end @health_config end |
#reset! ⇒ Object
Reset configuration to defaults (useful for testing)
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/tasker/configuration.rb', line 102 def reset! @auth_config = Tasker::Types::AuthConfig.new @database_config = Tasker::Types::DatabaseConfig.new @telemetry_config = Tasker::Types::TelemetryConfig.new @engine_config = Tasker::Types::EngineConfig.new @health_config = Tasker::Types::HealthConfig.new @dependency_graph_config = Tasker::Types::DependencyGraphConfig.new @backoff_config = Tasker::Types::BackoffConfig.new @execution_config = Tasker::Types::ExecutionConfig.new @cache_config = Tasker::Types::CacheConfig.new end |
#telemetry {|TelemetryConfigurationProxy| ... } ⇒ Tasker::Types::TelemetryConfig
Configure telemetry and observability settings
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/tasker/configuration.rb', line 171 def telemetry if block_given? # For block configuration, we need to create a new instance with the block's values current_values = @telemetry_config.to_h yield_config = TelemetryConfigurationProxy.new(current_values) yield(yield_config) @telemetry_config = Tasker::Types::TelemetryConfig.new(yield_config.to_h) end @telemetry_config end |
#validate_required_settings ⇒ true
Validate required configuration settings for system health Used by health check endpoints to ensure system is properly configured
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/tasker/configuration.rb', line 276 def validate_required_settings errors = [] # Database connectivity check errors << 'Database connection required' unless database_connected? # Authentication configuration validation (if enabled) if auth.authentication_enabled && auth.authenticator_class.blank? errors << 'Authentication enabled but no authenticator_class configured' end # Health configuration validation (dry-struct handles validation automatically) @health_config&.validate! raise StandardError, errors.join(', ') if errors.any? true end |