NAME
Zing::Worker - Worker Process
ABSTRACT
Worker Process
SYNOPSIS
package MyApp;
use parent 'Zing::Worker';
sub handle {
my ($name, $data) = @_;
[$name, $data];
}
sub perform {
time;
}
sub queues {
['todos'];
}
sub receive {
my ($self, $from, $data) = @_;
[$from, $data];
}
package main;
my $myapp = MyApp->new;
# $myapp->execute;
DESCRIPTION
This package provides a Zing::Process which listens to one or more queues calls the handle
method for each new message received. The standard process perform
and receive
methods operate as expected.
INHERITS
This package inherits behaviors from:
LIBRARIES
This package uses type constraints from:
SCENARIOS
This package supports the following scenarios:
handle
# given: synopsis
$myapp->handle('todos', { todo => 'rebuild' });
The handle method is meant to be implemented by a subclass and is automatically invoked when a message is received from a defined queue.
perform
# given: synopsis
$myapp->perform;
The perform method is meant to be implemented by a subclass and is automatically invoked iteratively by the event-loop.
queues
# given: synopsis
$myapp->queues;
The queues method is meant to be implemented by a subclass and is automatically invoked when the process is executed.
receive
# given: synopsis
$myapp->receive($myapp->name, { status => 'ok' });
The receive method is meant to be implemented by a subclass and is automatically invoked iteratively by the event-loop.
AUTHOR
Al Newkirk, awncorp@cpan.org
LICENSE
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".