刘刊 > pantheon > Cronos::Policy

Download:
pantheon-0.58.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

SYNOPSIS ^

 use Cronos::Policy;

 Cronos::Policy->new( $conf )->dump( $cache );

 my $policy = Cronos::Policy->load( $cache );
 my $now = time;
 my $level = 2;

 $policy->set( $now - 86400, $now + 86400 );

 my $who = $policy->get( $now, $level );
 my %list = $policy->list( $level );

CONFIGURATION ^

A YAML file that contains a stream of site definitions, each a HASH with the following keys:

required:

 pivot: a date expression, for rotation
 queue: a list of items to rotate through

optional:

 site: default '', name of site
 period: default 1
 timezone: default 'local'
 duration: default '00:00 ~ 23:59'
 day: days of coverage, default all
 level: levels of coverage, default all
 reverse: default 0, reverse escalation order if 1

Coverage is processed in sequential order until met or defaulted to the last site ( or in reverse order, and default to the first site if 'reverse' is set )

Hence duration, level, and day do not apply to the default site.

example:

 ---
 site: cn
 pivot: 2013.12.23
 queue:
 - huey
 - dewey
 - louie
 ---
 site: us
 pivot: 2013.12.23 20:00
 timezone: America/Los_Angeles
 duration: '19:10 ~ 7:20'
 period: 7
 level: [ 1, 2 ]
 day: [ 1, 2, 3, 4, 5 ]
 queue:
 - tom
 - dick
 - harry

METHODS ^

load( $path )

Loads object from $path

dump( $path )

Dumps object to $path

set( $begin, $end )

Sets the scope

get( $time, $level )

Returns the event at $time for $level

list( $level )

Returns a HASH of events indexed by time for $level

syntax highlighting: