eval_started event: change interface to traceID\tjobsetID
I was not going to break the interface until I noticed the current implementation uses the string literal \t.
This commit is contained in:
@ -7,6 +7,7 @@ use Hydra::Event::BuildQueued;
|
||||
use Hydra::Event::BuildStarted;
|
||||
use Hydra::Event::CachedBuildFinished;
|
||||
use Hydra::Event::CachedBuildQueued;
|
||||
use Hydra::Event::EvalStarted;
|
||||
use Hydra::Event::StepFinished;
|
||||
|
||||
my %channels_to_events = (
|
||||
@ -15,6 +16,7 @@ my %channels_to_events = (
|
||||
build_started => \&Hydra::Event::BuildStarted::parse,
|
||||
cached_build_finished => \&Hydra::Event::CachedBuildFinished::parse,
|
||||
cached_build_queued => \&Hydra::Event::CachedBuildQueued::parse,
|
||||
eval_started => \&Hydra::Event::EvalStarted::parse,
|
||||
step_finished => \&Hydra::Event::StepFinished::parse,
|
||||
);
|
||||
|
||||
|
53
src/lib/Hydra/Event/EvalStarted.pm
Normal file
53
src/lib/Hydra/Event/EvalStarted.pm
Normal file
@ -0,0 +1,53 @@
|
||||
package Hydra::Event::EvalStarted;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub parse :prototype(@) {
|
||||
unless (@_ == 2) {
|
||||
die "eval_started: payload takes two arguments, but ", scalar(@_), " were given";
|
||||
}
|
||||
|
||||
my ($trace_id, $jobset_id) = @_;
|
||||
|
||||
unless ($jobset_id =~ /^\d+$/) {
|
||||
die "eval_started: payload argument should be an integer, but '", $jobset_id, "' was given"
|
||||
}
|
||||
|
||||
return Hydra::Event::EvalStarted->new($trace_id, int($jobset_id));
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($self, $trace_id, $jobset_id) = @_;
|
||||
return bless {
|
||||
"trace_id" => $trace_id,
|
||||
"jobset_id" => $jobset_id,
|
||||
"jobset" => undef
|
||||
}, $self;
|
||||
}
|
||||
|
||||
sub interestedIn {
|
||||
my ($self, $plugin) = @_;
|
||||
return int(defined($plugin->can('evalStarted')));
|
||||
}
|
||||
|
||||
sub load {
|
||||
my ($self, $db) = @_;
|
||||
|
||||
if (!defined($self->{"jobset"})) {
|
||||
$self->{"jobset"} = $db->resultset('Jobsets')->find({ id => $self->{"jobset_id"}})
|
||||
or die "Jobset $self->{'jobset_id'} does not exist\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, $db, $plugin) = @_;
|
||||
|
||||
$self->load($db);
|
||||
|
||||
$plugin->evalStarted($self->{"trace_id"}, $self->{"jobset"});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
@ -31,6 +31,12 @@ sub instantiate {
|
||||
# See the tests in t/Event/*.t for arguments, and the documentation for
|
||||
# notify events for semantics.
|
||||
#
|
||||
|
||||
# # Called when an evaluation of $jobset has begun.
|
||||
# sub evalStarted {
|
||||
# my ($self, $traceID, $jobset) = @_;
|
||||
# }
|
||||
|
||||
# # Called when build $build has been queued.
|
||||
# sub buildQueued {
|
||||
# my ($self, $build) = @_;
|
||||
|
@ -861,7 +861,7 @@ sub checkJobset {
|
||||
my $tmpId = "${startTime}.$$";
|
||||
|
||||
$db->storage->dbh->do("notify eval_started, ?", undef,
|
||||
join('\t', $tmpId, $jobset->get_column('project'), $jobset->name));
|
||||
join("\t", $tmpId, $jobset->get_column('id')));
|
||||
|
||||
eval {
|
||||
checkJobsetWrapped($jobset, $tmpId);
|
||||
|
@ -98,6 +98,7 @@ $listener->subscribe("build_queued");
|
||||
$listener->subscribe("build_started");
|
||||
$listener->subscribe("cached_build_finished");
|
||||
$listener->subscribe("cached_build_queued");
|
||||
$listener->subscribe("eval_started");
|
||||
$listener->subscribe("hydra_notify_dump_metrics");
|
||||
$listener->subscribe("step_finished");
|
||||
|
||||
|
Reference in New Issue
Block a user