Symphony
– an evented asynchronous thingie.
See the README for additional guidance.
Default configuration
The name of the environment variable to check for config file overrides
The path to the default config file
Version-control revision constant
Library version constant
Get the loaded config (a Configurability::Config object)
# File lib/symphony.rb, line 108
def self::config
Configurability.loaded_config
end
Configurability API – configure the daemon.
# File lib/symphony.rb, line 127
def self::configure( config=nil )
config = self.defaults.merge( config || {} )
self.throttle_max = config[:throttle_max]
self.throttle_factor = config[:throttle_factor]
self.scaling_interval = config[:scaling_interval]
self.tasks = config[:tasks]
end
Load the specified config_file
, install the config in all objects with Configurability, and call any callbacks registered via after_configure.
# File lib/symphony.rb, line 115
def self::load_config( config_file=nil, defaults=nil )
config_file ||= ENV[ CONFIG_ENV ] || DEFAULT_CONFIG_FILE
defaults ||= Configurability.gather_defaults
self.log.info "Loading config from %p with defaults for sections: %p." %
[ config_file, defaults.keys ]
config = Configurability::Config.load( config_file, defaults )
config.install
end
Load the tasks with the specified task_names
and return them as an Array.
# File lib/symphony.rb, line 75
def self::load_configured_tasks
task_config = self.tasks
if task_config.respond_to?( :each_pair )
return self.task_config_from_hash( task_config )
else
return self.task_config_from_array( task_config )
end
end
Return the Array of tasks
as a Hash of Classes and the maximum number to run.
# File lib/symphony.rb, line 97
def self::task_config_from_array( task_config )
return [] unless task_config
return task_config.uniq.each_with_object({}) do |task_name, tasks|
max = task_config.count( task_name )
task_class = Symphony::Task.get_subclass( task_name )
tasks[ task_class ] = max
end
end
Return the Hash of tasks
as a Hash of Classes and the maximum number to run.
# File lib/symphony.rb, line 87
def self::task_config_from_hash( task_config )
return task_config.each_with_object({}) do |(task_name, max), tasks|
task_class = Symphony::Task.get_subclass( task_name )
tasks[ task_class ] = max.to_i
end
end
The maximum amount of time between task group process checks
# File lib/symphony.rb, line 69
singleton_attr_accessor :scaling_interval
The Array of Symphony::Task
classes that are configured to run
# File lib/symphony.rb, line 64
singleton_attr_accessor :tasks
The factor which controls how much incrementing the throttle factor affects the pause between workers being started.
# File lib/symphony.rb, line 59
singleton_attr_accessor :throttle_factor
The maximum throttle factor caused by failing workers
# File lib/symphony.rb, line 53
singleton_attr_accessor :throttle_max