The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Schedule::Depend::Config

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

SYNOPSIS

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

                ...
        }

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 Schedule::Depend::Execute

KNOWN BUGS

None, yet.

2DO

Add the global and local sections as paramters to moduleconfig.

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.