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

NAME

Piper::Role::Segment - Base role for pipeline segments

DESCRIPTION

This role contains attributes and methods that apply to each pipeline segment, both individual process handlers (Piper::Process) and pipelines (Piper).

REQUIRES

init

This role requires the definition of an init method which initializes the segment as a pipeline instance and prepares it for data processing. The method must return the created pipeline instance.

ATTRIBUTES

allow

An optional coderef used to subset the items which are allowed to be processed by the segment.

The coderef runs on each item attempting to queue to the segment. If it returns true, the item is queued. Otherwise, the item skips the segment and proceeds to the next adjacent segment.

Each item is localized to $_, and is also passed in as the first argument. These example allow subroutines are equivalent:

    # This segment only accepts digit inputs
    sub { /^\d+$/ }
    sub { $_ =~ /^\d+$/ }
    sub { $_[0] =~ /^\d+$/ }

batch_size

The number of items to process at a time for the segment. Once initialized, a segment inherits the batch_size of its parent(s) if not provided.

config

A Piper::Config object defining component classes and global defaults.

This attribute is set according to the import options provided to use Piper.

debug

Debug level for this segment.

enabled

Boolean indicating that the segment is enabled and can accept items for processing. Defaults to true.

id

A globally unique ID for the segment. This is primarily useful for debugging only.

label

A label for this segment. If no label is provided, the segment's id will be used.

Labels are necessary if any handlers wish to use the injectAt or injectAfter methods (described in Piper or Piper::Process documentation). Otherwise, labels are primarily useful for logging and/or debugging (see Piper::Logger).

verbose

Verbosity level for this segment.

METHODS

clear_batch_size

Clears any assigned batch_size for the segment.

clear_debug

Clears any assigned debug level for the segment.

clear_enabled

Clears any assigned enabled setting for the segment.

clear_verbose

Clears any assigned verbose level for the segment.

has_allow

A boolean indicating whether or not an allow attribute exists for this segment.

has_batch_size

A boolean indicating whether the segment has an assigned batch_size.

has_debug

A boolean indicating whether the segment has an assigned debug level.

has_enabled

A boolean indicating whether the segment has an assigned enabled setting.

has_verbose

A boolean indicating whether the segment has an assigned verbose level.

SEE ALSO

Piper
Piper::Process
Piper::Instance
Piper::Logger
Piper::Config

VERSION

version 0.05

AUTHOR

Mary Ehlers <ehlers@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Mary Ehlers.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004