Mojolicious/Plugin/Prometheus/Guard.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 27 / 27 CC 3 SCAR 4.1
CC
3
Cov
100%
_change
2.0
_fetch
2.0
BEGIN
1.0
CRAP 1.5
« Prometheus/MetricRenderer.pm ↑ Summary
1 package Mojolicious::Plugin::Prometheus::Guard;
2 12 ▶use Mojo::Base -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 12 ▶use Fcntl ':flock';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Sereal qw(get_sereal_decoder get_sereal_encoder);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 has 'share';
8  
9 13 ▶sub _change($self, $cb) {
Subroutine _change: called CC=2 SCAR=6.9
10 13 $self->share->lock(LOCK_EX);
11  
12 13 my $stats = $self->_fetch;
13 13 $cb->($_) for $stats;
14 13 $self->_store($stats);
15  
16 13 $self->share->unlock;
17 }
18  
19 39 ▶sub _fetch($self) {
Subroutine _fetch: called CC=2 SCAR=6.9
20 39 ▶ return {} unless my $data = $self->share->fetch;
Branch: 1 branch
BranchTrueFalseTotal
unless my $data = $self->share->fetch 10 29 39
21 29 return get_sereal_decoder->decode($data);
22 }
23  
24 13 ▶sub _store($self, $value) {
Subroutine _store: called CC=1 SCAR=0.0
25 13 $self->share->store(get_sereal_encoder->encode($value));
26 }
27  
28 12 1;
« Prometheus/MetricRenderer.pm ↑ Summary