use utf8;
package Hydra::Schema::Result::TaskRetries;
use strict;
use warnings;
use base 'DBIx::Class::Core';
__PACKAGE__->load_components("+Hydra::Component::ToJSON");
__PACKAGE__->table("taskretries");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
sequence => "taskretries_id_seq",
},
"channel",
{ data_type => "text", is_nullable => 0 },
"pluginname",
{ data_type => "text", is_nullable => 0 },
"payload",
{ data_type => "text", is_nullable => 0 },
"attempts",
{ data_type => "integer", is_nullable => 0 },
"retry_at",
{ data_type => "integer", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
use Hydra::Math qw(exponential_backoff);
sub requeue {
my ($self) = @_;
$self->update({
attempts => $self->attempts + 1,
retry_at => time() + exponential_backoff($self->attempts + 1),
});
}
1;