Files
netdisco/lib/App/Netdisco/Worker.pm
2017-09-06 20:56:26 +01:00

34 lines
746 B
Perl
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package App::Netdisco::Worker;
use strict;
use warnings;
use Module::Load ();
use Dancer ':syntax';
# load worker plugins for our workers
sub load_worker_plugins {
my ($action, $plugin_list) = @_;
foreach my $plugin (@$plugin_list) {
$plugin =~ s/^X::/+App::NetdiscoX::Worker::Plugin::/;
$plugin = 'App::Netdisco::Worker::Plugin::'. $plugin
if $plugin !~ m/^\+/;
$plugin =~ s/^\+//;
next unless $plugin =~ m/::Plugin::${action}(?:::|$)/i;
debug "loading worker plugin $plugin";
Module::Load::load $plugin;
}
}
sub import {
my ($class, $action) = @_;
load_worker_plugins( $action, setting('extra_worker_plugins') || [] );
load_worker_plugins( $action, setting('worker_plugins') || [] );
}
true;