| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Flux::Storage::Formatted; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Flux::Storage::Formatted::VERSION = '1.03'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Representation of a storage wrapped with a format. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
10
|
|
|
|
|
|
|
with 'Flux::Storage'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'format' => ( |
|
13
|
|
|
|
|
|
|
is => 'ro', |
|
14
|
|
|
|
|
|
|
required => 1, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'storage' => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
required => 1, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub write { |
|
23
|
2
|
|
|
2
|
0
|
2503
|
my $self = shift; |
|
24
|
2
|
|
|
|
|
4
|
my ($item) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
15
|
my @mapped = $self->format->encoder->write($item); |
|
27
|
2
|
50
|
|
|
|
30
|
return unless @mapped; |
|
28
|
2
|
|
|
|
|
16
|
$self->storage->write($_, @_) for @mapped; # would write_chunk be better? |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub write_chunk { |
|
32
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
33
|
0
|
|
|
|
|
0
|
my $chunk = shift; |
|
34
|
0
|
|
|
|
|
0
|
$self->storage->write_chunk( |
|
35
|
|
|
|
|
|
|
$self->format->encoder->write_chunk($chunk), |
|
36
|
|
|
|
|
|
|
@_ # passing the rest of parameters as-is, some storages accept additional settings on write(), e.g. DelayedQueue |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub in { |
|
41
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
|
42
|
1
|
|
|
|
|
6
|
my $in = $self->storage->in(@_); |
|
43
|
1
|
|
|
|
|
10891
|
return ($in | $self->format->decoder); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub commit { |
|
47
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
|
48
|
1
|
|
|
|
|
8
|
$self->storage->commit(@_); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
around 'does' => sub { |
|
52
|
|
|
|
|
|
|
my $orig = shift; |
|
53
|
|
|
|
|
|
|
my $self = shift; |
|
54
|
|
|
|
|
|
|
return 1 if $orig->($self, @_); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my ($role) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if ($role eq 'Flux::Storage::Role::ClientList' or $role eq 'Flux::Role::Description') { |
|
59
|
|
|
|
|
|
|
return $self->storage->does($role); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
return; |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
0
|
|
sub client_names { return shift->storage->client_names(@_) } |
|
65
|
0
|
|
|
0
|
0
|
|
sub register_client { return shift->storage->register_client(@_) } |
|
66
|
0
|
|
|
0
|
0
|
|
sub unregister_client { return shift->storage->unregister_client(@_) } |
|
67
|
0
|
|
|
0
|
0
|
|
sub has_client { return shift->storage->has_client(@_) } |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub description { |
|
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $inner; |
|
73
|
0
|
0
|
|
|
|
|
if ($self->storage->does('Flux::Role::Description')) { |
|
74
|
0
|
|
|
|
|
|
$inner = $self->storage->description(@_); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
else { |
|
77
|
0
|
|
|
|
|
|
$inner = $self->storage.""; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return |
|
81
|
0
|
|
|
|
|
|
"format: ".blessed($self->format)."\n" |
|
82
|
|
|
|
|
|
|
.$inner; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |