NAME

Schedule::Depend::Config

Extract global and package-specifc data from a configuration hash.

SYNOPSIS

    %Schedule::Depend::Execute::defaults =
    (
        Foo => 
        {
            # global configuration
        },

        Bar =>
        {
            # local configuration
        },

        Bletch =>
        {
            # local configuration
        },

    );

    package Foo::More::Stuff::Bar;

        sub something
        {
                my $que = shift;

        # $config is result of @{S::D::E::defaults}{qw(FOO BAR)}

                my $config = $que->{user}->moduleconfig;

        my $arg = shift;

                ...
        }

    package Foo::Other::Stuff::Bletch
    
    sub something_else
    {
                my $que = shift;

        # $config is result of @{S::D::E::defaults}{qw(FOO BLETCH)}

                my $config = $que->{user}->moduleconfig;

        my $arg = shift;

        ...
    }

    package Foo::Someproj;

    sub yet_another
    {
        my $que = shift;

        # Read metadata from Foo (global) and Bletch (local).

        $config = $que->{user}->moduleconfig( 'Foo::Bletch' );
    }

or package Foo::Blort;

    use Schedule::Depend::Utilities;

    sub this
    {
        # get que and configs in one step.

        my( $que, $config ) = &handle_que_args;

        my $arg = shift;
    }

DESCRIPTION

$que->{user}

Schedule::Depend and Schedule::Depend::Execute install a "user" key into the que hash for storing arbitrary data the user jobs may need during execution.

S::D uses the constructor "configure" to build the user hash. This merges any arguments passed in with the current \%Schedule::Depend::Execute::defaults values.

moduleconfig is called in jobs to extract relavant configuration information. The basic idea is to keep data separated by module in the configuration hash to allow for data inheritence and avoid namespace collisions between modules.

Example Schedule::Depend::Execute::defaults

The configuration hash for jobs in Foobar::*::Download and Foobar::*::Unlaod would look like:

        my $config = 
        {
                Foobar =>
                {
                        # anything here is available to both
                        # Download and Unload, with tEh modules
                        # overloading it.
                        #
                        # this is used by the "localpath" utility
                        # subroutine to convert generic tokens into
                        # local paths.

                        basenames =>
                        {
                                # token => file basename
                                
                                table1 => 'table1-full.dump',
                                table2 => 'table2-partial.dump',
                        },
                },

                Download =>
                {
                        ftpbase => 'ftp://foo.bar.com',

                        ftppath =>
                        [
                                 '/pub/bletch',
                                 '/pub/morebletch',
                        ],
                },

                Unload =>
                {
                        unload_tables =>
                        [ qw(
                                table1
                                table2
                        ) ],
                },
        }

In this case calls from subroutines in Foobar::Download will get 'basenames', 'ftpbase' and 'ftppath' keys back in their configuration; calls from the Foobar::Unload package will get 'basenames' and 'unload_tables'.

Setting the global portion.

The default global and local portion of the configuraton are set via:

        ( split /::/ $caller )[0, -1]

This means that "Foobar::Frum::Download" and "Foobar::Feefie::Download" will get the same results. If this not useful then the caller can set $config->{global} prior to calling moduleconfig in order to set the global data's key:

        package Foobar::Upload;

        sub some_job
        {
                my $que = shift;

                my $user = $que->{user};

                $user->{global} = 'Baronly';

                my $config = $user->moduleconfig;

                ...
        }

Will leave $config with defaults from $user->{Baronly} and local data from "Upload".

SEE ALSO

Schedule::Depend

Definition of que object and schedule.

Schedule::Depend::Execute

runsched (top-level call for #! code).

Schedule::Depend::Utilities

handle_que_args simplifies getting the arguments.

NEXT::init

DWIM data inheritence simplifies setting up default data hashes via data inheritence.

KNOWN BUGS

None, yet.

2DO

Iterate the arguments to allow a subroutine to call moduleconfig with multiple package arguments for data sharing between packages.

AUTHOR

Steven Lembark, Workhorse Computing <lembark@wrkhors.com>

Copyright

(C) 2001-2002 Steven Lembark, Workhorse Computing

This code is released under the same terms as Perl istelf. Please see the Perl-5.8 distribution (or later) for a full description.

In any case, this code is release as-is, with no implied warranty of fitness for a particular purpose or warranty of merchantability.