Class: Tasker::Types::HealthConfig

Inherits:
BaseConfig
  • Object
show all
Defined in:
lib/tasker/types/health_config.rb

Overview

Configuration type for health check settings

This configuration handles health check endpoint behavior and authentication requirements. It provides the same functionality as the original HealthConfiguration but with dry-struct type safety and immutability.

Examples:

Basic usage

config = HealthConfig.new(
  status_requires_authentication: false,
  readiness_timeout_seconds: 10.0
)

Full configuration

config = HealthConfig.new(
  status_endpoint_requires_auth: true,
  ready_requires_authentication: false,
  status_requires_authentication: true,
  readiness_timeout_seconds: 5.0,
  cache_duration_seconds: 15
)

Constant Summary collapse

BooleanType =

Custom boolean type that accepts various truthy/falsy values

Types::Bool.constructor do |value|
  case value
  when true, 'true', 'yes', '1', 1
    true
  when false, 'false', 'no', '0', 0, nil, ''
    false
  else
    !value.nil? # Convert any other truthy value to true, falsy to false
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseConfig

#initialize

Constructor Details

This class inherits a constructor from Tasker::Types::BaseConfig

Instance Attribute Details

#cache_duration_secondsInteger (readonly)

Returns Cache duration in seconds.

Returns:

  • (Integer)

    Cache duration in seconds



68
# File 'lib/tasker/types/health_config.rb', line 68

attribute :cache_duration_seconds, Types::Integer.constrained(gt: 0).default(15)

#readiness_timeout_secondsFloat (readonly)

Returns Readiness check timeout in seconds.

Returns:

  • (Float)

    Readiness check timeout in seconds



62
# File 'lib/tasker/types/health_config.rb', line 62

attribute :readiness_timeout_seconds, Types::Float.constrained(gt: 0).default(5.0)

#ready_requires_authenticationBoolean (readonly)

Returns Whether ready endpoint requires authentication.

Returns:

  • (Boolean)

    Whether ready endpoint requires authentication



50
# File 'lib/tasker/types/health_config.rb', line 50

attribute :ready_requires_authentication, BooleanType.default(false)

#status_endpoint_requires_authBoolean (readonly)

Returns Whether status endpoint requires auth.

Returns:

  • (Boolean)

    Whether status endpoint requires auth



44
# File 'lib/tasker/types/health_config.rb', line 44

attribute :status_endpoint_requires_auth, BooleanType.default(true)

#status_requires_authenticationBoolean (readonly)

Returns Whether status endpoint requires authentication.

Returns:

  • (Boolean)

    Whether status endpoint requires authentication



56
# File 'lib/tasker/types/health_config.rb', line 56

attribute :status_requires_authentication, BooleanType.default(true)

Instance Method Details

#validate!true

Validate health configuration settings

This method maintains compatibility with the original HealthConfiguration but is largely redundant since dry-struct handles validation automatically.

Returns:

  • (true)

    if valid

Raises:

  • (StandardError)

    if invalid configuration found



77
78
79
80
81
# File 'lib/tasker/types/health_config.rb', line 77

def validate!
  # dry-struct automatically validates types and constraints
  # This method is kept for backward compatibility
  true
end