Class: Makit::Configuration::Timeout

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/configuration/timeout.rb

Overview

Configuration for timeouts across the makit system

Constant Summary collapse

DEFAULTS =

Default timeout values for different operations

{
  # Command execution timeouts
  command: 300,
  git_clone: 300,
  git_pull: 120,
  bundle_install: 300,
  dotnet_build: 300,
  dotnet_publish: 300,
  dotnet_test: 180,
  dotnet_restore: 120,
  protoc_generate: 60,
  gem_build: 300,
  gem_install: 120,

  # Strategy timeouts
  childprocess: 30,
  open3: 30,

  # Example execution timeout
  example: 30,
}.freeze

Class Method Summary collapse

Class Method Details

.all_timeoutsHash

Get all configured timeouts

Returns:

  • (Hash)

    all timeout configurations



57
58
59
# File 'lib/makit/configuration/timeout.rb', line 57

def self.all_timeouts
  DEFAULTS.dup
end

.default_for(operation) ⇒ Integer

Get the default timeout for a specific operation

Parameters:

  • operation (Symbol)

    the operation type

Returns:

  • (Integer)

    timeout in seconds



34
35
36
# File 'lib/makit/configuration/timeout.rb', line 34

def self.default_for(operation)
  DEFAULTS[operation] || DEFAULTS[:command]
end

.global_defaultInteger

Get the global default timeout from environment or fallback

Returns:

  • (Integer)

    global default timeout in seconds



41
42
43
# File 'lib/makit/configuration/timeout.rb', line 41

def self.global_default
  ENV["MAKIT_DEFAULT_TIMEOUT"]&.to_i || DEFAULTS[:command]
end

.set_timeout(operation, timeout) ⇒ void

This method returns an undefined value.

Set a custom timeout for an operation

Parameters:

  • operation (Symbol)

    the operation type

  • timeout (Integer)

    timeout in seconds



50
51
52
# File 'lib/makit/configuration/timeout.rb', line 50

def self.set_timeout(operation, timeout)
  DEFAULTS[operation] = timeout
end

.validate_timeout(timeout) ⇒ Object

Validate a timeout value

Parameters:

  • timeout (Integer)

    timeout to validate

Raises:

  • (ArgumentError)

    if timeout is invalid



65
66
67
68
69
70
71
# File 'lib/makit/configuration/timeout.rb', line 65

def self.validate_timeout(timeout)
  raise ArgumentError, "Timeout must be a positive integer" unless timeout.is_a?(Integer) && timeout.positive?

  return unless timeout > 3600 # 1 hour max

  raise ArgumentError, "Timeout cannot exceed 3600 seconds (1 hour)"
end