Use OO-style plugins
This is mostly so we don't have to pass around common parameters like "db" and "config", and we don't have to check for the existence of methods. A plugin now looks like this: package Hydra::Plugin::TwitterNotification; use parent 'Hydra::Plugin'; sub buildFinished { my ($self, $build, $dependents) = @_; print STDERR "tweeting about build ", $build->id, "\n"; # Send tweet... # Hydra database is $self->{db}. }
This commit is contained in:
@ -1,14 +1,23 @@
|
||||
package Hydra::Plugin;
|
||||
|
||||
use strict;
|
||||
use Module::Pluggable
|
||||
search_path => "Hydra::Plugin",
|
||||
require => 1;
|
||||
instantiate => 'new';
|
||||
|
||||
sub new {
|
||||
my ($class, %args) = @_;
|
||||
my $self = { db => $args{db}, config => $args{config} };
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
# $plugin->buildFinished($db, $config, $build, $dependents):
|
||||
#
|
||||
# Called when build $build has finished. If the build failed, then
|
||||
# $dependents is an array ref to a list of builds that have also
|
||||
# failed as a result (i.e. because they depend on $build or a failed
|
||||
# dependeny of $build).
|
||||
sub buildFinished {
|
||||
my ($self, $build, $dependents) = @_;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user