lib/Myriad/Redis/Pending.pm

filter: Statementstmt 100% 3 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 4 / 4 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« lib/Myriad/RPC/Message.pm ↑ Summary lib/Myriad/Role/Storage.pm »
1 package Myriad::Redis::Pending;
2  
3 3 ▶use Myriad::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 our $VERSION = '1.001'; # VERSION
6 our $AUTHORITY = 'cpan:DERIV'; # AUTHORITY
7  
8 =encoding utf8
9  
10 =head1 NAME
11  
12 Myriad::Redis::Pending
13  
14 =head1 SYNOPSIS
15  
16 =head1 DESCRIPTION
17  
18 =cut
19  
20 has $redis;
21 has $stream;
22 has $group;
23 has $id;
24 has $finished;
25  
26 BUILD (%args) {
27 $redis = $args{redis} // die 'need a redis';
28 $stream = $args{stream} // die 'need a stream';
29 $group = $args{group} // die 'need a group';
30 $id = $args{id} // die 'need an id';
31 $finished = $redis->loop->new_future->on_done($self->curry::weak::finish);
32 }
33  
34 =head2 finished
35  
36 Returns a L<Future> representing the state of this message - C<done> means that
37 it has been acknowledged.
38  
39 =cut
40  
41 method finished () { $finished }
42  
43 =head2 finish
44  
45 Should be called once processing is complete.
46  
47 This is probably in the wrong place - better to have this as a simple abstract class.
48  
49 =cut
50  
51 async method finish () {
52 await $redis->xack($stream, $group, $id)
53 }
54  
55 1;
56  
57 =head1 AUTHOR
58  
59 Deriv Group Services Ltd. C<< DERIV@cpan.org >>.
60  
61 See L<Myriad/CONTRIBUTORS> for full details.
62  
63 =head1 LICENSE
64  
65 Copyright Deriv Group Services Ltd 2020-2022. Licensed under the same terms as Perl itself.
66  
« lib/Myriad/RPC/Message.pm ↑ Summary lib/Myriad/Role/Storage.pm »