Net-Etcd

 view release on metacpan or  search on metacpan

lib/Net/Etcd/Watch.pm  view on Meta::CPAN

use utf8;
package Net::Etcd::Watch;

use strict;
use warnings;

use Moo;
use Types::Standard qw(Str Int Bool HashRef ArrayRef);
use MIME::Base64;
use Data::Dumper;
use JSON;

with 'Net::Etcd::Role::Actions';

use namespace::clean;

=head1 NAME

Net::Etcd::Watch

=cut

our $VERSION = '0.022';

=head1 DESCRIPTION

Watch watches for events happening or that have happened. Both input and output are streams;
the input stream is for creating and canceling watchers and the output stream sends events.
One watch RPC can watch on multiple key ranges, streaming events for several watches at once.
The entire event history can be watched starting from the last compaction revision.

=head1 ACCESSORS

=head2 endpoint

=cut

has endpoint => (
    is      => 'ro',
    isa     => Str,
    default => '/watch'
);

=head2 key

key is the first key for the range. If range_end is not given, the request only looks up key.
the key is encoded with base64.  type bytes

=cut

has key => (
    is       => 'ro',
    isa      => Str,
    required => 1,
    coerce   => sub { return encode_base64( $_[0], '' ) }
);

=head2 range_end

range_end is the end of the range [key, range_end) to watch. If range_end is not given, only
the key argument is watched. If range_end is equal to '\0', all keys greater than or equal to
the key argument are watched.

=cut

has range_end => (
    is     => 'ro',
    isa    => Str,
    coerce => sub { return encode_base64( $_[0], '' ) }
);

=head2 start_revision

start_revision is an optional revision to watch from (inclusive). No start_revision is "now".
int64

=cut

has start_revision => (
    is  => 'ro',
    isa => Int,
);

=head2 progress_notify

progress_notify is set so that the etcd server will periodically send a WatchResponse with no
events to the new watcher if there are no recent events. It is useful when clients wish to recover
a disconnected watcher starting from a recent known revision. The etcd server may decide how often
it will send notifications based on current load.



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