| 1 | # Copyright 2014 - 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 | 60 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 60 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | package MongoDB::Role::_DatabaseOp; | ||
| 18 | |||
| 19 | # MongoDB role for operations within a database, that need a database name | ||
| 20 | # and a BSON codec. This is likely a "base role" for all operations. | ||
| 21 | |||
| 22 | 60 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 60 | our $VERSION = 'v2.2.2'; | |
| 24 | |||
| 25 | 60 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | 60 | ▶ | use MongoDB::_Types qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | Boolish | ||
| 29 | BSONCodec | ||
| 30 | ClientSession | ||
| 31 | Stringish | ||
| 32 | 60 | ); | |
| 33 | 60 | ▶ | use Types::Standard qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 34 | CodeRef | ||
| 35 | Maybe | ||
| 36 | 60 | ); | |
| 37 | |||
| 38 | 60 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 39 | |||
| 40 | 60 | has bson_codec => ( | |
| 41 | is => 'ro', | ||
| 42 | required => 1, | ||
| 43 | isa => BSONCodec, | ||
| 44 | ); | ||
| 45 | |||
| 46 | 60 | has db_name => ( | |
| 47 | is => 'ro', | ||
| 48 | required => 1, | ||
| 49 | isa => Stringish, | ||
| 50 | ); | ||
| 51 | |||
| 52 | # required, but allowed to be undef so we're sure this gets wired up | ||
| 53 | # correctly through all database ops. | ||
| 54 | 60 | has monitoring_callback => ( | |
| 55 | is => 'ro', | ||
| 56 | required => 1, | ||
| 57 | isa => Maybe[CodeRef], | ||
| 58 | ); | ||
| 59 | |||
| 60 | 60 | has session => ( | |
| 61 | is => 'ro', | ||
| 62 | required => 0, | ||
| 63 | isa => Maybe[ClientSession], | ||
| 64 | ); | ||
| 65 | |||
| 66 | # set during retryable writes on supported operations | ||
| 67 | 60 | has retryable_write => ( | |
| 68 | is => 'rw', | ||
| 69 | isa => Boolish, | ||
| 70 | default => 0, | ||
| 71 | ); | ||
| 72 | |||
| 73 | # set during retryable reads on supported operations | ||
| 74 | 60 | has retryable_read => ( | |
| 75 | is => 'rw', | ||
| 76 | isa => Boolish, | ||
| 77 | default => 0, | ||
| 78 | ); | ||
| 79 | |||
| 80 | 60 | 1; | |