App-HistHub

 view release on metacpan or  search on metacpan

lib/App/HistHub.pm  view on Meta::CPAN

    isa     => 'JSON::XS',
    lazy    => 1,
    default => sub {
        JSON::XS->new->latin1;
    },
);

has poll_delay => (
    is      => 'rw',
    isa     => 'Int',
    default => sub { 5 },
);

has update_queue => (
    is      => 'rw',
    isa     => 'ArrayRef',
    default => sub { [] },
);

has api_endpoint => (
    is       => 'rw',
    isa      => 'Str',
    required => 1,
);

has api_uid => (
    is  => 'rw',
    isa => 'Str',
);

=head1 NAME

App::HistHub - Sync shell history between multiple PC.

=head1 SYNOPSIS

    use App::HistHub;
    
    my $hh = App::HistHub->new(
        hist_file    => 'path to your history file',
        api_endpoint => 'http://localhost:3000/',
    );
    $hh->run;

=head1 DESCRIPTION

App::HistHub is an application that enables you to sync shell history between multiple computers.

This application consists of two modules: client module (histhubd.pl) and server module (histhub_server.pl).

You need one histhub server. To bootup the server, type following command:

    histhub_server

This server receive updating history data from one client, and broadcast to others.

You also need one client daemon in each computer that you want to share history. To boot client, type following command:

    histhubd --histfile=/path/to/your_history_file --server=http://your_server_address

This client send updated history to server, and receive new history from other clients.

=head1 METHODS

=head2 new

    my $hh = App::HistHub->new( %options );

Create HistHub object.

Available obtions are:

=over 4

=item hist_file

History file path to watch update

=item api_endpoint

Update API URL.

=back

=head2 spawn

Create POE session and return session object.

=cut

sub spawn {
    my $self = shift;

    POE::Session->create(
        object_states => [
            $self => {
                map { $_ => "poe_$_" } qw/_start init poll set_poll hist_line hist_rollover/
            },
        ],
    );
}

=head2 run

Spawn and start POE::Kernel

=cut

sub run {
    my $self = shift;
    $self->spawn;
    POE::Kernel->run;
}

=head2 uri_for

    $hh->uri_for( $path )

Build api url

=cut



( run in 0.742 second using v1.01-cache-2.11-cpan-39bf76dae61 )