line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2015 - present MongoDB, Inc. |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
|
|
|
|
# limitations under the License. |
14
|
|
|
|
|
|
|
|
15
|
59
|
|
|
59
|
|
346
|
use strict; |
|
59
|
|
|
|
|
113
|
|
|
59
|
|
|
|
|
1517
|
|
16
|
59
|
|
|
59
|
|
259
|
use warnings; |
|
59
|
|
|
|
|
98
|
|
|
59
|
|
|
|
|
1551
|
|
17
|
|
|
|
|
|
|
package MongoDB::ReadConcern; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ABSTRACT: Encapsulate and validate a read concern |
20
|
|
|
|
|
|
|
|
21
|
59
|
|
|
59
|
|
261
|
use version; |
|
59
|
|
|
|
|
100
|
|
|
59
|
|
|
|
|
252
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.2'; |
23
|
|
|
|
|
|
|
|
24
|
59
|
|
|
59
|
|
3776
|
use Moo; |
|
59
|
|
|
|
|
140
|
|
|
59
|
|
|
|
|
263
|
|
25
|
59
|
|
|
59
|
|
15228
|
use MongoDB::Error; |
|
59
|
|
|
|
|
148
|
|
|
59
|
|
|
|
|
5221
|
|
26
|
59
|
|
|
|
|
460
|
use Types::Standard qw( |
27
|
|
|
|
|
|
|
Maybe |
28
|
|
|
|
|
|
|
Str |
29
|
|
|
|
|
|
|
ArrayRef |
30
|
59
|
|
|
59
|
|
370
|
); |
|
59
|
|
|
|
|
124
|
|
31
|
|
|
|
|
|
|
|
32
|
59
|
|
|
59
|
|
36426
|
use namespace::clean; |
|
59
|
|
|
|
|
111
|
|
|
59
|
|
|
|
|
904
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#pod =attr level |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod The read concern level determines the consistency level required |
37
|
|
|
|
|
|
|
#pod of data being read. |
38
|
|
|
|
|
|
|
#pod |
39
|
|
|
|
|
|
|
#pod The default level is C, which means the server will use its configured |
40
|
|
|
|
|
|
|
#pod default. |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod If the level is set to "local", reads will return the latest data a server has |
43
|
|
|
|
|
|
|
#pod locally. |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod Additional levels are storage engine specific. See L
|
46
|
|
|
|
|
|
|
#pod Concern|http://docs.mongodb.org/manual/search/?query=readConcern> in the MongoDB |
47
|
|
|
|
|
|
|
#pod documentation for more details. |
48
|
|
|
|
|
|
|
#pod |
49
|
|
|
|
|
|
|
#pod This may be set in a connection string with the the C option. |
50
|
|
|
|
|
|
|
#pod |
51
|
|
|
|
|
|
|
#pod =cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has level => ( |
54
|
|
|
|
|
|
|
is => 'ro', |
55
|
|
|
|
|
|
|
isa => Maybe [Str], |
56
|
|
|
|
|
|
|
predicate => 'has_level', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub BUILD { |
60
|
11
|
|
|
11
|
0
|
6408
|
my $self = shift; |
61
|
11
|
100
|
|
|
|
55
|
if ( defined $self->{level} ) { |
62
|
9
|
|
|
|
|
105
|
$self->{level} = lc $self->{level}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# public interface for compatibility, but undocumented |
67
|
|
|
|
|
|
|
sub as_args { |
68
|
6
|
|
|
6
|
0
|
13
|
my ( $self, $session ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# if session is defined and operation_time is not, then either the |
71
|
|
|
|
|
|
|
# operation_time was not sent on the response from the server for this |
72
|
|
|
|
|
|
|
# session or the session has causal consistency disabled. |
73
|
6
|
100
|
|
|
|
12
|
if ( $self->{level} ) { |
74
|
|
|
|
|
|
|
return [ |
75
|
|
|
|
|
|
|
readConcern => { |
76
|
|
|
|
|
|
|
level => $self->{level}, |
77
|
5
|
50
|
33
|
|
|
33
|
( defined $session && defined $session->operation_time |
78
|
|
|
|
|
|
|
? ( afterClusterTime => $session->operation_time ) |
79
|
|
|
|
|
|
|
: () ), |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
]; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
|
|
|
|
|
|
return [ |
85
|
1
|
50
|
33
|
|
|
6
|
( defined $session && defined $session->operation_time |
86
|
|
|
|
|
|
|
? ( readConcern => { afterClusterTime => $session->operation_time } ) |
87
|
|
|
|
|
|
|
: () |
88
|
|
|
|
|
|
|
) |
89
|
|
|
|
|
|
|
]; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |