.\" 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 "MR::Tarantool::Box::Singleton 3pm" .TH MR::Tarantool::Box::Singleton 3pm "2020-07-21" "perl v5.30.3" "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" MR::Tarantool::Box::Singleton \- A singleton wrapper for MR::Tarantool::Box. .PP Provides connection\-persistence and replica fallback. Please read "MR::Tarantool::Box manual" first. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& package Some::Tarantool::Box::Singleton; \& use MR::Tarantool::Box::Singleton; \& use base \*(AqMR::Tarantool::Box::Singleton\*(Aq; \& \& BEGIN { # generates "TUPLE_$field_name" constants, and methods: FIELDS, FIELDS_HASH \& _\|_PACKAGE_\|_\->mkfields(qw/ id f1 f2 f3 field4 f5 f6 f7 misc_string /); # applicable for DEFAULT_SPACE only \& } \& \& sub SERVER { Some::Config\->GetBoxServer() } \& sub REPLICAS { Some::Config\->GetBoxReplicas() } \& \& sub DEFAULT_SPACE { 0 } \& \& sub SPACES {[{ \& space => 0, \& indexes => [ { \& index_name => \*(Aqprimary_id\*(Aq, \& keys => [TUPLE_id], \& }, { \& index_name => \*(Aqsecondary_f1f2\*(Aq, \& keys => [TUPLE_f1, TUPLE_f2], \& }, ], \& format => \*(AqQqLlSsCc&\*(Aq, \& default_index => \*(Aqprimary_id\*(Aq, \& }, { \& space => 1, \& indexes => [ { \& index_name => \*(Aqprimary_id\*(Aq, \& keys => [0], \& }, ], \& format => \*(Aq&&&&\*(Aq, \& fields => [qw/ string1 str2 s3 s4 /], \& }]} .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" .SS "\s-1METHODS\s0" .IX Subsection "METHODS" \fImkfields\fR .IX Subsection "mkfields" .PP .Vb 3 \& BEGIN { \& $CLASS\->mkfields(@names); \& } .Ve .IP "\(bu" 4 Generates constants \*(L"TUPLE_$fieldname\*(R" => \f(CW$fieldposition\fR in \f(CW$CLASS\fR. Just Like if you say \f(CW\*(C`use constant TUPLE_id => 0, TUPLE_f1 => 1, ...;\*(C'\fR .IP "\(bu" 4 Generates \f(CW$CLASS\fR variable \f(CW@fields\fR containing field names, and a \f(CW$CLASS\fR method \f(CW\*(C`FIELDS\*(C'\fR returning \f(CW@fields\fR. .IP "\(bu" 4 Generates \f(CW$CLASS\fR variable \f(CW%fields\fR containing field names mapping to positions, and a \f(CW$CLASS\fR method \f(CW\*(C`FIELDS_HASH\*(C'\fR returning \f(CW\*(C`\e%fields\*(C'\fR. .IP "\(bu" 4 These \f(CW@fields\fR are applied to the \f(CW\*(C`DEFAULT_SPACE\*(C'\fR, if \fIfields\fR were not set explicitly for that space. .PP \fIdeclare_stored_procedure\fR .IX Subsection "declare_stored_procedure" .PP .Vb 1 \& $CLASS\->declare_stored_procedure(%args); \& \& $CLASS\->declare_stored_procedure( \& name => "box.do.something", # internal procedure name, in da box \& method_name => "CallMyTestingStoredProcedure", # will generate method named \& options => { default => options }, # MR::Tarantool::Box\->Call \e%options \& params => [ qw{ P1 P2 P3 Param4 }], # names \& \& unpack_format => "&LSC(L$)*", \& \& params_format => [qw{ C S L a* }], \& params_default => [ 1, 2, undef, \*(Aqthe_default\*(Aq ], # undef\*(Aqs are mandatory params \& ); \& \& ... \& \& my $data = $CLASS\->CallMyTestingStoredProcedure( \& P1 => $val1, \& P2 => $val2, \& P3 => $val3, \& Param4 => $val3, \& { option => $value }, # optional \& ) or warn $CLASS\->ErrorStr; .Ve .PP Declare a stored procedure. This generates \f(CW$CLASS\fR method \f(CW$args{method_name}\fR which calls Tarantool/Box procedure \f(CW$args{name}\fR, using \f(CW$args{options}\fR as default \&\f(CW\*(C`\e%options\*(C'\fR for \f(CW\*(C`MR::Tarantool::Box\->Call\*(C'\fR call. The generated method has the following prototype: .PP .Vb 1 \& $CLASS\->CallMyTestingStoredProcedure( %sp_params, \e%optional_options ); .Ve .PP Parameters description: .IP "\fB\f(CB%args\fB\fR:" 4 .IX Item "%args:" .RS 4 .PD 0 .ie n .IP "\fBname\fR => $tarantool_box_sp_name" 4 .el .IP "\fBname\fR => \f(CW$tarantool_box_sp_name\fR" 4 .IX Item "name => $tarantool_box_sp_name" .PD The name of procedure in Tarantool/Box to call. .ie n .IP "\fBmethod_name\fR => $class_method_name" 4 .el .IP "\fBmethod_name\fR => \f(CW$class_method_name\fR" 4 .IX Item "method_name => $class_method_name" Class method name to generate. .IP "\fBoptions\fR => \e%options" 4 .IX Item "options => %options" Options to pass to MR::Taranatool::Box\-Call|MR::Taranatool::Box/Call> method. .IP "\fBparams\fR => \e@names" 4 .IX Item "params => @names" Procedure input parameters' names .IP "\fBparams_default\fR => \e@defaults" 4 .IX Item "params_default => @defaults" Procedure input parameters default values. Undefined or absent value makes its parameter mandatory. .IP "\fBparams_format\fR => \e@format" 4 .IX Item "params_format => @format" \&\f(CW\*(C`pack()\*(C'\fR\-compatible format to pack input parameters. Must match \f(CW\*(C`params\*(C'\fR. .ie n .IP "\fBunpack_format\fR => $format" 4 .el .IP "\fBunpack_format\fR => \f(CW$format\fR" 4 .IX Item "unpack_format => $format" \&\f(CW\*(C`pack()\*(C'\fR\-compatible format to unpack procedure output. .RE .RS 4 .RE .IP "\fB\f(CB%sp_params\fB\fR:" 4 .IX Item "%sp_params:" \&\f(CW\*(C`Name => $value\*(C'\fR pairs. .IP "\fB\f(CB%optional_options\fB\fR:" 4 .IX Item "%optional_options:" Options to pass to MR::Taranatool::Box\-Call|MR::Taranatool::Box/Call> method. This overrides \f(CW%options\fR values key-by-key. .PP \fIConfiguration methods\fR .IX Subsection "Configuration methods" .IP "\fB\s-1SERVER\s0\fR" 4 .IX Item "SERVER" Must return a string of ip:port of \fImaster\fR server. .IP "\fB\s-1REPLICAS\s0\fR" 4 .IX Item "REPLICAS" Must return a comma separated string of ip:port pairs of \fIreplica\fR servers (see \*(L"is_replica\*(R"). Server is chosen from the list randomly. .IP "\fB\s-1MR_TARANTOOL_BOX_CLASS\s0\fR" 4 .IX Item "MR_TARANTOOL_BOX_CLASS" Must return name of the class implementing MR::Tarantool::Box interface, or it's descendant. .IP "\fB\s-1SPACES\s0\fR, \fB\s-1RAISE\s0\fR, \fB\s-1TIMEOUT\s0\fR, \fB\s-1SELECT_TIMEOUT\s0\fR, \fB\s-1RETRY\s0\fR, \fB\s-1SELECT_RETRY\s0\fR, \fB\s-1SOFT_RETRY\s0\fR, \fB\s-1DEBUG\s0\fR" 4 .IX Item "SPACES, RAISE, TIMEOUT, SELECT_TIMEOUT, RETRY, SELECT_RETRY, SOFT_RETRY, DEBUG" See corresponding arguments of MR::Tarantool::Box\-new|MR::Tarantool::Box/new> method. .PP \fIAdd, Insert, Replace, UpdateMulti, Delete\fR .IX Subsection "Add, Insert, Replace, UpdateMulti, Delete" .PP These methods operate on \f(CW\*(C`SERVER\*(C'\fR only. See corresponding methods of MR::Tarantool::Box class. .PP \fISelect, Call\fR .IX Subsection "Select, Call" .PP These methods operate on \f(CW\*(C`SERVER\*(C'\fR at first, and then \fBmay\fR try to query \f(CW\*(C`REPLICAS\*(C'\fR. .PP See corresponding methods of MR::Tarantool::Box class. .PP These methods have additional \f(CW%options\fR params: .IP "\fBis_replica\fR => \e$is_result_from_replica" 4 .IX Item "is_replica => $is_result_from_replica" If this option is set, then if the query to \f(CW\*(C`SERVER\*(C'\fR fails, \&\f(CW\*(C`REPLICAS\*(C'\fR will be queried one-by-one until query succeeds or the list ends, and \f(CW$is_result_from_replica\fR will be set to \&\f(CW\*(C`true\*(C'\fR, no matter whether any query succeeds or not. .PP \fI\f(BIError\fI, \f(BIErrorStr\fI\fR .IX Subsection "Error, ErrorStr" .PP Return error code or description (see ). .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. .SH "SEE ALSO" .IX Header "SEE ALSO" .PP MR::Tarantool::Box