App-Koyomi
view release on metacpan or search on metacpan
lib/App/Koyomi/DataSource/Job.pm view on Meta::CPAN
use warnings;
use 5.010_001;
use Carp qw(croak);
use version; our $VERSION = 'v0.6.1';
sub instance { croak 'Must implement in child class!'; }
sub gets { croak 'Must implement in child class!'; }
sub get_by_id { croak 'Must implement in child class!'; }
sub create { croak 'Must implement in child class!'; }
sub update_by_id { croak 'Must implement in child class!'; }
sub delete_by_id { croak 'Must implement in child class!'; }
1;
__END__
=encoding utf8
=head1 NAME
lib/App/Koyomi/DataSource/Job.pm view on Meta::CPAN
=head1 SYNOPSIS
use parent qw(App::Koyomi::DataSource::Job);
# Your implementation goes below
sub instance { ... }
sub gets { ... }
sub get_by_id { ... }
sub create { ... }
sub update_by_id { ... }
sub delete_by_id { ... }
=head1 DESCRIPTION
Abstract datasource class for koyomi job entity.
=head1 METHODS
=over 4
lib/App/Koyomi/DataSource/Job/Teng.pm view on Meta::CPAN
};
if ($@) {
$txn->rollback;
die $@;
}
$txn->commit;
return 1;
}
sub update_by_id {
args(
my $self,
my $id => 'Int',
my $data => 'HashRef',
my $ctx => 'App::Koyomi::Context',
my $now => +{ isa => 'DateTime', optional => 1 },
);
$now ||= $ctx->now;
my $teng = $self->teng;
lib/App/Koyomi/DataSource/Semaphore/Teng/Data.pm view on Meta::CPAN
my $class,
my $row => 'Teng::Row',
my $ctx => 'App::Koyomi::Context',
);
bless +{
row => $row,
ctx => $ctx,
}, $class;
}
sub update_with_condition {
args(
my $self,
my $data => 'HashRef',
my $where => 'HashRef',
my $ctx => 'App::Koyomi::Context',
my $now => +{ isa => 'DateTime', optional => 1 },
);
$now ||= $ctx->now;
my $teng = $self->row->handle;
lib/App/Koyomi/Schedule.pm view on Meta::CPAN
ctx => $ctx,
config => $ctx->config,
jobs => undef,
last_updated_at => 0,
);
return bless \%obj, $class;
}->();
return $SCHEDULE;
}
sub update {
my $self = shift;
my $now = shift // $self->ctx->now;
if ($now->epoch - $self->last_updated_at < $self->config->{schedule}{update_interval_seconds}) {
debugf('no need to update schedule');
return;
}
debugf('update schedule');
$self->_update_jobs && $self->last_updated_at($now->epoch);
( run in 0.258 second using v1.01-cache-2.11-cpan-95122f20152 )