File Coverage

blib/lib/MongoDB/_Constants.pm
Criterion Covered Total %
statement 19 19 100.0
branch 1 2 50.0
condition 1 2 50.0
subroutine 7 7 100.0
pod n/a
total 28 30 93.3


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 70     70   87934 use strict;
  70         159  
  70         2127  
16 70     70   395 use warnings;
  70         147  
  70         2497  
17              
18             package MongoDB::_Constants;
19              
20             # Common MongoDB driver constants
21              
22 70     70   809 use version;
  70         2043  
  70         515  
23             our $VERSION = 'v2.2.1';
24              
25 70     70   6774 use Exporter 5.57 qw/import/;
  70         1138  
  70         2378  
26 70     70   412 use Config;
  70         171  
  70         13240  
27              
28             my $CONSTANTS;
29              
30             BEGIN {
31             $CONSTANTS = {
32             COOLDOWN_SECS => 5,
33             CURSOR_ZERO => "\0" x 8,
34             EPOCH => 0,
35             HAS_INT64 => $Config{use64bitint},
36             IDLE_WRITE_PERIOD_SEC => 10,
37             MAX_BSON_OBJECT_SIZE => 4_194_304,
38             MAX_GRIDFS_BATCH_SIZE => 16_777_216, # 16MiB
39             MAX_BSON_WIRE_SIZE => 16_793_600, # 16MiB + 16KiB
40             MAX_WIRE_VERSION => 8,
41             MAX_WRITE_BATCH_SIZE => 1000,
42             MIN_HEARTBEAT_FREQUENCY_SEC => .5,
43             MIN_HEARTBEAT_FREQUENCY_USEC => 500_000, # 500ms, not configurable
44             MIN_KEYED_DOC_LENGTH => 8,
45             MIN_SERVER_VERSION => "2.4.0",
46             MIN_WIRE_VERSION => 0,
47             RESCAN_SRV_FREQUENCY_SEC => $ENV{TEST_MONGO_RESCAN_SRV_FREQUENCY_SEC} || 60,
48             NO_JOURNAL_RE => qr/^journaling not enabled/,
49             NO_REPLICATION_RE => qr/^no replication has been enabled/,
50             P_INT32 => $] lt '5.010' ? 'l' : 'l<',
51             SMALLEST_MAX_STALENESS_SEC => 90,
52             WITH_ASSERTS => $ENV{PERL_MONGO_WITH_ASSERTS},
53             # Transaction state tracking
54 70 50 50 70   11542 TXN_NONE => 'none',
55             TXN_STARTING => 'starting',
56             TXN_IN_PROGRESS => 'in_progress',
57             TXN_COMMITTED => 'committed',
58             TXN_ABORTED => 'aborted',
59             TXN_WTIMEOUT_RETRY_DEFAULT => 10_000, # 10 seconds
60             TXN_TRANSIENT_ERROR_MSG => 'TransientTransactionError',
61             TXN_UNKNOWN_COMMIT_MSG => 'UnknownTransactionCommitResult',
62             # From the Convenient API for Transactions spec, with_transaction must
63             # halt retries after 120 seconds.
64             # This limit is non-configurable and was chosen to be twice the 60 second
65             # default value of MongoDB's `transactionLifetimeLimitSeconds` parameter.
66             WITH_TXN_RETRY_TIME_LIMIT => 120, # seconds
67             };
68             }
69              
70 70     70   583 use constant $CONSTANTS;
  70         199  
  70         22537  
71              
72             our @EXPORT = keys %$CONSTANTS;
73              
74             1;