NAME

POEx::WorkerPool::Role::Job - Provides a role for common job semantics

VERSION

version 1.101610

SYNOPSIS

class MyJob with POEx::WorkerPool::Role::Job
{
    method init_job
    {
        # Implement job initialization across the process boundary here
    }
}

DESCRIPTION

POEx::WorkerPool::Role::Job provides the scaffolding required to execute arbitrary tasks within the POEx::WorkerPool framework. Consuming classes only need to implement init_job, which will be called once on the other side of the process boundary where coderefs, database handles, etc won't have survived.

Use init_job to initialize all of those ephemeral resources necessary for the job and also to populate the steps to the job.

PUBLIC_ATTRIBUTES

ID

is: ro, isa: Str

This attribute stores the unique ID for the job. By default it uses Data::UUID::create_str()

steps

traits: Array, is: ro, isa: ArrayRef[JobStep]

This attribute stores the steps for the job. All jobs must have one step before execution or else a JobError exception will be thrown.

The following handles are defined to access the steps of the job:

{
    push    => '_enqueue_step',
    shift   => 'dequeue_step',
    count   => 'count_steps',
}

PROTECTED_ATTRIBUTES

total_steps

is: ro, isa: ScalarRef

total_steps contains a scalar ref of the count of the total number of steps

PUBLIC_METHODS

enqueue_step

(JobStep $step)

enqueue_step takes a JobStep and places it into the steps collection and also increments the total_steps counter.

is_multi_step

returns (Bool)

A simple convenience method to check if the job has multiple steps

execute_step

returns (JobStatus)

execute_step dequeues a step from steps and executes it, building a proper JobStatus return value. If executing the step produces an exception, the exception class is JobError

AUTHOR

Nicholas R. Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Infinity Interactive.

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