DOKK / manpages / debian 10 / libdr-tarantool-perl / DR::Tarantool::LLClient.3pm.en
DR::Tarantool::LLClient(3pm) User Contributed Perl Documentation DR::Tarantool::LLClient(3pm)

DR::Tarantool::LLClient - a low level async client for Tarantool <http://tarantool.org>

    DR::Tarantool::LLClient->connect(
        host => '127.0.0.1',
        port => '33033',
        cb   => {
            my ($tnt) = @_;
            ...
        }
    );
    $tnt->ping( sub { .. } );
    $tnt->insert(0, [ 1, 2, 3 ], sub { ... });
    $tnt->select(1, 0, [ [ 1, 2 ], [ 3, 4 ] ], sub { ... });
    $tnt->update(0, [ 1 ], [ [ 1 => add pack 'L<', 1 ] ], sub { ... });
    $tnt->call_lua( 'box.select', [ 0, 1, 2 ], sub { ... });

This module provides a low-level interface to Tarantool <http://tarantool.org>.

All methods receive callback as the last argument. The callback receives HASHREF value with the following fields:

Done status:
A fatal error occurred. The server closed the connection or returned a broken package.
An internal driver error.
The request wasn't executed: the server returned an error.
Request was executed OK.
If an error occurred, contains error description.
Contains reply code.
Contains request id. (see protocol documentation <https://github.com/mailru/tarantool/blob/master/doc/box-protocol.txt>)
Contains request type (see protocol documentation <https://github.com/mailru/tarantool/blob/master/doc/box-protocol.txt>)
Contains the count of returned tuples.
Returned tuples (ARRAYREF of ARRAYREF).

If you use NUM or NUM64 field types, values for these fields need to be packed before they are sent to the server, and unpacked when received in a response. This is a low-level driver :)

Creates a connection to Tarantool

    DR::Tarantool::LLClient->connect(
        host => '127.0.0.1',
        port => '33033',
        cb   => {
            my ($tnt) = @_;
            ...
        }
    );

Arguments

Host and port to connect to.
An interval to wait before trying to reconnect after a fatal error or unsuccessful connect. If the field is defined and is greater than 0, the driver tries to reconnect to the server after this interval.

Important: the driver does not reconnect after the first unsuccessful connection. It calls callback instead.

Try to reconnect even after the first unsuccessful connection.
Done callback. The callback receives a connection handle connected to the server or an error string.

True if this connection is established.

Contains a string with the status of connection. Return value can be:

Connection is established.
Connection isn't established yet, or was lost.
The driver is connecting to the server.
An attempt to connect was made, but ended up with an error. If the event loop is running, and reconnect_period option is set, the driver continues to try to reconnect and update its status.

Ping the server.

    $tnt->ping( sub { .. } );

Arguments

Insert a tuple.

    $tnt->insert(0, [ 1, 2, 3 ], sub { ... });
    $tnt->insert(0, [ 4, 5, 6 ], $flags, sub { .. });

Arguments

Select a tuple or tuples.

    $tnt->select(1, 0, [ [ 1, 2 ], [ 3, 4 ] ], sub { ... });
    $tnt->select(1, 0, [ [ 1, 2 ], [ 3, 4 ] ], 1, sub { ... });
    $tnt->select(1, 0, [ [ 1, 2 ], [ 3, 4 ] ], 1, 2, sub { ... });

Arguments

If the limit isn't set or is zero, select extracts all records without a limit.
Default value is 0.
callback for results

Update a tuple.

    $tnt->update(0, [ 1 ], [ [ 1 => add 1 ] ], sub { ... });
    $tnt->update(
        0,                                      # space
        [ 1 ],                                  # key
        [ [ 1 => add 1 ], [ 2 => add => 1 ],    # operations
        $flags,                                 # flags
        sub { ... }                             # callback
    );
    $tnt->update(0, [ 1 ], [ [ 1 => add 1 ] ], $flags, sub { ... });

Arguments

callback for results

Delete a tuple.

    $tnt->delete( 0, [ 1 ], sub { ... });
    $tnt->delete( 0, [ 1 ], $flags, sub { ... });

Arguments

callback for results

Calls a lua procedure.

    $tnt->call_lua( 'box.select', [ 0, 1, 2 ], sub { ... });
    $tnt->call_lua( 'box.select', [ 0, 1, 2 ], $flags, sub { ... });

Arguments

callback to call when the request is ready

Return code of the last request or undef if there was no request.

An error string if the last request ended up with an error, or undef otherwise.

The module can log requests/responses. Logging can be turned ON by setting these environment variables:

Instructs LLClient to record all requests/responses into this directory.
Instructs LLClient to record all requests/responses which ended up with an error into this directory.

 Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org>
 Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
 This program is free software, you can redistribute it and/or
 modify it under the terms of the Artistic License.

The project is placed git repo on github: <https://github.com/dr-co/dr-tarantool/>.

2018-11-02 perl v5.28.0