| 1 | 9 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package Net::Etcd::Maintenance; | ||||||||||
| 3 | |||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | =encoding utf8 | ||||||||||
| 8 | |||||||||||
| 9 | =cut | ||||||||||
| 10 | |||||||||||
| 11 | 9 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 9 | ▶ | use Types::Standard qw(Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 9 | with 'Net::Etcd::Role::Actions'; | |||||||||
| 15 | 9 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | =head1 NAME | ||||||||||
| 18 | |||||||||||
| 19 | Net::Etcd::Maintenance | ||||||||||
| 20 | |||||||||||
| 21 | =cut | ||||||||||
| 22 | |||||||||||
| 23 | 9 | our $VERSION = '0.021'; | |||||||||
| 24 | =head1 SYNOPSIS | ||||||||||
| 25 | |||||||||||
| 26 | # defrag member's backend database | ||||||||||
| 27 | $defrag = $etcd->maintenance()->defragment; | ||||||||||
| 28 | |||||||||||
| 29 | # check status | ||||||||||
| 30 | $status = $etcd->maintenance()->status; | ||||||||||
| 31 | |||||||||||
| 32 | # member version | ||||||||||
| 33 | $status = $etcd->version; | ||||||||||
| 34 | |||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||
| 36 | |||||||||||
| 37 | Provides support for maintenance related actions. | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | |||||||||||
| 41 | =head1 ACCESSORS | ||||||||||
| 42 | |||||||||||
| 43 | =head2 endpoint | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | 9 | has endpoint => ( | |||||||||
| 48 | is => 'rwp', | ||||||||||
| 49 | isa => Str, | ||||||||||
| 50 | ); | ||||||||||
| 51 | |||||||||||
| 52 | =head1 PUBLIC METHODS | ||||||||||
| 53 | |||||||||||
| 54 | =head2 snapshot | ||||||||||
| 55 | |||||||||||
| 56 | Snapshot sends a snapshot of the entire backend from a member over a stream to a client. | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | sub snapshot { | ||||||||||
| 61 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||
|
Subroutine
snapshot: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 62 | 0 | ▶ | my $cb = pop if ref $_[-1] eq 'CODE'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $self->{endpoint} = '/maintenance/snapshot'; | |||||||||
| 64 | 0 | $self->{json_args} = '{}'; | |||||||||
| 65 | 0 | $self->request; | |||||||||
| 66 | 0 | return $self; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | =head2 status | ||||||||||
| 70 | |||||||||||
| 71 | Status gets the status of the member. | ||||||||||
| 72 | |||||||||||
| 73 | =cut | ||||||||||
| 74 | |||||||||||
| 75 | sub status { | ||||||||||
| 76 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||
|
Subroutine
status: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 77 | 0 | ▶ | my $cb = pop if ref $_[-1] eq 'CODE'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | $self->{endpoint} = '/maintenance/status'; | |||||||||
| 79 | 0 | $self->{json_args} = '{}'; | |||||||||
| 80 | 0 | $self->request; | |||||||||
| 81 | 0 | return $self; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | =head2 defragment | ||||||||||
| 85 | |||||||||||
| 86 | Defragment defragments a member's backend database to recover storage space. | ||||||||||
| 87 | |||||||||||
| 88 | =cut | ||||||||||
| 89 | |||||||||||
| 90 | sub defragment { | ||||||||||
| 91 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||
|
Subroutine
defragment: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 92 | 0 | ▶ | my $cb = pop if ref $_[-1] eq 'CODE'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | 0 | $self->{endpoint} = '/maintenance/defragment'; | |||||||||
| 94 | 0 | $self->{json_args} = '{}'; | |||||||||
| 95 | 0 | $self->request; | |||||||||
| 96 | 0 | return $self; | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | =head2 version | ||||||||||
| 100 | |||||||||||
| 101 | Returns the member version. | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | sub version { | ||||||||||
| 106 | 0 | ▶ | my ( $self, $options ) = @_; | ||||||||
|
Subroutine
version: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 107 | 0 | ▶ | my $cb = pop if ref $_[-1] eq 'CODE'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 108 | 0 | my $status = $self->status; | |||||||||
| 109 | 0 | ▶ | if ( $status->is_success ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | 0 | return $status->content->{version}; | |||||||||
| 111 | } | ||||||||||
| 112 | 0 | return; | |||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | 9 | 1; | |||||||||