App-RabbitTail

 view release on metacpan or  search on metacpan

lib/App/RabbitTail/FileTailer.pm  view on Meta::CPAN

package App::RabbitTail::FileTailer;
use Moose;
use AnyEvent;
use MooseX::Types::Moose qw/CodeRef Num/;
use MooseX::Types::Path::Class qw/File/;
use Coro::Handle;
use namespace::autoclean;

has fn => (
    isa => File,
    is => 'ro',
    required => 1,
    coerce => 1,
);

has fh => (
    is => 'ro',
    lazy => 1,
    default => sub {
        my $fh = shift->fn->openr;
        seek $fh, 0, 2;
        $fh;
    },
);

has cb => (
    isa => CodeRef,
    is => 'ro',
    required => 1,
);

has _sleep_interval => (
    isa => Num,
    is => 'rw',
    default => 0,
    init_arg => undef,
);

has _next_backoff => (
    isa => Num,
    is => 'rw',
    clearer => '_clear_next_backoff',
    predicate => '_has_next_backoff',
    init_arg => undef,
);

has backoff_increment => (
    isa => Num,
    is => 'ro',
    default => 0.1,
);

has max_sleep => (
    isa => Num,
    is => 'ro',
    default => 10,
);

has _watcher => (
    is => 'rw'
);

sub tail {
    my ($self) = @_;
    $self->_watcher(AnyEvent->timer(
        after => $self->_sleep_interval,
        cb => sub {



( run in 1.952 second using v1.01-cache-2.11-cpan-e1769b4cff6 )