better use of new status class
This commit is contained in:
@@ -36,4 +36,32 @@ Returns the logical inversion of C<ok>.
|
||||
|
||||
sub not_ok { return (not $_[0]->ok) }
|
||||
|
||||
=head2 status
|
||||
|
||||
Returns text equivalent of C<done>, C<defer>, or C<error>.
|
||||
|
||||
=cut
|
||||
|
||||
sub status {
|
||||
my $self = shift;
|
||||
return (
|
||||
$self->done ? 'done'
|
||||
: $self->defer ? 'defer'
|
||||
: 'error';
|
||||
);
|
||||
}
|
||||
|
||||
=head2 update_job
|
||||
|
||||
Updates an L<App::Netdisco::Backend::Job> with status and message.
|
||||
|
||||
=cut
|
||||
|
||||
sub update_job {
|
||||
my $self = shift;
|
||||
my $job = shift or return;
|
||||
$job->status( $self->status );
|
||||
$job->log( $self->message );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -39,9 +39,8 @@ sub worker_body {
|
||||
$wid, $job->job, $job->summary;
|
||||
info sprintf "pol (%s): starting %s job(%s) at %s",
|
||||
$wid, $action, $job->job, $job->started;
|
||||
my ($status, $log) = $self->$action($job);
|
||||
$job->status($status);
|
||||
$job->log($log);
|
||||
my $status = $self->$action($job); # TODO
|
||||
$status->update_job($job);
|
||||
}
|
||||
catch {
|
||||
$job->status('error');
|
||||
|
||||
Reference in New Issue
Block a user