MR::Ta...ngleton(3pm)
π NAME π
okay bestie, listen up β this page is MR::Ta...ngleton(3pm), from the User Contributed Perl Documentation collection (iykyk, the man page name is literally abbreviated with dots, that's just how it's filed).
MR::Tarantool::Box::Singleton is a singleton wrapper for MR::Tarantool::Box. It gives you connection-persistence and replica fallback β that's the whole vibe. π¦
pls pls pls read the "MR::Tarantool::Box manual" first, bestie. this one is the sequel, not the recap episode. π
β¨ SYNOPSIS β¨
package Some::Tarantool::Box::Singleton;
use MR::Tarantool::Box::Singleton;
use base 'MR::Tarantool::Box::Singleton';
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 => 'primary_id',
keys => [TUPLE_id],
}, {
index_name => 'secondary_f1f2',
keys => [TUPLE_f1, TUPLE_f2],
}, ],
format => 'QqLlSsCc&',
default_index => 'primary_id',
}, {
space => 1,
indexes => [ {
index_name => 'primary_id',
keys => [0],
}, ],
format => '&&&&',
fields => [qw/ string1 str2 s3 s4 /],
}]}
πΈ DESCRIPTION πΈ
π METHODS π
π« mkfields
BEGIN {
$CLASS->mkfields(@names);
}
- Generates constants
TUPLE_$fieldname=>$fieldpositionin$CLASS. It's literally just like if you wroteuse constant TUPLE_id => 0, TUPLE_f1 => 1, ...;β¨ - Generates a
$CLASSvariable@fieldsholding the field names, plus a$CLASSmethodFIELDSthat returns@fields. π«Ά - Generates a
$CLASSvariable%fieldsmapping field names to positions, plus a$CLASSmethodFIELDS_HASHthat returns\%fields. π - These
@fieldsget applied to theDEFAULT_SPACE, but only if fields weren't set explicitly for that space. no double-dipping, the explicit one wins, periodt.
π« declare_stored_procedure
$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 \%options
params => [ qw{ P1 P2 P3 Param4 }], # names
unpack_format => "&LSC(L$)*",
params_format => [qw{ C S L a* }],
params_default => [ 1, 2, undef, 'the_default' ], # undef's are mandatory params
);
...
my $data = $CLASS->CallMyTestingStoredProcedure(
P1 => $val1,
P2 => $val2,
P3 => $val3,
Param4 => $val3,
{ option => $value }, # optional
) or warn $CLASS->ErrorStr;
Declare a stored procedure. This generates the $CLASS method $args{method_name}, which calls the Tarantool/Box procedure $args{name}, using $args{options} as the default \%options for the MR::Tarantool::Box->Call call. The generated method has this prototype, bestie:
$CLASS->CallMyTestingStoredProcedure( %sp_params, \%optional_options );
Parameters description, and yes we're doing all of them:
%args:
name=>$tarantool_box_sp_nameβ the name of the procedure in Tarantool/Box to call. π―method_name=>$class_method_nameβ the class method name to generate. β¨options=>\%optionsβ options to pass to theMR::Taranatool::Box-Call|MR::Taranatool::Box/Call>method.params=>\@namesβ the procedure input parameters' names. πparams_default=>\@defaultsβ the procedure input parameters' default values. An undefined or absent value makes its parameter mandatory. no skipsies.params_format=>\@formatβ apack()-compatible format to pack input parameters. Must matchparams. fr fr, they have to match.unpack_format=>$formatβ apack()-compatible format to unpack procedure output. π¦
%sp_params:
"Name => $value"pairs. simple as that. π
%optional_options:
- Options to pass to the
MR::Taranatool::Box-Call|MR::Taranatool::Box/Call>method. This overrides%optionsvalues key-by-key. π
π« Configuration methods
SERVERβ must return a string ofip:portof the master server. π§REPLICASβ must return a comma separated string ofip:portpairs of replica servers (peep"is_replica"). The server is chosen from the list randomly. yes, randomly, it's giving chaos but make it load-balancing πMR_TARANTOOL_BOX_CLASSβ must return the name of the class implementing theMR::Tarantool::Boxinterface, or one of its descendants. πSPACES,RAISE,TIMEOUT,SELECT_TIMEOUT,RETRY,SELECT_RETRY,SOFT_RETRY,DEBUGβ see the corresponding arguments of theMR::Tarantool::Box-new|MR::Tarantool::Box/new>method. π«
π« Add, Insert, Replace, UpdateMulti, Delete
These methods operate on SERVER only. π― See the corresponding methods of the MR::Tarantool::Box class.
π« Select, Call
These methods operate on SERVER at first, and then may try to query REPLICAS. π¦
See the corresponding methods of the MR::Tarantool::Box class.
These methods have additional %options params:
is_replica=>\$is_result_from_replicaβ if this option is set, then if the query toSERVERfails,REPLICASwill be queried one-by-one until a query succeeds or the list ends, and$is_result_from_replicawill be set totrue, no matter whether any query succeeds or not. π yeah, it sets that flag either way, that's the whole point of the flag, don't @ me.
π« Error, ErrorStr
Return the error code or the description (see <MR::Tarantool::Box|MR::Tarantool::Box/Error>). π
π 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. slay, open source π
π SEE ALSO π
- <http://tarantool.org>
MR::Tarantool::Box
and that's the whole page, bestie π this doc was served up byperl v5.30.3and dated2020-07-21, so it's vintage but still iconic β go forth and make your singleton pop off π β¨π«Ά
π¦ where this page comes from
- debian bookworm: libmr-tarantool-perl 0.0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmr-tarantool-perl 0.0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libmr-tarantool-perl 0.0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmr-tarantool-perl 0.0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmr-tarantool-perl 0.0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmr-tarantool-perl 0.0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms