DR-Tnt

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

t/040-full/030-ae-sch-collision.t
t/040-full/040-sync-sch-collision.t
t/040-full/045-sync-sch-noauth.t
t/040-full/050-ae-reconnect.t
t/040-full/060-sync-reconnect.t
t/040-full/070-sync-wrongpassowrd.t
t/040-full/hashify/010-ae.t
t/040-full/lua/easy.lua
t/040-full/lua/start/00-test.lua
t/040-full/lua/start-pause.lua
t/100-connector/010-coro/010-base.t
t/100-connector/010-coro/020-utf8.t
t/100-connector/010-coro/030-parallel.t
t/100-connector/010-coro/040-require.t
t/100-connector/020-sync/010-base.t
t/100-connector/020-sync/020-utf8.t
t/100-connector/020-sync/030-require.t
t/100-connector/030-ae/010-base.t
t/100-connector/030-ae/020-utf8.t
t/100-connector/030-ae/030-require.t
t/100-connector/lua/easy.lua
trash/eval.pl
.travis.yml
META.yml                                 Module YAML meta-data (added by MakeMaker)

debian/control  view on Meta::CPAN

Source: libdr-tnt-perl
Section: perl
Homepage: http://search.cpan.org/dist/DR-Tnt/
Maintainer: Dmitry E. Oboukhov <unera@debian.org>
Build-Depends: debhelper (>= 7), cdbs,
 libanyevent-perl,
 tarantool,
 liblist-moreutils-perl,
 libcoro-perl,
 libanyevent-perl
Standards-Version: 3.9.6
Priority: extra
VCS-Browser: https://github.com/dr-co/dr-tnt

Package: libdr-tnt-perl
Depends:
 ${perl:Depends},
 ${misc:Depends},
 ${shlibs:Depends},
 liblist-moreutils-perl
Recommends: libcoro-perl, libanyevent-perl
Architecture: any
Suggests: tarantool
Description: perl driver for Tarantool
 The package contains sync and async drivers for tarantool database.

lib/DR/Tnt.pm  view on Meta::CPAN

use List::MoreUtils 'any';

use Carp;
$Carp::Internal{ (__PACKAGE__) }++;

sub tarantool {
    my (%opts) = @_;

    my $driver = delete($opts{driver}) || 'sync';
    
    unless (any { $driver eq $_ } 'sync', 'ae', 'async', 'coro') {
        goto usage;
    }


    goto $driver;
    sync:
        require DR::Tnt::Client::Sync;
        return DR::Tnt::Client::Sync->new(%opts);

    ae:
    async:
        require DR::Tnt::Client::AE;
        return DR::Tnt::Client::AE->new(%opts);

    coro:
        require DR::Tnt::Client::Coro;
        return DR::Tnt::Client::Coro->new(%opts);


    usage:
        croak "Too few information about tarantool connection";
}

1;

lib/DR/Tnt.pm  view on Meta::CPAN

=over

=item sync

L<DR::Tnt::Client::Sync> will be loaded and created.

=item ae or async

L<DR::Tnt::Client::AE> will be loaded and created.

=item coro

L<DR::Tnt::Client::Coro> will be loaded and created.

=back


=head2 Attributes

=over

lib/DR/Tnt.pm  view on Meta::CPAN

If the option is set to C<TRUE>, then the driver will extract tuples
to hash by C<box.space._space> schema.

=item reconnect_interval

Internal to reconnect after disconnect or fatal errors. Undefined value
disables the mechanizm.

=item raise_error

The option is actual for C<coro> and C<sync> drivers
(L<DR::Tnt::Client::Coro> and L<DR::Tnt::Client::Sync>).

=item utf8

Default value is C<TRUE>. If C<TRUE>, driver will unpack all
strings as C<utf8>-decoded strings.

=back

=head2 Information attributes

lib/DR/Tnt.pm  view on Meta::CPAN


=back

=back

=head1 CONNECTORS METHODS

All connectors have the same API. AnyEvent's connector has the last
argument - callback for results.

If C<raise_error> is C<false>, C<coro> and C<sync> drivers will
return C<undef> and store C<last_error>. Any successfuly call clears
C<last_error> attribute.

=over
    
=item auth

    # auth by $tnt->user and $tnt->password
    if ($tnt->auth) {

t/100-connector/010-coro/020-utf8.t  view on Meta::CPAN

    note "$now [$level] $message";
}

my $tntu = tarantool
                host    => 'localhost',
                port    => $ti->port,
                user            => 'testrwe',
                password        => 'test',
                logger          => \&LOGGER,
                hashify_tuples  => 1,
                driver          => 'coro',
                utf8            => 1,
;

isa_ok $tntu => 'DR::Tnt::Client::Coro', 'connector created';
ok $tntu->ping, 'ping';
for my $t ($tntu->insert(test => [ 'Вася', 'Пупкин' ])) {
    isa_ok $t => 'HASH', 'inserted';
    is $t->{name} => 'Вася', 'name';
    is $t->{value} => 'Пупкин', 'value';
}

my $tntnu = tarantool
                host    => 'localhost',
                port    => $ti->port,
                user            => 'testrwe',
                password        => 'test',
                logger          => \&LOGGER,
                hashify_tuples  => 1,
                driver          => 'coro',
                utf8            => 0,
;

isa_ok $tntnu => 'DR::Tnt::Client::Coro', 'connector created';
ok $tntnu->ping, 'ping';
for my $t ($tntnu->get(test => 'name', [ 'Вася' ])) {
    isa_ok $t => 'HASH', 'got tuple';
    is $t->{name} => encode(utf8 => 'Вася'), 'name';
    is $t->{value} => encode(utf8 => 'Пупкин'), 'value';
}

t/100-connector/010-coro/040-require.t  view on Meta::CPAN


diag $ti->log unless
    ok $ti->is_started, 'test tarantool started';

my $c = DR::Tnt::tarantool
            host            => 'localhost',
            port            => $ti->port,
            user            => 'testrwe',
            password        => 'test',
            hashify_tuples  => 1,
            driver          => 'coro',
;

isa_ok $c => 'DR::Tnt::Client::Coro';

ok $c->ping, 'ping';



( run in 0.821 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )