GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DR::Tarantool::AsyncClient(3) User Contributed Perl Documentation DR::Tarantool::AsyncClient(3)

DR::Tarantool::AsyncClient - async client for tarantool <http://tarantool.org>

    use DR::Tarantool::AsyncClient 'tarantool';

    DR::Tarantool::AsyncClient->connect(
        host    => '127.0.0.1',
        port    => 12345,
        spaces  => {
            0   => {
                name    => 'users',
                fields  => [
                    qw(login password role),
                    {
                        name    => 'counter',
                        type    => 'NUM'
                    }
                ],
                indexes => {
                    0   => 'login',
                    1   => [ qw(login password) ],
                }
            },
            2   => {
                name    => 'roles',
                fields  => [ qw(name title) ],
                indexes => {
                    0   => 'name',
                    1   => {
                        name    => 'myindex',
                        fields  => [ 'name', 'title' ],
                    }
                }
            }
        },
        sub {
            my ($client) = @_;
            ...
        }
    );

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

    $client->insert('space', [ 'user', 10, 'password' ], sub { ... });

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

    $client->select('space', 1, sub { ... });

    $client->delete('space', 1, sub { ... });

    $client->update('space', 1, [ passwd => set => 'abc' ], sub { .. });

Connects to <Tarantool:http://tarantool.org>, returns (by callback) an object which can be used to make requests.

    DR::Tarantool::AsyncClient->connect(
        host                => $host,
        port                => $port,
        spaces              => $spaces,
        reconnect_period    => 0.5,
        reconnect_always    => 1,
        sub {
            my ($obj) = @_;
            if (ref $obj) {
                ... # handle errors
            }
            ...
        }
    );

Arguments

host & port
Address where tarantool is started.
spaces
A hash with space description or a DR::Tarantool::Spaces reference.
reconnect_period & reconnect_always
See DR::Tarantool::LLClient for more details.

Returns a space object by space name or numeric id. See perldoc DR::Tarantool::Spaces for more details.

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 the server.

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

Arguments

cb

Insert a tuple into a space.

    $client->insert('space', [ 'user', 10, 'password' ], sub { ... });
    $client->insert('space', \@tuple, $flags, sub { ... });

Arguments

space_name
tuple
flags (optional)
Possible flags are described in perldoc ":constant" in DR::Tarantool.
callback

Call a Lua function. All arguments are passed to Lua as binary strings. Returned tuples can be unpacked using either a space description or a format specification.

    $client->call_lua(foo => ['arg1', 'arg2'], sub {  });
    $client->call_lua(foo => [], 'space_name', sub { ... });
    $client->call_lua(foo => \@args,
        flags => $f,
        space => $space_name,
        sub { ... }
    );
    $client->call_lua(foo => \@args,
        fields => [ qw(a b c) ],
        sub { ... }
    );
    $client->call_lua(foo => \@args,
        fields => [ qw(a b c), { type => 'NUM', name => 'abc'} ... ],
        sub { ... }
    );

Arguments

function name
function arguments
space or fields
Is optional. If given, this space description will be used to interpret contents of tuples returned by the procedure. Alternatively, instead of providing a reference to a space, the format can be set explicitly with fields argument.
callback

Optional arguments

space
Space name. Use the argument if your function returns tuple(s) from a space described on connect.
fields
Output format of the returned tuple (like 'fields' in connect method).
flags
Reserved option.
args
Format description for stored procedure arguments.

Select a tuple from a space by index.

    $tuples = $client->select('space', 1, sub { ... });
    $tuples = $client->select('space', [1, 2], sub { ... });

    $tuples = $client->select('space_name',
            [1,2,3] => 'index_name', sub { ... });

Arguments

space name
key(s)
optional arguments
callback

optional arguments

This section can contain only one element, which is either an index name, or a hash with the following fields:

index
index name or number
limit
offset

Delete a tuple.

    $client->delete('space', 1, sub { ... });
    $client->delete('space', $key, $flags, sub { ... });

Tuple is always deleted by primary key.

Arguments

space name
key
flags (optional)
Server flags, as described in perldoc ":constant" in DR::Tarantool.
callback

Update a tuple.

    $client->update('space', 1, [ passwd => set => 'abc' ], sub { .. });
    $client->update(
        'space',
        1,
        [ [ passwd => set => 'abc' ], [ login => 'delete' ] ],
        sub { ... }
    );

Arguments

space name
key
operation list
flags (optional)
Server flags, as described in perldoc ":constant" in DR::Tarantool.
callback

The error code returned by the last request (see "last_code" in DR::Tarantool::LLClient).

The error message associated with the last request (see "last_error_string" in DR::Tarantool::LLClient), if there was an error.

 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/>.
2014-05-15 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.