MongoDB

 view release on metacpan or  search on metacpan

lib/MongoDB/_Constants.pm  view on Meta::CPAN

        MAX_WIRE_VERSION             => 8,
        MAX_WRITE_BATCH_SIZE         => 1000,
        MIN_HEARTBEAT_FREQUENCY_SEC  => .5,
        MIN_HEARTBEAT_FREQUENCY_USEC => 500_000,                    # 500ms, not configurable
        MIN_KEYED_DOC_LENGTH         => 8,
        MIN_SERVER_VERSION           => "2.4.0",
        MIN_WIRE_VERSION             => 0,
        RESCAN_SRV_FREQUENCY_SEC      => $ENV{TEST_MONGO_RESCAN_SRV_FREQUENCY_SEC} || 60,
        NO_JOURNAL_RE                => qr/^journaling not enabled/,
        NO_REPLICATION_RE          => qr/^no replication has been enabled/,
        P_INT32                    => $] lt '5.010' ? 'l' : 'l<',
        SMALLEST_MAX_STALENESS_SEC => 90,
        WITH_ASSERTS               => $ENV{PERL_MONGO_WITH_ASSERTS},
        # Transaction state tracking
        TXN_NONE                    => 'none',
        TXN_STARTING                => 'starting',
        TXN_IN_PROGRESS             => 'in_progress',
        TXN_COMMITTED               => 'committed',
        TXN_ABORTED                 => 'aborted',
        TXN_WTIMEOUT_RETRY_DEFAULT  => 10_000,  # 10 seconds
        TXN_TRANSIENT_ERROR_MSG     => 'TransientTransactionError',

lib/MongoDB/_Protocol.pm  view on Meta::CPAN

    RESERVED        => 2003, # formerly used for OP_GET_BY_OID
    OP_QUERY        => 2004, # query a collection
    OP_GET_MORE     => 2005, # Get more data from a query. See Cursors
    OP_DELETE       => 2006, # Delete documents
    OP_KILL_CURSORS => 2007, # Tell database client is done with a cursor
    OP_COMPRESSED   => 2012, # wire compression
    OP_MSG          => 2013, # generic bi-directional op code
};

use constant {
    PERL58           => $] lt '5.010',
    MIN_REPLY_LENGTH => 4 * 5 + 8 + 4 * 2,
    MAX_REQUEST_ID   => 2**31 - 1,
};

# Perl < 5.10, pack doesn't have endianness modifiers, and the MongoDB wire
# protocol mandates little-endian order. For 5.10, we can use modifiers but
# before that we only work on platforms that are natively little-endian.  We
# die during configuration on big endian platforms on 5.8

use constant {

lib/MongoDB/_Protocol.pm  view on Meta::CPAN

        my $as_hex = $cursor_id->as_hex; # big-endian hex
        substr( $as_hex, 0, 2, '' );     # remove "0x"
        my $len = length($as_hex);
        substr( $as_hex, 0, 0, "0" x ( 16 - $len ) ) if $len < 16; # pad to quad length
        $cursor_id = pack( "H*", $as_hex );                        # packed big-endian
        $cursor_id = reverse($cursor_id);                          # reverse to little-endian
    }
    elsif (HAS_INT64) {
        # pack doesn't have endianness modifiers before perl 5.10.
        # We die during configuration on big-endian platforms on 5.8
        $cursor_id = pack( $] lt '5.010' ? "q" : "q<", $cursor_id );
    }
    else {
        # we on 32-bit perl *and* have a cursor ID that fits in 32 bits,
        # so pack it as long and pad out to a quad
        $cursor_id = pack( $] lt '5.010' ? "l" : "l<", $cursor_id ) . ( "\0" x 4 );
    }

    return $cursor_id;
}

1;

# vim: ts=4 sts=4 sw=4 et:

lib/MongoDB/_URI.pm  view on Meta::CPAN

    return $ret;
}

# uri_escape borrowed from HTTP::Tiny 0.070
my %escapes = map { chr($_) => sprintf("%%%02X", $_) } 0..255;
$escapes{' '}="+";
my $unsafe_char = qr/[^A-Za-z0-9\-\._~]/;

sub __uri_escape {
    my ($str) = @_;
    if ( $] ge '5.008' ) {
        utf8::encode($str);
    }
    else {
        $str = pack("U*", unpack("C*", $str)) # UTF-8 encode a byte string
            if ( length $str == do { use bytes; length $str } );
        $str = pack("C*", unpack("C*", $str)); # clear UTF-8 flag
    }
    $str =~ s/($unsafe_char)/$escapes{$1}/ge;
    return $str;
}

t/lib/TestBSON.pm  view on Meta::CPAN

    _hexdump
    _int32
    _int64
    _pack_bigint
    _regexp
    _string
    is_bin
);

use constant {
    PERL58    => $] lt '5.010',
    HAS_INT64 => $Config{use64bitint}
};

use constant {
    P_INT32 => PERL58 ? "l" : "l<",
    P_INT64 => PERL58 ? "q" : "q<",
    MAX_LONG      => 2147483647,
    MIN_LONG      => -2147483647,
    BSON_DOUBLE   => "\x01",
    BSON_STRING   => "\x02",



( run in 1.194 second using v1.01-cache-2.11-cpan-cc502c75498 )