blib/lib/Langertha/Raider/Hall/Raider.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 4 / 4 Conditioncond 87.5% 7 / 8 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 96.2% 51 / 53 CC 7 SCAR 16.5
CC
7
Cov
98%
run_finished
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« blib/lib/Langertha/Raider/Provider/Change.pm ↑ Summary blib/lib/Langertha/Raider/Plugin/Situation.pm »
1 package Langertha::Raider::Hall::Raider;
2 73 our $VERSION = '0.503';
3 # ABSTRACT: Internal record of a raider process spawned by the hall
4  
5  
6 73 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 73 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 73 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 73 has id => (is => 'ro', isa => 'Str', required => 1);
11 73 has pid => (is => 'ro', isa => 'Int', predicate => 'has_pid');
12 73 has slot_name => (is => 'ro', isa => 'Str', required => 1);
13 73 has base_name => (is => 'ro', isa => 'Str', required => 1);
14 73 has log_path => (is => 'ro', isa => 'Path::Tiny', required => 1);
15 73 has mission => (is => 'ro', isa => 'Str', required => 1);
16  
17  
18 73 has events_path => (is => 'ro', isa => 'Path::Tiny', predicate => 'has_events_path');
19  
20  
21 73 has session_id => (is => 'ro', isa => 'Str', predicate => 'has_session_id');
22 73 has binding => (is => 'ro', isa => 'Str', predicate => 'has_binding');
23  
24  
25 108 ▶sub run_finished {
Subroutine run_finished: called CC=7 SCAR=19.5
Pod documented
26 108 my ( $self ) = @_;
27 108 ▶ return unless $self->has_events_path && -f $self->events_path;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_events_path and -f $self->events_path 4 104 108
Condition100%3/3
$self->has_events_path and -f $self->events_path
!ll&&!rl&&r
31104
MC/DC100%2/2
$self->has_events_path and -f $self->events_path
$self->has_events_path -f $self->events_path
Truth table100%3/3
A and B
A= $self->has_events_pathB= -f $self->events_path
ABresult
0X0
100
111
28 104 my $json = JSON::MaybeXS->new( utf8 => 1 );
29 104 for my $line ( reverse $self->events_path->lines_raw({ chomp => 1 }) ) {
30 90 my $event = eval { $json->decode($line) };
31 90 ▶ next unless ref $event eq 'HASH' && ( $event->{type} // '' ) eq 'run.finished';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $event eq "HASH" and ($event->{"type"} // "") eq "run.finished" 5 85 90
Condition80%4/5
ref $event eq "HASH" and ($event->{"type"} // "") eq "run.finished"
!ll&&!rl&&r
1485
$event->{"type"} // ""
l!l
890
MC/DC50%1/2
ref $event eq "HASH" and ($event->{"type"} // "") eq "run.finished"
ref $event eq "HASH" $event->{"type"}
Truth table66%2/3
A and B
A= ref $event eq "HASH"B= $event->{"type"}
ABresult
0X0
100
111
32 85 delete @{$event}{qw( type seq time )};
33 85 return $event;
34 }
35 19 return;
36 }
37  
38 73 __PACKAGE__->meta->make_immutable;
39  
40 73 1;
41  
42 __END__
43  
44 =pod
45  
46 =encoding UTF-8
47  
48 =head1 NAME
49  
50 Langertha::Raider::Hall::Raider - Internal record of a raider process spawned by the hall
51  
52 =head1 VERSION
53  
54 version 0.503
55  
56 =head1 DESCRIPTION
57  
58 B<Internal module.> Its interface may change without notice.
59  
60 Data object the L<Langertha::Raider::Hall> keeps per running raider, keyed by run ID:
61 id, pid, slot and base name, log path, events path, mission and, for a
62 bound run, its session and binding.
63  
64 =head2 events_path
65  
66 The file the raider's C<--stream-json> stdout goes to, one file per run.
67 Optional; without it L</run_finished> has nothing to read.
68  
69 =head2 session_id
70  
71 The session the hall started a bound run with (C<--session ID>).
72 Unset for an unbound run, which picks its own session.
73  
74 =head2 binding
75  
76 The binding key of a bound run (C<telegram:ops:42>, C<cron:nightly>,
77 C<slot:1bjorn>, ...); see L<Langertha::Raider::Hall/session_bindings>.
78  
79 =head2 run_finished
80  
81 my $doc = $raider->run_finished; # HashRef or undef
82  
83 The payload of the last C<run.finished> event in L</events_path>: the run's
84 C<--json> document (C<version>, C<status>, C<response> or C<error>, ...),
85 without the event fields C<type>, C<seq> and C<time>. Undef when the file is
86 missing or holds no C<run.finished> -- the process was killed before it
87 could write one, for example. Lines that are not JSON objects are skipped.
88  
89 =head1 SUPPORT
90  
91 =head2 Issues
92  
93 Please report bugs and feature requests on GitHub at
94 L<https://github.com/Getty/langertha-raider/issues>.
95  
96 =head2 IRC
97  
98 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
99  
100 =head1 CONTRIBUTING
101  
102 Contributions are welcome! Please fork the repository and submit a pull request.
103  
104 =head1 AUTHOR
105  
106 Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>
107  
108 =head1 COPYRIGHT AND LICENSE
109  
110 This software is copyright (c) 2026 by Torsten Raudssus.
111  
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114  
115 =cut
« blib/lib/Langertha/Raider/Provider/Change.pm ↑ Summary blib/lib/Langertha/Raider/Plugin/Situation.pm »