NAME

Zonemaster::Backend::Config::DCPlugin - Daemon::Control plugin that loads the backend configuration.

SYNOPSIS

Provides validated and sanity-checked backend configuration through the config, db and pm properties.

my $daemon = Daemon::Control
    ->with_plugins('+Zonemaster::Backend::Config::DCPlugin')
    ->new({
        program => sub {
            my $self = shift;

            $self->init_backend_config();

            my $config = $self->config;
            my $db     = $self->db;
            my $pm     = $self->pm;
            ...
        },
    });

No configuration is loaded automatically. Instead a successful call to init_backend_config() is required.

On restart the reload_config() method is called automatically.

AUTHOR

Mattias P, <mattias.paivarinta@iis.se>

INSTANCE METHODS

init_backend_config

Initializes or reinitializes the config, db and pm properties.

A candidate for the config property is either accepted as an argument, or Zonemaster::Backend::Config::load_config is invoked to provide one. Candidates for the db and pm properties are constructed according to the config candidate.

Returns 1 if all candidates are successfully constructed. In this case all properties are assigned their respective candidate values.

Returns 0 if the construction of any one of the candidates fails. Details about the construction failure are logged. None of the properties are updated.

PROPERTIES

config

Getter for the currently loaded configuration.

Throws an exception if no successful call to init_backend_config() has been made prior to this call.

db

Getter for a database adapter constructed according to the current configuration.

Throws an exception if no successful call to init_backend_config() has been made prior to this call.

pm

Getter for a processing manager constructed according to the current configuration.

Throws an exception if no successful call to init_backend_config() has been made prior to this call.