Scroll to navigation

DR::Tarantool::MsgPack::AsyncClient(3pm) User Contributed Perl Documentation DR::Tarantool::MsgPack::AsyncClient(3pm)


DR::Tarantool::MsgPack::AsyncClient - async client for tarantool.


    use DR::Tarantool::MsgPack::AsyncClient;
        host => '',
        port => 12345,
        spaces => $spaces,
        sub {
            my ($client) = @_;
    $client->insert('space_name', [1,2,3], sub { ... });

Class methods


Connect to <Tarantool:>, returns (by callback) an object which can be used to make requests.


Address and auth information of remote tarantool.
A hash with space description or a DR::Tarantool::Spaces reference.
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.

Worker methods

All methods accept callbacks which are invoked with the following arguments:

On success, this field has value 'ok'. The value of this parameter determines the contents of the rest of the callback arguments.
On success, the second argument contains tuple(s) produced by the request. On error, it contains the server error code.
Error string in case of an error.

    sub {
        if ($_[0] eq 'ok') {
            my ($status, $tuples) = @_;
        } else {
            my ($status, $code, $errstr) = @_;


Ping the server.

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

insert, replace

Insert/replace a tuple into a space.

    $client->insert('space', [ 1, 'Vasya', 20 ], sub { ... });
    $client->replace('space', [ 2, 'Petya', 22 ], sub { ... });


Call Lua function.

    $client->call_lua(foo => ['arg1', 'arg2'], sub {  });


Select a tuple (or tuples) from a space by index.

    $client->select('space_name', 'index_name', [ 'key' ], %opts, sub { .. });

Options can be:

An iterator for index. Can be:
Returns all tuples in space.


Delete a tuple.

    $client->delete('space_name', [ 'key' ], sub { ... });


Update a tuple.

    $client->update('space', [ 'key' ], \@ops, sub { ... });

@ops is array of operations to update. Each operation is array of elements:

Code of operation: "=", "+", "-", "&", "|", etc
Field number or name.
2019-10-07 perl v5.30.0