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
|
|
399
|
use strict; |
|
59
|
|
|
|
|
125
|
|
|
59
|
|
|
|
|
1706
|
|
16
|
59
|
|
|
59
|
|
302
|
use warnings; |
|
59
|
|
|
|
|
120
|
|
|
59
|
|
|
|
|
1771
|
|
17
|
|
|
|
|
|
|
package MongoDB::ReadConcern; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ABSTRACT: Encapsulate and validate a read concern |
20
|
|
|
|
|
|
|
|
21
|
59
|
|
|
59
|
|
295
|
use version; |
|
59
|
|
|
|
|
131
|
|
|
59
|
|
|
|
|
291
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.1'; |
23
|
|
|
|
|
|
|
|
24
|
59
|
|
|
59
|
|
4187
|
use Moo; |
|
59
|
|
|
|
|
143
|
|
|
59
|
|
|
|
|
301
|
|
25
|
59
|
|
|
59
|
|
17690
|
use MongoDB::Error; |
|
59
|
|
|
|
|
149
|
|
|
59
|
|
|
|
|
5908
|
|
26
|
59
|
|
|
|
|
490
|
use Types::Standard qw( |
27
|
|
|
|
|
|
|
Maybe |
28
|
|
|
|
|
|
|
Str |
29
|
|
|
|
|
|
|
ArrayRef |
30
|
59
|
|
|
59
|
|
391
|
); |
|
59
|
|
|
|
|
138
|
|
31
|
|
|
|
|
|
|
|
32
|
59
|
|
|
59
|
|
41917
|
use namespace::clean; |
|
59
|
|
|
|
|
132
|
|
|
59
|
|
|
|
|
880
|
|
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
|
7858
|
my $self = shift; |
61
|
11
|
100
|
|
|
|
67
|
if ( defined $self->{level} ) { |
62
|
9
|
|
|
|
|
114
|
$self->{level} = lc $self->{level}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# public interface for compatibility, but undocumented |
67
|
|
|
|
|
|
|
sub as_args { |
68
|
6
|
|
|
6
|
0
|
16
|
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
|
|
|
|
17
|
if ( $self->{level} ) { |
74
|
|
|
|
|
|
|
return [ |
75
|
|
|
|
|
|
|
readConcern => { |
76
|
|
|
|
|
|
|
level => $self->{level}, |
77
|
5
|
50
|
33
|
|
|
31
|
( defined $session && defined $session->operation_time |
78
|
|
|
|
|
|
|
? ( afterClusterTime => $session->operation_time ) |
79
|
|
|
|
|
|
|
: () ), |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
]; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
|
|
|
|
|
|
return [ |
85
|
1
|
50
|
33
|
|
|
8
|
( defined $session && defined $session->operation_time |
86
|
|
|
|
|
|
|
? ( readConcern => { afterClusterTime => $session->operation_time } ) |
87
|
|
|
|
|
|
|
: () |
88
|
|
|
|
|
|
|
) |
89
|
|
|
|
|
|
|
]; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |