.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DR::Tarantool::AsyncClient 3pm" .TH DR::Tarantool::AsyncClient 3pm "2019-10-07" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DR::Tarantool::AsyncClient \- async client for tarantool .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use DR::Tarantool::AsyncClient \*(Aqtarantool\*(Aq; \& \& DR::Tarantool::AsyncClient\->connect( \& host => \*(Aq127.0.0.1\*(Aq, \& port => 12345, \& spaces => { \& 0 => { \& name => \*(Aqusers\*(Aq, \& fields => [ \& qw(login password role), \& { \& name => \*(Aqcounter\*(Aq, \& type => \*(AqNUM\*(Aq \& } \& ], \& indexes => { \& 0 => \*(Aqlogin\*(Aq, \& 1 => [ qw(login password) ], \& } \& }, \& 2 => { \& name => \*(Aqroles\*(Aq, \& fields => [ qw(name title) ], \& indexes => { \& 0 => \*(Aqname\*(Aq, \& 1 => { \& name => \*(Aqmyindex\*(Aq, \& fields => [ \*(Aqname\*(Aq, \*(Aqtitle\*(Aq ], \& } \& } \& } \& }, \& sub { \& my ($client) = @_; \& ... \& } \& ); \& \& $client\->ping(sub { ... }); \& \& $client\->insert(\*(Aqspace\*(Aq, [ \*(Aquser\*(Aq, 10, \*(Aqpassword\*(Aq ], sub { ... }); \& \& $client\->call_lua(foo => [\*(Aqarg1\*(Aq, \*(Aqarg2\*(Aq], sub { }); \& \& $client\->select(\*(Aqspace\*(Aq, 1, sub { ... }); \& \& $client\->delete(\*(Aqspace\*(Aq, 1, sub { ... }); \& \& $client\->update(\*(Aqspace\*(Aq, 1, [ passwd => set => \*(Aqabc\*(Aq ], sub { .. }); .Ve .SH "Class methods" .IX Header "Class methods" .SS "connect" .IX Subsection "connect" Connects to , returns (by callback) an object which can be used to make requests. .PP .Vb 10 \& 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 \& } \& ... \& } \& ); .Ve .PP \fIArguments\fR .IX Subsection "Arguments" .IP "host & port" 4 .IX Item "host & port" Address where tarantool is started. .IP "spaces" 4 .IX Item "spaces" A hash with space description or a DR::Tarantool::Spaces reference. .IP "reconnect_period & reconnect_always" 4 .IX Item "reconnect_period & reconnect_always" See DR::Tarantool::LLClient for more details. .SH "Attributes" .IX Header "Attributes" .SS "space" .IX Subsection "space" Returns a space object by space name or numeric id. See perldoc DR::Tarantool::Spaces for more details. .SH "Worker methods" .IX Header "Worker methods" All methods accept callbacks which are invoked with the following arguments: .IP "status" 4 .IX Item "status" On success, this field has value '\fBok\fR'. The value of this parameter determines the contents of the rest of the callback arguments. .IP "a tuple or tuples or an error code" 4 .IX Item "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. .IP "errorstr" 4 .IX Item "errorstr" Error string in case of an error. .PP .Vb 8 \& sub { \& if ($_[0] eq \*(Aqok\*(Aq) { \& my ($status, $tuples) = @_; \& ... \& } else { \& my ($status, $code, $errstr) = @_; \& } \& } .Ve .SS "ping" .IX Subsection "ping" Ping the server. .PP .Vb 1 \& $client\->ping(sub { ... }); .Ve .PP \fIArguments\fR .IX Subsection "Arguments" .IP "cb" 4 .IX Item "cb" .SS "insert" .IX Subsection "insert" Insert a tuple into a space. .PP .Vb 2 \& $client\->insert(\*(Aqspace\*(Aq, [ \*(Aquser\*(Aq, 10, \*(Aqpassword\*(Aq ], sub { ... }); \& $client\->insert(\*(Aqspace\*(Aq, \e@tuple, $flags, sub { ... }); .Ve .PP \fIArguments\fR .IX Subsection "Arguments" .IP "space_name" 4 .IX Item "space_name" .PD 0 .IP "tuple" 4 .IX Item "tuple" .IP "flags (optional)" 4 .IX Item "flags (optional)" .PD Possible flags are described in perldoc \*(L":constant\*(R" in DR::Tarantool. .IP "callback" 4 .IX Item "callback" .SS "call_lua" .IX Subsection "call_lua" 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. .PP .Vb 10 \& $client\->call_lua(foo => [\*(Aqarg1\*(Aq, \*(Aqarg2\*(Aq], sub { }); \& $client\->call_lua(foo => [], \*(Aqspace_name\*(Aq, sub { ... }); \& $client\->call_lua(foo => \e@args, \& flags => $f, \& space => $space_name, \& sub { ... } \& ); \& $client\->call_lua(foo => \e@args, \& fields => [ qw(a b c) ], \& sub { ... } \& ); \& $client\->call_lua(foo => \e@args, \& fields => [ qw(a b c), { type => \*(AqNUM\*(Aq, name => \*(Aqabc\*(Aq} ... ], \& sub { ... } \& ); .Ve .PP \fIArguments\fR .IX Subsection "Arguments" .IP "function name" 4 .IX Item "function name" .PD 0 .IP "function arguments" 4 .IX Item "function arguments" .IP "space or fields" 4 .IX Item "space or fields" .PD 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 \fBfields\fR argument. .IP "callback" 4 .IX Item "callback" .PP Optional arguments .IX Subsection "Optional arguments" .IP "space" 4 .IX Item "space" Space name. Use the argument if your function returns tuple(s) from a space described on connect. .IP "fields" 4 .IX Item "fields" Output format of the returned tuple (like '\fBfields\fR' in connect method). .IP "flags" 4 .IX Item "flags" Reserved option. .IP "args" 4 .IX Item "args" Format description for stored procedure arguments. .SS "select" .IX Subsection "select" Select a tuple from a space by index. .PP .Vb 2 \& $tuples = $client\->select(\*(Aqspace\*(Aq, 1, sub { ... }); \& $tuples = $client\->select(\*(Aqspace\*(Aq, [1, 2], sub { ... }); \& \& $tuples = $client\->select(\*(Aqspace_name\*(Aq, \& [1,2,3] => \*(Aqindex_name\*(Aq, sub { ... }); .Ve .PP \fIArguments\fR .IX Subsection "Arguments" .IP "space name" 4 .IX Item "space name" .PD 0 .IP "key(s)" 4 .IX Item "key(s)" .IP "optional arguments" 4 .IX Item "optional arguments" .IP "callback" 4 .IX Item "callback" .PD .PP \fIoptional arguments\fR .IX Subsection "optional arguments" .PP This section can contain only one element, which is either an index name, or a hash with the following fields: .IP "index" 4 .IX Item "index" index name or number .IP "limit" 4 .IX Item "limit" .PD 0 .IP "offset" 4 .IX Item "offset" .PD .SS "delete" .IX Subsection "delete" Delete a tuple. .PP .Vb 2 \& $client\->delete(\*(Aqspace\*(Aq, 1, sub { ... }); \& $client\->delete(\*(Aqspace\*(Aq, $key, $flags, sub { ... }); .Ve .PP Tuple is always deleted by primary key. .PP \fIArguments\fR .IX Subsection "Arguments" .IP "space name" 4 .IX Item "space name" .PD 0 .IP "key" 4 .IX Item "key" .IP "flags (optional)" 4 .IX Item "flags (optional)" .PD Server flags, as described in perldoc \*(L":constant\*(R" in DR::Tarantool. .IP "callback" 4 .IX Item "callback" .SS "update" .IX Subsection "update" Update a tuple. .PP .Vb 7 \& $client\->update(\*(Aqspace\*(Aq, 1, [ passwd => set => \*(Aqabc\*(Aq ], sub { .. }); \& $client\->update( \& \*(Aqspace\*(Aq, \& 1, \& [ [ passwd => set => \*(Aqabc\*(Aq ], [ login => \*(Aqdelete\*(Aq ] ], \& sub { ... } \& ); .Ve .PP \fIArguments\fR .IX Subsection "Arguments" .IP "space name" 4 .IX Item "space name" .PD 0 .IP "key" 4 .IX Item "key" .IP "operation list" 4 .IX Item "operation list" .IP "flags (optional)" 4 .IX Item "flags (optional)" .PD Server flags, as described in perldoc \*(L":constant\*(R" in DR::Tarantool. .IP "callback" 4 .IX Item "callback" .SS "last_code" .IX Subsection "last_code" The error code returned by the last request (see \*(L"last_code\*(R" in DR::Tarantool::LLClient). .SS "last_error_string" .IX Subsection "last_error_string" The error message associated with the last request (see \*(L"last_error_string\*(R" in DR::Tarantool::LLClient), if there was an error. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" .Vb 2 \& Copyright (C) 2011 Dmitry E. Oboukhov \& Copyright (C) 2011 Roman V. Nikolaev \& \& This program is free software, you can redistribute it and/or \& modify it under the terms of the Artistic License. .Ve .SH "VCS" .IX Header "VCS" The project is placed git repo on github: .