Man pages sections > man3 > DR::Tarantool::MsgPack::AsyncClient

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

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

NAME

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

SYNOPSIS

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

Class methods

connect

Connect to <Tarantool:http://tarantool.org>, returns (by callback) an object which can be used to make requests.
Arguments
host & port & user & password
Address and auth information of remote tarantool.
space
A hash with space description or a DR::Tarantool::Spaces reference.
reconnect_period
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.
reconnect_always
Try to reconnect even after the first unsuccessful connection.

Worker methods

All methods accept callbacks which are invoked with the following arguments:
status
On success, this field has value 'ok'. The value of this parameter determines the contents of the rest of the callback arguments.
a tuple or tuples or an error code
On success, the second argument contains tuple(s) produced by the request. On error, it contains the server error code.
errorstr
Error string in case of an error.
 
    sub {
        if ($_[0] eq 'ok') {
            my ($status, $tuples) = @_;
            ...
        } else {
            my ($status, $code, $errstr) = @_;
            ...
        }
    }
    

ping

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

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

select

Select a tuple (or tuples) from a space by index.
    $client->select('space_name', 'index_name', [ 'key' ], %opts, sub { .. });
Options can be:
limit
offset
iterator
An iterator for index. Can be:
ALL
Returns all tuples in space.
EQ, GE, LE, GT, LT

delete

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

update

Update a tuple.
    $client->update('space', [ 'key' ], \@ops, sub { ... });
@ops is array of operations to update. Each operation is array of elements:
code
Code of operation: "=", "+", "-", "&", "|", etc
field
Field number or name.
arguments
2017-07-22 perl v5.26.0