Zapp::Task - Base class for individual steps in a job


version 0.005


    package My::Task::Greet;
    use Mojo::Base 'Zapp::Task', -signatures;

    # Perform the task
    sub run( $self, $input ) {
        return $self->fail( 'No-one to greet' ) if !$input->{who};
        return $self->finish({
            greeting => "Hello, $input->{who}!",


    @@ input.html.ep
    %# Display the form to configure this task
    %= text_field 'who', value => $input->{who}

    @@ output.html.ep
    %# Show the result of this task
    %# XXX: Switch to $task->{error} if it's an actual error
    % if ( !ref $task->{output} ) {
        <p>I couldn't send a greeting: <%= $task->{output} %></p>
    % }
    % else {
        <p>I sent a greeting of <q><%= $task->{output}{greeting} %></q></p>
    % }


Zapp::Task is the base class for all tasks. Tasks are the individual steps of a job. Each task has an input template to configure its input and an output template to display its output. Task input and output are declared with JSON Schema (see the "schema" method), and input will be processed with Zapp::Formula before being given to "run".

Creating a Task

To create a task, start by extending this class. Create a run method that takes one argument, $input. Inside this method, do the work you want to do. Then, in the DATA section of your module, create two templates: input.html.ep for the input form, and output.html.ep for the output display.

The input form should have a set of fields. Field names will be used as the keys to the $input hash reference given to the run method. You can build complex data structures using [\d] to make arrays and . to nest hashes (see "build_data_from_params" in Zapp::Util).

    <!-- { name => 'Planet Express', loc => { city => 'New New York' } } -->
    <input name="name" value="Planet Express">
    <input name="" value="New New York">

Input forms can also use special data-zapp-* attributes to add dynamic features without writing the JavaScript yourself. See "parse_zapp_attrs" in Mojo::Util.

Your run method should do the actual work, and then call either finish (for success) or fail (for failure) with the output data. This data will be given to the output.html.ep template for display.


Zapp::Task::Action, Minion::Job, Zapp


Doug Bell <>


This software is copyright (c) 2021 by Doug Bell.

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