The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Launcher::Cascade - a framework for launching processes that depend on one another

SYNOPSIS

    use Launcher::Cascade::Simple;
    use Launcher::Cascade::Container;

    my $launcher1 = Launcher::Cascade::Simple->new(
        -launch_hook  => sub { ... },    # what to do to launch
        -test_hook    => sub { ... },    # what to do to test that it succeeded
        );
    my $launcher2 = Launcher::Cascade::Simple->new(
        -launch_hook  => sub { ... },    # what to do to launch
        -test_hook    => sub { ... },    # what to do to test that it succeeded
        -dependencies => [ $launcher1 ], # second launcher depends on success of first
    );

    my $container = new Launcher::Cascade::Container
        -launchers => [ $launcher1, $launcher2 ];

    $container->run_session();

DESCRIPTION

This module provides a framework to launch processes, test whether they succeeded or not and report on that. Each process is modeled as an object and can depend on other processes to start, i.e., a process will not be started until all the processes it depends upon have successfully been started.

Process launchers must be implemented as Launcher::Cascade::Base objects (or subclassses thereof). Their launch() method will actually launch the process, and their test() method will check whether it succeeded or not. Each launcher can be made to depend on one or more other launchers: it will then refuse to launch() until the others have been test()ed successfully.

All the launchers should be given to a Launcher::Cascade::Container, which will run them in turn and test their status when applicable, until either all of the Launchers have succeeded or one of them has failed.

The distribution provides Launcher::Cascade::FileReader to ease the launching of external (and possibly remote, by means of ssh) commands and the reading of files. FileReaders should be used in launch() or test() methods of Launchers.

This base class provides a constructor for its subclasses that accepts named arguments, as well as function to easily create attributes and their accessors. All the real functionality has to be implemented in subclasses.

Constructor

new LIST

Creates and returns an instance. LIST should be a list of named parameters. The values will be passed to the accessors of the same name. Leading dashes will be removed from the names, and they will be converted to lowercase before invoking the accessor.

Functions

make_accessors LIST

Make accessors in the caller's namespace.

LIST should contain names of accessors. make_accessors() will generate an accessor for each name in LIST, that will return the corresponding attribute's value when called without argument, and set the attribute's value when called with an argument (in that latter case, the former value is returned). Example:

    package MyPackage;

    use Launcher::Cascade;
    our @ISA = qw/ Launcher::Cascade /; # inherits constructor

    Launcher::Cascade::make_accessors qw/ first_name last_name /;

    1;

Meanwhile, in a nearby piece of code:

    use MyPackage;

    my $object = new MyPackage -first_name => 'Zaphod';
    print $object->first_name(); # Zaphod

    print $object->last_name('Beeblebrox'); # undef
    print $object->last_name(); # Beeblebrox
read_default_file FILENAME

Reads a file containing the definition of default values for subclasses attributes. The file should contain name, value pairs, one by line, separated by an equal sign. Whitespace is ignored at the beginning or end of the line and on either side of the equal sign. Lines starting with a hash sign are ignored, as well as blank lines.

The name should be the fully qualified accessor method name, i.e., the package and name of the accessor separated by a double colon.

    # This is an example

    MyPackage::first_name = Zaphod
    MyPackage::last_name  = Beeblebrox
make_accessors_with_defaults LIST

Does the same as make_accessors(), but elements in LIST should go in pairs, accessor names together with their default values. If the attribute's value has not explicitly been set, the accessor will return the default value as read from the defaults file (see read_default_file()) or the default value provided in LIST. The defaults file overrides the value from LIST.

    package MyPackage;

    use Launcher::Cascade;
    our @ISA = qw/ Launcher::Cascade /;

    Launcher::Cascade::make_accessors_with_defaults(
        first_name => 'Zaphod',
        last_name  => 'Beeblebrox',
    );

Meanwhile, in a nearby piece of code:

    use MyPackage;
    
    my $o = new MyPackage;
    print $o->first_name(); # Zaphod

VERSION

0.02

SEE ALSO

AUTHOR

Cédric Bouvier <cbouvi@cpan.org>

COPYRIGHT & LICENSE

Copyright (C) 2006 Cédric Bouvier, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 229:

Non-ASCII character seen before =encoding in 'Cédric'. Assuming CP1252