package Whostmgr::360Monitoring::Config;

use cPstrict;

=head1 MODULE

C<Whostmgr::360Monitoring::Config>

=head1 DESCRIPTION

C<Whostmgr::360Monitoring::Config> is used to load the configuration file for the 360 monitoring plugin.
This file contains various configuration options that are used by the plugin and its components.

=head1 SYNOPSIS

  use  Whostmgr::360Monitoring::Config();
  my $config = Whostmgr::360Monitoring::Config::load();

=head1 PRIVATE PROPERTIES

=head2 $_config

The cached configuration.

=cut

my $_config;

=head1 METHODS

=head2 load

Load the configuration. If already loaded, it will return the cached configuration..

=cut

sub load {
    if ( !$_config ) {

        my $config_file = '/var/cpanel/plugins/monitoring/config.yaml';
        require YAML::XS;
        $_config = YAML::XS::LoadFile($config_file)
          or die sprintf( 'Failed to load %s with error: %s', $config_file, $! );
    }
    return $_config;
}

=head2 clear_cache

Clear the cached configuration. This is useful when you want to reload the configuration file.

=cut

sub clear_cache {
    $_config = undef;
}

1;
