ArangoDB2/Replication.pm

filter: Statementstmt 27.4% 17 / 62 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 21.7% 5 / 23 Podpod 100% 18 / 18 totaltotal 37.3% 40 / 107 CC 3 SCAR 8.9
CC
3
Cov
26%
applierConfig
6.0
loggerFollow
6.0
applierStart
2.0
CRAP 2.4
« ArangoDB2/Traversal.pm ↑ Summary ArangoDB2/Database.pm »
1 package ArangoDB2::Replication;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 22 ▶use base qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 ArangoDB2::Base
8 22 );
9  
10 22 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 22 my $JSON = JSON::XS->new->utf8;
14  
15  
16  
17 ###############
18 # API METHODS #
19 ###############
20  
21 # applierConfig
22 #
23 # GET /_api/replication/applier-config
24 # PUT /_api/replication/applier-config
25 sub applierConfig
26 0 ▶{
Subroutine applierConfig: not called CC=2 SCAR=17.9
Pod documented
27 0 my($self, $args) = @_;
28 # process args
29 0 $args = $self->_build_args($args, ['configuration']);
30 # build path
31 0 my $path = $self->api_path('replication', 'applier-config');
32 # make request
33 return $args->{configuration}
34 0 ▶ ? $self->arango->http->put($path, $args)
Branch: 1 branch
BranchTrueFalseTotal
$args->{'configuration'} ? : 0 0 0
35 : $self->arango->http->get($path);
36 }
37  
38 # applierStart
39 #
40 # PUT /_api/replication/applier-start
41 sub applierStart
42 0 ▶{
Subroutine applierStart: not called CC=1 SCAR=6.9
Pod documented
43 0 my($self, $args) = @_;
44 # process args
45 0 $args = $self->_build_args($args, ['from']);
46 # make request
47 0 return $self->arango->http->put(
48 $self->api_path('replication', 'applier-start'),
49 $args,
50 );
51 }
52  
53 # applierState
54 #
55 # GET /_api/replication/applier-state
56 sub applierState
57 0 ▶{
Subroutine applierState: not called CC=1 SCAR=6.9
Pod documented
58 0 my($self) = @_;
59 # make request
60 0 return $self->arango->http->get(
61 $self->api_path('replication', 'applier-state'),
62 );
63 }
64  
65 # applierStop
66 #
67 # PUT /_api/replication/applier-stop
68 sub applierStop
69 0 ▶{
Subroutine applierStop: not called CC=1 SCAR=6.9
Pod documented
70 0 my($self) = @_;
71 # make request
72 0 return $self->arango->http->get(
73 $self->api_path('replication', 'applier-stop'),
74 );
75 }
76  
77 # clusterInventory
78 #
79 # GET /_api/replication/clusterInventory
80 sub clusterInventory
81 0 ▶{
Subroutine clusterInventory: not called CC=1 SCAR=6.9
Pod documented
82 0 my($self, $args) = @_;
83 # process args
84 0 $args = $self->_build_args($args, ['includeSystem']);
85 # make request
86 0 return $self->arango->http->get(
87 $self->api_path('replication', 'clusterInventory'),
88 $args,
89 );
90 }
91  
92 # dump
93 #
94 # GET /_api/replication/dump
95 sub dump
96 0 ▶{
Subroutine dump: not called CC=1 SCAR=6.9
Pod documented
97 0 my($self, $args) = @_;
98 # process args
99 0 $args = $self->_build_args($args, ['chunkSize', 'collection', 'from', 'ticks', 'to']);
100 # make request
101 0 return $self->arango->http->get(
102 $self->api_path('replication', 'dump'),
103 $args,
104 );
105 }
106  
107 # inventory
108 #
109 # GET /_api/replication/inventory
110 sub inventory
111 0 ▶{
Subroutine inventory: not called CC=1 SCAR=6.9
Pod documented
112 0 my($self, $args) = @_;
113 # process args
114 0 $args = $self->_build_args($args, ['includeSystem']);
115 # make request
116 0 return $self->arango->http->get(
117 $self->api_path('replication', 'inventory'),
118 $args,
119 );
120 }
121  
122 # loggerFollow
123 #
124 # GET /_api/replication/loggerFollow
125 sub loggerFollow
126 0 ▶{
Subroutine loggerFollow: not called CC=2 SCAR=17.9
Pod documented
127 0 my($self, $args) = @_;
128 # process args
129 0 $args = $self->_build_args($args, ['chunkSize', 'from', 'to']);
130 # make request
131 0 ▶ my $res = $self->arango->http->get(
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->get($self->api_path("replication", "logger-follow"), $args, 1) or return 0 0 0
132 $self->api_path('replication', 'logger-follow'),
133 $args,
134 1, # get raw response
135 ) or return;
136 # build our own response
137 0 my $ret = {};
138 # response is newline separated JSON log entries
139 0 $ret->{log} = [ map { $JSON->decode($_) } split(/\n/, $res->content) ];
140  
141 # get response header values
142 0 $ret->{replication}->{active} = $res->header('x-arango-replication-active');
143 0 $ret->{replication}->{checkmore} = $res->header('x-arango-replication-checkmore');
144 0 $ret->{replication}->{lastincluded} = $res->header('x-arango-replication-lastincluded');
145 0 $ret->{replication}->{lasttick} = $res->header('x-arango-replication-lasttick');
146  
147 0 return $ret;
148 }
149  
150 # loggerState
151 #
152 # GET /_api/replication/loggerState
153 sub loggerState
154 0 ▶{
Subroutine loggerState: not called CC=1 SCAR=6.9
Pod documented
155 0 my($self) = @_;
156 # make request
157 0 return $self->arango->http->get(
158 $self->api_path('replication', 'logger-state'),
159 );
160 }
161  
162 # serverId
163 #
164 # GET /_api/replication/server-id
165 sub serverId
166 0 ▶{
Subroutine serverId: not called CC=1 SCAR=6.9
Pod documented
167 0 my($self) = @_;
168 # make request
169 0 return $self->arango->http->get(
170 $self->api_path('replication', 'server-id'),
171 );
172 }
173  
174 # sync
175 #
176 # PUT /_api/replication/sync
177 sub sync
178 0 ▶{
Subroutine sync: not called CC=1 SCAR=6.9
Pod documented
179 0 my($self, $args) = @_;
180 # process args
181 0 $args = $self->_build_args($args, ['configuration']);
182 # make request
183 0 return $self->arango->http->put(
184 $self->api_path('replication', 'sync'),
185 $args,
186 );
187 }
188  
189  
190 ####################
191 # PROPERTY METHODS #
192 ####################
193  
194 # chunkSize
195 #
196 # get/set chunkSize
197 0 ▶sub chunkSize { shift->_get_set('chunkSize', @_) }
Subroutine chunkSize: not called CC=1 SCAR=6.9
Pod documented
198  
199 # collection
200 #
201 # get/set collection
202 0 ▶sub collection { shift->_get_set_name('collection', @_) }
Subroutine collection: not called CC=1 SCAR=6.9
Pod documented
203  
204 # configuration
205 #
206 # get/set configuration
207 0 ▶sub configuration { shift->_get_set('configuration', @_) }
Subroutine configuration: not called CC=1 SCAR=6.9
Pod documented
208  
209 # from
210 #
211 # get/set from
212 0 ▶sub from { shift->_get_set('from', @_) }
Subroutine from: not called CC=1 SCAR=6.9
Pod documented
213  
214 # includeSystem
215 #
216 # get/set includeSystem
217 0 ▶sub includeSystem { shift->_get_set('includeSystem', @_) }
Subroutine includeSystem: not called CC=1 SCAR=6.9
Pod documented
218  
219 # ticks
220 #
221 # get/set ticks
222 0 ▶sub ticks { shift->_get_set_bool('ticks', @_) }
Subroutine ticks: not called CC=1 SCAR=6.9
Pod documented
223  
224 #
225 #
226 # get/set
227 0 ▶sub to { shift->_get_set('', @_) }
Subroutine to: not called CC=1 SCAR=6.9
Pod documented
228  
229  
230 22 1;
231  
232 __END__
« ArangoDB2/Traversal.pm ↑ Summary ArangoDB2/Database.pm »