NAME
Pipeline::Config - configuration files for building Pipelines.
SYNOPSIS
use Error qw( :try );
use Pipeline::Config;
my $config = Pipeline::Config->new();
try {
my $pipe = $config->load( 'somefile.type' );
my $pipe2 = $config->load( 'somefile', 'type' );
} catch Error with {
print shift;
}
DESCRIPTION
Pipeline::Config lets you specify the structure of a Pipeline in a configuration file. This means you don't have to use() every Segment, call its constructor, and add it to the pipeline, because Pipeline::Config does it for you. It also means the flow of logic through your Pipeline is in one place, in a format that is easily read.
"How nice", you say? Well, this all assumes you have relatively simple Pipeline Segments that don't need lots of configuration. If you don't, then maybe this module is not for you.
Pipeline::Config
is the frontend to various types of pipeline configuration files.
SUPPORTED FILE TYPES
At the moment, only YAML
is supported.
METHODS
- $class->types
-
Get/set the hash of known pipeline config types & their class names. This is used to lookup & load config classes. If you write your own config parser you should register it like this:
Pipeline::Config->types->{type} => 'MyConfig::Type';
- $pipe = $obj->load( $file [, $type ] )
-
Load the config file given. Currently $file must be a valid path (file handles and text references are not yet supported). If $type is not passed, attempts to resolve it by seeing if the filename's suffix matches any of the known types listed in $class->types().
Throws a
Pipeline::Config::UnknownTypeError
if the type could not be resolved, or aPipeline::Config::LoadError
if there was an error loading the config file.
EXAMPLE
Here's an example YAML config file:
# Pipeline configuration file
---
search-packages:
- MyApp::Segment
pipeline:
- MyApp::Segment::Foo
# you don't have to name segments explicitly
# if you're using search-packages:
- Foo
- this is a sub pipe:
# anything with the word 'pipe' creates a new Pipeline
# named sub-pipes are not yet supported
- another sub pipe:
- DeclineNoBar
- GetDrink
# this calls the 'foo' method with 'bar' as an argument:
- Baz: { foo: "bar" }
- AnotherApp::Segment::GoFish
cleanups:
# if you really need to, set cleanup segments here...
- Cleanup::Segment
AUTHOR
Steve Purkis <spurkis@epn.nu>
COPYRIGHT
Copyright (c) 2003 Steve Purkis. All rights reserved. Released under the same license as Perl itself.