Net-Etcd

 view release on metacpan or  search on metacpan

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


=head1 PUBLIC METHODS

=head2 grant

LeaseGrant creates a lease which expires if the server does not receive a keepAlive within
a given time to live period. All keys attached to the lease will be expired and deleted if
the lease expires. Each expired key generates a delete event in the event history.


    $etcd->lease({ ID => 7587821338341002662,  TTL => 20 })->grant

=cut

sub grant {
    my $self = shift;
    $self->{endpoint} = '/lease/grant';
    confess 'TTL and ID are required for ' . __PACKAGE__ . '->grant'
      unless ($self->{ID} &&  $self->{TTL});
    $self->request;
    return $self;
}

=head2 revoke

LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.

    $etcd->lease({ ID => 7587821338341002662 })->revoke

=cut

sub revoke {
    my $self = shift;
    $self->{endpoint} = '/kv/lease/revoke';
    confess 'ID is required for ' . __PACKAGE__ . '->revoke'
      unless $self->{ID};
    $self->request;
    return $self;
}

=head2 ttl

LeaseTimeToLive retrieves lease information.

    $etcd->lease({ ID => 7587821338341002662, keys => 1 })->ttl

=cut

sub ttl {
    my $self = shift;
    $self->{endpoint} = '/kv/lease/timetolive';
    confess 'ID is required for ' . __PACKAGE__ . '->ttl'
      unless $self->{ID};
    $self->request;
    return $self;
}


=head2 keepalive

LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client
to the server and streaming keep alive responses from the server to the client."

    $etcd->lease({{ ID => 7587821338341002662 })->keepalive

=cut

sub keepalive {
    my $self = shift;
    $self->{endpoint} = '/lease/keepalive';
    confess 'ID is required for ' . __PACKAGE__ . '->keepalive'
      unless $self->{ID};
    $self->request;
    return $self;
}

=head2 leases
lists all existing leases.

    $etcd->lease()->leases

=cut

sub leases {
    my $self = shift;
    $self->{endpoint} = '/kv/lease/leases';
    $self->{json_args} = '{}';
    $self->request;
    return $self;
}

1;



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