hydra-notify: respond to cached_build_queued

This commit is contained in:
Graham Christensen
2022-01-10 20:23:48 -05:00
parent 6b7f1da11e
commit 42edd3a9d8
6 changed files with 186 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package Hydra::Event;
use strict;
use warnings;
use Hydra::Event::CachedBuildFinished;
use Hydra::Event::CachedBuildQueued;
use Hydra::Event::BuildFinished;
use Hydra::Event::BuildQueued;
use Hydra::Event::BuildStarted;
@ -14,6 +15,7 @@ my %channels_to_events = (
step_finished => \&Hydra::Event::StepFinished::parse,
build_finished => \&Hydra::Event::BuildFinished::parse,
cached_build_finished => \&Hydra::Event::CachedBuildFinished::parse,
cached_build_queued => \&Hydra::Event::CachedBuildQueued::parse,
);

View File

@ -0,0 +1,59 @@
package Hydra::Event::CachedBuildQueued;
use strict;
use warnings;
sub parse :prototype(@) {
if (@_ != 2) {
die "cached_build_queued: payload takes two arguments, but ", scalar(@_), " were given";
}
my @failures = grep(!/^\d+$/, @_);
if (@failures > 0) {
die "cached_build_queued: payload arguments should be integers, but we received the following non-integers:", @failures;
}
my ($evaluation_id, $build_id) = map int, @_;
return Hydra::Event::CachedBuildQueued->new($evaluation_id, $build_id);
}
sub new {
my ($self, $evaluation_id, $build_id) = @_;
return bless {
"evaluation_id" => $evaluation_id,
"build_id" => $build_id,
"evaluation" => undef,
"build" => undef,
}, $self;
}
sub interestedIn {
my ($self, $plugin) = @_;
return int(defined($plugin->can('cachedBuildQueued')));
}
sub load {
my ($self, $db) = @_;
if (!defined($self->{"build"})) {
$self->{"build"} = $db->resultset('Builds')->find($self->{"build_id"})
or die "build $self->{'build_id'} does not exist\n";
}
if (!defined($self->{"evaluation"})) {
$self->{"evaluation"} = $db->resultset('JobsetEvals')->find($self->{"evaluation_id"})
or die "evaluation $self->{'evaluation_id'} does not exist\n";
}
}
sub execute {
my ($self, $db, $plugin) = @_;
$self->load($db);
$plugin->cachedBuildQueued($self->{"evaluation"}, $self->{"build"});
return 1;
}
1;

View File

@ -36,6 +36,12 @@ sub instantiate {
# my ($self, $build) = @_;
# }
# # Called when build $build has been queued again by evaluation $evaluation
# where $build has not yet finished.
# sub cachedBuildQueued {
# my ($self, $evaluation, $build) = @_;
# }
# # Called when build $build is a finished build, and is
# part evaluation $evaluation
# sub cachedBuildFinished {

View File

@ -97,6 +97,7 @@ $listener->subscribe("build_finished");
$listener->subscribe("build_queued");
$listener->subscribe("build_started");
$listener->subscribe("cached_build_finished");
$listener->subscribe("cached_build_queued");
$listener->subscribe("hydra_notify_dump_metrics");
$listener->subscribe("step_finished");