App-Config-Chronicle
view release on metacpan or search on metacpan
lib/App/Config/Chronicle.pm view on Meta::CPAN
use Moose;
use namespace::autoclean;
use YAML::XS qw(LoadFile);
use App::Config::Chronicle::Attribute::Section;
use App::Config::Chronicle::Attribute::Global;
use Data::Hash::DotNotation;
use Data::Chronicle::Reader;
use Data::Chronicle::Writer;
use Data::Chronicle::Subscriber;
=head2 REDIS_HISTORY_TTL
The maximum length of time (in seconds) that a cached history entry will stay in Redis.
=cut
use constant REDIS_HISTORY_TTL => 7 * 86400; # 7 days
=head2 definition_yml
The YAML file that store the configuration
=cut
has definition_yml => (
is => 'ro',
isa => 'Str',
required => 1,
);
=head2 chronicle_reader
The chronicle store that configurations can be fetch from it. It should be an instance of L<Data::Chronicle::Reader>.
But user is free to implement any storage backend he wants if it is implemented with a 'get' method.
=cut
has chronicle_reader => (
is => 'ro',
isa => 'Data::Chronicle::Reader',
required => 1,
);
=head2 chronicle_writer
The chronicle store that updated configurations can be stored into it. It should be an instance of L<Data::Chronicle::Writer>.
But user is free to implement any storage backend he wants if it is implemented with a 'set' method.
=cut
has chronicle_writer => (
is => 'rw',
isa => 'Data::Chronicle::Writer',
);
=head2 chronicle_subscriber
The chronicle connection that can notify via callbacks when particular configuration items have a new value set. It should be an instance of L<Data::Chronicle::Subscriber>.
=cut
has chronicle_subscriber => (
is => 'ro',
isa => 'Data::Chronicle::Subscriber'
);
has setting_namespace => (
is => 'ro',
isa => 'Str',
default => 'app_settings',
);
has setting_name => (
is => 'ro',
isa => 'Str',
required => 1,
default => 'settings1',
);
=head2 refresh_interval
How much time (in seconds) should pass between L<check_for_update> invocations until
it actually will do (a bit heavy) lookup for settings in redis.
Default value is 10 seconds
=cut
has refresh_interval => (
is => 'ro',
isa => 'Num',
required => 1,
default => 10,
);
has _updated_at => (
is => 'rw',
isa => 'Num',
required => 1,
default => 0,
);
# definitions database
has _defdb => (
is => 'rw',
lazy => 1,
default => sub { LoadFile(shift->definition_yml) },
);
has 'data_set' => (
is => 'ro',
lazy_build => 1,
);
sub _build_class {
my $self = shift;
$self->_create_attributes($self->_defdb, $self);
return;
( run in 0.760 second using v1.01-cache-2.11-cpan-5623c5533a1 )