Symphony

module
Extended With
Symphony::MethodUtilities

Symphony – an evented asynchronous thingie.

See the README for additional guidance.

Constants

CONFIG_DEFAULTS

Default configuration

CONFIG_ENV

The name of the environment variable to check for config file overrides

DEFAULT_CONFIG_FILE

The path to the default config file

REVISION

Version-control revision constant

VERSION

Library version constant

Public Class Methods

anchor
config()

Get the loaded config (a Configurability::Config object)

# File lib/symphony.rb, line 108
def self::config
        Configurability.loaded_config
end
anchor
configure( config=nil )

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
anchor
load_config( config_file=nil, defaults=nil )

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
anchor
load_configured_tasks()

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
anchor
task_config_from_array( task_config )

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
anchor
task_config_from_hash( task_config )

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

Public Instance Methods

anchor
scaling_interval()

The maximum amount of time between task group process checks

# File lib/symphony.rb, line 69
singleton_attr_accessor :scaling_interval
anchor
tasks()

The Array of Symphony::Task classes that are configured to run

# File lib/symphony.rb, line 64
singleton_attr_accessor :tasks
anchor
throttle_factor()

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
anchor
throttle_max()

The maximum throttle factor caused by failing workers

# File lib/symphony.rb, line 53
singleton_attr_accessor :throttle_max