libdr-tarantool-perl-0.45/000077500000000000000000000000001300064270600154755ustar00rootroot00000000000000libdr-tarantool-perl-0.45/.gitignore000066400000000000000000000000331300064270600174610ustar00rootroot00000000000000.includepath .project blib libdr-tarantool-perl-0.45/.gitlab-ci.yml000066400000000000000000000056521300064270600201410ustar00rootroot00000000000000# test: # script: # - apt-get update # - ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../issh gitlabuploader@debian.nowtaxi.ru pwd before_script: - rm -f ../*.changes - sed -E -i 's/httpredir.debian.org/ftp.de.debian.org/g' /etc/apt/sources.list - apt-get update - apt-get install --yes --no-install-recommends build-essential equivs devscripts git-buildpackage ca-certificates pristine-tar git dpkg-dev coreutils ssh dput - DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool 'apt-get --no-install-recommends --yes' debian/control - git describe - echo $UPLOAD_SSH_KEY | base64 -d > ../issh - chmod 0600 ../issh - echo '[nowtaxi-jessie]' > ../dput.cf - echo login = gitlabuploader >> ../dput.cf - echo fqdn = debian.nowtaxi.ru >> ../dput.cf - echo method = scp >> ../dput.cf - echo incoming = /srv/debian.incomming/jessie >> ../dput.cf - echo ssh_config_options = UserKnownHostsFile=/dev/null >> ../dput.cf - echo ' StrictHostKeyChecking=no' >> ../dput.cf - echo ' IdentityFile=../issh' >> ../dput.cf - echo '[nowtaxi-wheezy]' >> ../dput.cf - echo login = gitlabuploader >> ../dput.cf - echo fqdn = debian.nowtaxi.ru >> ../dput.cf - echo method = scp >> ../dput.cf - echo incoming = /srv/debian.incomming/wheezy >> ../dput.cf - echo ssh_config_options = UserKnownHostsFile=/dev/null >> ../dput.cf - echo ' StrictHostKeyChecking=no' >> ../dput.cf - echo ' IdentityFile=../issh' >> ../dput.cf - echo '[nowtaxi-stretch]' >> ../dput.cf - echo login = gitlabuploader >> ../dput.cf - echo fqdn = debian.nowtaxi.ru >> ../dput.cf - echo method = scp >> ../dput.cf - echo incoming = /srv/debian.incomming/stretch >> ../dput.cf - echo ssh_config_options = UserKnownHostsFile=/dev/null >> ../dput.cf - echo ' StrictHostKeyChecking=no' >> ../dput.cf - echo ' IdentityFile=../issh' >> ../dput.cf wheezy_deb: image: debian:wheezy script: - dch --newversion `git describe|sed -E 's#.*/##'|sed -E 's/-([0-9]+)-(.{8})$/+\1.\2/'`~wheezy --force-distribution --distribution nowtaxi-wheezy 'Autobuilt by git commit' - dpkg-parsechangelog - apt-get -qq --yes install devscripts dpkg-dev git-buildpackage - git-buildpackage --git-ignore-branch --git-builder='debuild -i -I -uc -us -sa' --git-ignore-new - cat ../*.changes - dput --debug -u -c ../dput.cf nowtaxi-wheezy ../*.changes jessie_deb: image: debian:jessie script: - dch --newversion `git describe|sed -E 's#.*/##'|sed -E 's/-([0-9]+)-(.{8})$/+\1.\2/'`~jessie --force-distribution --distribution nowtaxi-jessie 'Autobuilt by git commit' - dpkg-parsechangelog - apt-get -qq --yes install devscripts dpkg-dev git-buildpackage - git-buildpackage --git-ignore-branch --git-builder='debuild -i -I -uc -us -sa' --git-ignore-new - cat ../*.changes - ping -c 2 debian.nowtaxi.ru - dput --debug -u -c ../dput.cf nowtaxi-jessie ../*.changes libdr-tarantool-perl-0.45/.travis.yml000066400000000000000000000012431300064270600176060ustar00rootroot00000000000000sudo: required services: - docker env: matrix: - TRAVIS_DEBIAN_DISTRIBUTION=wheezy - TRAVIS_DEBIAN_DISTRIBUTION=jessie - TRAVIS_DEBIAN_DISTRIBUTION=sid before_install: - sudo apt-get -qq --yes install devscripts dpkg-dev - dch --newversion `git describe|sed -E 's#.*/##'|sed -E 's/-([0-9]+)-(.{8})$/+\1.\2/'` --force-distribution --distribution nowtaxi-$TRAVIS_DEBIAN_DISTRIBUTION 'Autobuilt by git commit' - git commit -m 'update changelog' debian/changelog - dpkg-parsechangelog script: - wget -O- http://travis.debian.net/script.sh | sh - - ls -lR - pwd - echo $TRAVIS_DEBIAN_DISTRIBUTION - ls -l .. branches: only: - master libdr-tarantool-perl-0.45/Changes000077700000000000000000000000001300064270600220572debian/changelogustar00rootroot00000000000000libdr-tarantool-perl-0.45/MANIFEST000066400000000000000000000036621300064270600166350ustar00rootroot00000000000000Changes debian/changelog debian/compat debian/control debian/copyright debian/rules debian/source/format debian/watch lib/DR/Tarantool.pm lib/DR/Tarantool/AEConnection.pm lib/DR/Tarantool/AsyncClient.pm lib/DR/Tarantool/CoroClient.pm lib/DR/Tarantool/Iterator.pm lib/DR/Tarantool/LLClient.pm lib/DR/Tarantool/LLSyncClient.pm lib/DR/Tarantool/MsgPack.pm lib/DR/Tarantool/MsgPack/AsyncClient.pm lib/DR/Tarantool/MsgPack/CoroClient.pm lib/DR/Tarantool/MsgPack/LLClient.pm lib/DR/Tarantool/MsgPack/Proto.pm lib/DR/Tarantool/MsgPack/SyncClient.pm lib/DR/Tarantool/RealSyncClient.pm lib/DR/Tarantool/Spaces.pm lib/DR/Tarantool/StartTest.pm lib/DR/Tarantool/SyncClient.pm lib/DR/Tarantool/Tuple.pm lib/DR/Tarantool/Tuple/MsgPack.pm Makefile.PL MANIFEST msgpack.c msgpack.o msgpuck.h rpm/perl-DR-Tarantool.spec rpm/SOURCES/filter-requires-dr-tarantool.sh st/Check/OneHash.pm st/Check/OneTree.pm st/Check/Order.pm st/Check/Ping.pm st/Check/XlogCleanup.pm st/init.lua st/stress.cfg st/stress.pl st/stress.tarantool.cfg t/000-use.t t/005-connection.t t/010-xs.t t/020-low_level_client.t t/025-ll_synclient.t t/030-spaces.t t/033-iterator.t t/040-tuple.t t/050-async-client.t t/060-sync-client.t t/065-realsync-client.t t/070-coro-client.t t/080-tarantool.t t/090-parallel-requests.t t/1.6/015-msgpack-xs.t t/1.6/017-msgpack-proto.t t/1.6/022-msgpack-llclient.t t/1.6/030-msgpack-async.t t/1.6/040-msgpack-sync.t t/1.6/050-msgpack-coro.t t/1.6/data/ll-grant.lua t/1.6/data/ll.lua t/100-transform.t t/110-netsplit-readahead.t t/120-sessionid.t t/130-reconnect.t t/900-podspell.t t/910-pod.t t/920-critic.xt t/test-data/00013-000-ok.bin t/test-data/00013-14082-error.bin t/test-data/00017-000-ok.bin t/test-data/00019-000-ok.bin t/test-data/00020-000-ok.bin t/test-data/00022-000-ok.bin t/test-data/65280-000-ok.bin t/test-data/empty_tuple.00022-000-ok.bin t/test-data/init.lua t/test-data/llc-easy.cfg t/test-data/llc-easy2.cfg Tarantool.bs Tarantool.c Tarantool.o Tarantool.xs tp.h libdr-tarantool-perl-0.45/Makefile.PL000066400000000000000000000031711300064270600174510ustar00rootroot00000000000000use 5.008008; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'DR::Tarantool', VERSION_FROM => 'lib/DR/Tarantool.pm', # finds $VERSION PREREQ_PM => { 'Carp' => 0, 'File::Temp' => 0, 'File::Path' => 0, 'File::Spec::Functions' => 0, 'Cwd' => 0, 'IO::Socket::INET' => 0, 'AnyEvent' => 0, 'Devel::GlobalDestruction' => 0, 'JSON::XS' => 0, 'List::MoreUtils' => 0, }, # e.g., Module::Name => 1.1 META_MERGE => { resources => { homepage => 'https://github.com/dr-co/dr-tarantool', repository => 'https://github.com/dr-co/dr-tarantool', bugtracker => 'https://github.com/dr-co/dr-tarantool/issues', } }, ABSTRACT_FROM => 'lib/DR/Tarantool.pm', # retrieve abstract from module AUTHOR => 'Dmitry E. Oboukhov ', LIBS => [], # e.g., '-lm' DEFINE => '', # e.g., '-DHAVE_SOMETHING' INC => '-I.', # e.g., '-I. -I/usr/include/other' # Un-comment this if you add C files to link with later: OBJECT => '$(O_FILES)', # link all the C files too LICENSE => 'artistic', ); # if (open my $fh, '>>', 'Makefile') { # print $fh "\n\nTEST_VERBOSE=1\n"; # } libdr-tarantool-perl-0.45/Tarantool.xs000066400000000000000000000233771300064270600200300ustar00rootroot00000000000000/* vim: set ft=c */ /* 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. */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "tp.h" #include "msgpuck.h" extern void _mpack_item(SV *res, SV *o); extern const char *_munpack_item(const char *p, size_t len, SV **res, HV *ext, int utf); #define PREALLOC_SCALAR_SIZE 0 inline static void hash_ssave(HV *h, const char *k, const char *v) { hv_store( h, k, strlen(k), newSVpvn( v, strlen(v) ), 0 ); } inline static void hash_scsave(HV *h, const char *k, SV *sv) { hv_store( h, k, strlen(k), sv, 0); } inline static void hash_isave(HV *h, const char *k, uint32_t v) { hv_store( h, k, strlen(k), newSViv( v ), 0 ); } static char * sv_resizer(struct tp *p, size_t req, size_t *size) { SV *sv = p->obj; STRLEN new_len = tp_size(p) + req; char *new_str = SvGROW(sv, new_len); if (!new_str) croak("Cannot allocate memory"); // SvCUR_set(sv, new_len); *size = new_len; return new_str; } inline static void tp_av_tuple(struct tp *req, AV *tuple) { int i; tp_tuple(req); for (i = 0; i <= av_len(tuple); i++) { SV *field = *av_fetch(tuple, i, 0); char *fd; STRLEN fl; fd = SvPV(field, fl); tp_field(req, fd, fl); } } inline static int fetch_tuples( HV * ret, struct tp * rep ) { AV * tuples = newAV(); hv_store( ret, "tuples", 6, newRV_noinc( ( SV * ) tuples ), 0 ); int code; while ( (code = tp_next(rep)) ) { if (code < 0) return code; AV * t = newAV(); av_push( tuples, newRV_noinc( ( SV * ) t ) ); while((code = tp_nextfield(rep))) { if (code < 0) return code; SV * f = newSVpvn( tp_getfield(rep), tp_getfieldsize(rep) ); av_push( t, f ); } } return 0; } #define ALLOC_RET_SV(__name, __ptr, __len, __size) \ SV *__name = newSVpvn("", 0); \ RETVAL = __name; \ if (__size) SvGROW(__name, __size); \ STRLEN __len; \ char *__ptr = SvPV(__name, __len); MODULE = DR::Tarantool PACKAGE = DR::Tarantool PROTOTYPES: ENABLE SV * _pkt_select( req_id, ns, idx, offset, limit, keys ) unsigned req_id unsigned ns unsigned idx unsigned offset unsigned limit AV * keys CODE: ALLOC_RET_SV(ret, b, len, PREALLOC_SCALAR_SIZE); int k; struct tp req; tp_init(&req, b, PREALLOC_SCALAR_SIZE, sv_resizer, ret); tp_select(&req, ns, idx, offset, limit); for (k = 0; k <= av_len(keys); k++) { SV *t = *av_fetch(keys, k, 0); if (!SvROK(t) || (SvTYPE(SvRV(t)) != SVt_PVAV)) croak("keys must be ARRAYREF of ARRAYREF"); tp_av_tuple(&req, (AV *)SvRV(t)); } tp_reqid(&req, req_id); SvCUR_set(ret, tp_used(&req)); OUTPUT: RETVAL SV * _pkt_ping( req_id ) unsigned req_id CODE: ALLOC_RET_SV(ret, b, len, 0); struct tp req; tp_init(&req, b, len, sv_resizer, ret); tp_ping(&req); tp_reqid(&req, req_id); SvCUR_set(ret, tp_used(&req)); OUTPUT: RETVAL SV * _pkt_insert( req_id, ns, flags, tuple ) unsigned req_id unsigned ns unsigned flags AV * tuple CODE: ALLOC_RET_SV(ret, b, len, PREALLOC_SCALAR_SIZE); struct tp req; tp_init(&req, b, PREALLOC_SCALAR_SIZE, sv_resizer, ret); tp_insert(&req, ns, flags); tp_av_tuple(&req, tuple); tp_reqid(&req, req_id); SvCUR_set(ret, tp_used(&req)); OUTPUT: RETVAL SV * _pkt_delete( req_id, ns, flags, tuple ) unsigned req_id unsigned ns unsigned flags AV *tuple CODE: ALLOC_RET_SV(ret, b, len, PREALLOC_SCALAR_SIZE); struct tp req; tp_init(&req, b, PREALLOC_SCALAR_SIZE, sv_resizer, ret); tp_delete(&req, ns, flags); tp_av_tuple(&req, tuple); tp_reqid(&req, req_id); SvCUR_set(ret, tp_used(&req)); OUTPUT: RETVAL SV * _pkt_call_lua( req_id, flags, proc, tuple ) unsigned req_id unsigned flags SV *proc AV *tuple CODE: STRLEN name_len; char *name = SvPV(proc, name_len); ALLOC_RET_SV(ret, b, len, PREALLOC_SCALAR_SIZE); struct tp req; tp_init(&req, b, PREALLOC_SCALAR_SIZE, sv_resizer, ret); tp_call(&req, flags, name, name_len); tp_av_tuple(&req, tuple); tp_reqid(&req, req_id); SvCUR_set(ret, tp_used(&req)); OUTPUT: RETVAL SV * _pkt_update( req_id, ns, flags, tuple, operations ) unsigned req_id unsigned ns unsigned flags AV *tuple AV *operations CODE: ALLOC_RET_SV(ret, b, len, PREALLOC_SCALAR_SIZE); struct tp req; int i; tp_init(&req, b, PREALLOC_SCALAR_SIZE, sv_resizer, ret); tp_update(&req, ns, flags); tp_reqid(&req, req_id); tp_av_tuple(&req, tuple); tp_updatebegin(&req); for (i = 0; i <= av_len( operations ); i++) { uint8_t opcode; SV *op = *av_fetch( operations, i, 0 ); if (!SvROK(op) || SvTYPE( SvRV(op) ) != SVt_PVAV) croak("Wrong update operation format"); AV *aop = (AV *)SvRV(op); int asize = av_len( aop ) + 1; if ( asize < 2 ) croak("Too short operation argument list"); unsigned fno = SvIV( *av_fetch( aop, 0, 0 ) ); STRLEN size; char *opname = SvPV( *av_fetch( aop, 1, 0 ), size ); /* delete */ if ( strcmp(opname, "delete") == 0 ) { tp_op(&req, fno, TP_OPDELETE, "", 0); continue; } if (asize < 3) croak("Too short operation argument list"); /* assign */ if ( strcmp(opname, "set") == 0 ) { char *data = SvPV( *av_fetch( aop, 2, 0 ), size ); tp_op(&req, fno, TP_OPSET, data, size); continue; } /* insert */ if ( strcmp(opname, "insert") == 0 ) { char *data = SvPV( *av_fetch( aop, 2, 0 ), size ); tp_op(&req, fno, TP_OPINSERT, data, size); continue; } /* arithmetic operations */ if ( strcmp(opname, "add") == 0 ) { opcode = TP_OPADD; goto ARITH; } if ( strcmp(opname, "and") == 0 ) { opcode = TP_OPAND; goto ARITH; } if ( strcmp(opname, "or") == 0 ) { opcode = TP_OPOR; goto ARITH; } if ( strcmp(opname, "xor") == 0 ) { opcode = TP_OPXOR; goto ARITH; } /* substr */ if ( strcmp(opname, "substr") == 0 ) { if (asize < 4) croak("Too short argument " "list for substr"); unsigned offset = SvIV( *av_fetch( aop, 2, 0 ) ); unsigned length = SvIV( *av_fetch( aop, 3, 0 ) ); char * data; if ( asize > 4 && SvOK( *av_fetch( aop, 4, 0 ) ) ) { data = SvPV( *av_fetch( aop, 4, 0 ), size ); } else { data = ""; size = 0; } tp_opsplice(&req, fno, offset, length, data, size); continue; } /* unknown command */ croak("unknown update operation: `%s'", opname); ARITH: { char *data = SvPV( *av_fetch( aop, 2, 0 ), size ); if (sizeof(unsigned long long) < size) size = sizeof(unsigned long long); tp_op(&req, fno, opcode, data, size); continue; } } SvCUR_set(ret, tp_used(&req)); OUTPUT: RETVAL HV * _pkt_parse_response( response ) SV *response INIT: RETVAL = newHV(); sv_2mortal((SV *)RETVAL); CODE: /* asm("break"); */ if ( !SvOK(response) ) croak( "response is undefined" ); STRLEN size; char *data = SvPV( response, size ); struct tp rep; tp_init(&rep, data, size, NULL, 0); // tp_use(&rep, size); ssize_t code = tp_reply(&rep); if (code == -1) { hash_ssave(RETVAL, "status", "buffer"); hash_ssave(RETVAL, "errstr", "Input data too short"); } else if (code >= 0) { uint32_t type = tp_replyop(&rep); hash_isave(RETVAL, "code", tp_replycode(&rep) ); hash_isave(RETVAL, "req_id", tp_getreqid(&rep) ); hash_isave(RETVAL, "type", type ); hash_isave(RETVAL, "count", tp_replycount(&rep) ); if (code == 0) { if (type != TP_PING) code = fetch_tuples(RETVAL, &rep); if (code != 0) { hash_ssave(RETVAL, "status", "buffer"); hash_ssave(RETVAL, "errstr", "Broken response"); } else { hash_ssave(RETVAL, "status", "ok"); } } else { hash_ssave(RETVAL, "status", "error"); size_t el = tp_replyerrorlen(&rep); SV *err; if (el) { char *s = tp_replyerror(&rep); if (s[el - 1] == 0) el--; err = newSVpvn(s, el); } else { err = newSVpvn("", 0); } hash_scsave(RETVAL, "errstr", err); } } OUTPUT: RETVAL unsigned TNT_PING() CODE: RETVAL = TP_PING; OUTPUT: RETVAL unsigned TNT_CALL() CODE: RETVAL = TP_CALL; OUTPUT: RETVAL unsigned TNT_INSERT() CODE: RETVAL = TP_INSERT; OUTPUT: RETVAL unsigned TNT_UPDATE() CODE: RETVAL = TP_UPDATE; OUTPUT: RETVAL unsigned TNT_DELETE() CODE: RETVAL = TP_DELETE; OUTPUT: RETVAL unsigned TNT_SELECT() CODE: RETVAL = TP_SELECT; OUTPUT: RETVAL unsigned TNT_FLAG_RETURN() CODE: RETVAL = TP_BOX_RETURN_TUPLE; OUTPUT: RETVAL unsigned TNT_FLAG_ADD() CODE: RETVAL = TP_BOX_ADD; OUTPUT: RETVAL unsigned TNT_FLAG_REPLACE() CODE: RETVAL = TP_BOX_REPLACE; OUTPUT: RETVAL SV * _msgpack(o) SV *o CODE: SV *res = newSVpvn("", 0); RETVAL = res; _mpack_item(res, o); OUTPUT: RETVAL SV * _msgunpack(str, utf) SV *str; SV *utf; PROTOTYPE: $$ CODE: SV *sv = 0; size_t len; const char *s = SvPV(str, len); if (items > 1) _munpack_item(s, len, &sv, (HV *)ST(1), SvIV(utf)); else _munpack_item(s, len, &sv, NULL, SvIV(utf)); RETVAL = sv; OUTPUT: RETVAL size_t _msgcheck(str) SV *str PROTOTYPE: $ CODE: size_t len; if (SvOK(str)) { const char *p = SvPV(str, len); if (len > 0) { const char *pe = p + len; const char *begin = p; if (mp_check(&p, pe) == 0) { RETVAL = p - begin; } else { RETVAL = 0; } } else { RETVAL = 0; } } else { RETVAL = 0; } OUTPUT: RETVAL libdr-tarantool-perl-0.45/debian/000077500000000000000000000000001300064270600167175ustar00rootroot00000000000000libdr-tarantool-perl-0.45/debian/changelog000066400000000000000000000214151300064270600205740ustar00rootroot00000000000000libdr-tarantool-perl (0.45-1) unstable; urgency=medium * Fix depends (tarantool < 1.6 or tarantool-lts). Now the package can be built for wheezy, jessie, stretch. -- Dmitry E. Oboukhov Sun, 16 Oct 2016 12:14:59 +0300 libdr-tarantool-perl (0.44-1) unstable; urgency=medium * FTBFS (Fix build deps), closes: #798484 * Bump Standards-Version to 3.9.6 -- Dmitry E. Oboukhov Tue, 15 Dec 2015 13:11:48 +0300 libdr-tarantool-perl (0.43-1) unstable; urgency=medium * EINTR doesn't throw exception with RealSyncClient driver. * Fix randomly test segfaults, closes: #727554, thanks to Colin Watson . -- Dmitry E. Oboukhov Sun, 04 May 2014 10:52:41 +0400 libdr-tarantool-perl (0.42-2) nowtaxi; urgency=medium * Rebuild for Nowtaxi repo. -- Dmitry E. Oboukhov Sat, 12 Apr 2014 15:30:16 +0400 libdr-tarantool-perl (0.42-1) unstable; urgency=low * Rebuild for Debian perl 5.18. * Fix some cpan tests (that are run without tarantool). -- Dmitry E. Oboukhov Wed, 18 Sep 2013 01:37:52 +0400 libdr-tarantool-perl (0.41-1) unstable; urgency=low * Fix broken xs-test (by cpan testers reports). -- Dmitry E. Oboukhov Mon, 02 Sep 2013 15:37:11 +0400 libdr-tarantool-perl (0.40-1) unstable; urgency=low * Add RealSyncClient module. -- Dmitry E. Oboukhov Wed, 28 Aug 2013 17:00:13 +0400 libdr-tarantool-perl (0.39-1) unstable; urgency=low * Ping method works even connection isn't established. -- Dmitry E. Oboukhov Wed, 21 Aug 2013 17:33:08 +0400 libdr-tarantool-perl (0.38-1) unstable; urgency=low * Parser doesn't segfault if tarantool replies by broken package. -- Dmitry E. Oboukhov Sat, 01 Jun 2013 21:23:23 +0400 libdr-tarantool-perl (0.37-1) unstable; urgency=low * Update perldoc. -- Dmitry E. Oboukhov Mon, 29 Apr 2013 14:37:25 +0400 libdr-tarantool-perl (0.36-1) unstable; urgency=low * Update perldoc. * Extends readahead buffer to fix FTBFS, closes: #704266. -- Dmitry E. Oboukhov Sun, 21 Apr 2013 12:23:43 +0400 libdr-tarantool-perl (0.35-1) unstable; urgency=low * Add stress test for tarantool, some additional test cases. -- Dmitry E. Oboukhov Wed, 30 Jan 2013 23:54:19 +0400 libdr-tarantool-perl (0.34-1) unstable; urgency=low * Fix some tests. -- Dmitry E. Oboukhov Tue, 29 Jan 2013 10:12:56 +0400 libdr-tarantool-perl (0.33-2) unstable; urgency=low * All requests that are called between reconnects will wait connection instead error returning. -- Dmitry E. Oboukhov Sun, 27 Jan 2013 16:48:26 +0400 libdr-tarantool-perl (0.32-1) unstable; urgency=low * Re-enable tests. -- Dmitry E. Oboukhov Wed, 23 Jan 2013 14:56:43 +0400 libdr-tarantool-perl (0.31-1) unstable; urgency=low * Disable some tests (try to localize some problems with cpan testers). -- Dmitry E. Oboukhov Mon, 21 Jan 2013 21:56:14 +0400 libdr-tarantool-perl (0.30-1) unstable; urgency=low * Fixed empty tuple list in tp.h. -- Dmitry E. Oboukhov Sat, 19 Jan 2013 00:30:24 +0400 libdr-tarantool-perl (0.29-1) unstable; urgency=low * Fixed some warnings in tests. -- Dmitry E. Oboukhov Tue, 15 Jan 2013 22:31:13 +0400 libdr-tarantool-perl (0.28-1) unstable; urgency=low * Fix disconnect async method. -- Dmitry E. Oboukhov Tue, 15 Jan 2013 22:17:35 +0400 libdr-tarantool-perl (0.27-1) unstable; urgency=low * Don't use libtarantool for depends/build-depends. -- Dmitry E. Oboukhov Thu, 10 Jan 2013 17:53:46 +0400 libdr-tarantool-perl (0.26-1) unstable; urgency=low * Update homepage/vcs information. -- Dmitry E. Oboukhov Mon, 07 Jan 2013 03:01:47 +0400 libdr-tarantool-perl (0.25-1) unstable; urgency=low * Uses AE::io instead AE::Handle (benchmarks, benchmarks... :)). -- Dmitry E. Oboukhov Sun, 06 Jan 2013 19:18:46 +0400 libdr-tarantool-perl (0.24-1) unstable; urgency=low * Fix possibly memory leak, closes Debian FTBFS (fix tests), closes: #695660. -- Dmitry E. Oboukhov Tue, 11 Dec 2012 23:28:06 +0400 libdr-tarantool-perl (0.23-1) unstable; urgency=low * LLClient can log requests/reposnses (and error responses). -- Dmitry E. Oboukhov Wed, 05 Sep 2012 13:35:43 +0400 libdr-tarantool-perl (0.22-1) unstable; urgency=low * Prebuild tuple packages (so it doesn't use AUTOLOAD anymore). -- Dmitry E. Oboukhov Mon, 20 Aug 2012 21:19:44 +0400 libdr-tarantool-perl (0.21-1) unstable; urgency=low * Add some functions to iterator (sort, grep, ...). -- Dmitry E. Oboukhov Sun, 15 Jul 2012 20:10:23 +0400 libdr-tarantool-perl (0.20-1) unstable; urgency=low * Some optimizations in iterators. -- Dmitry E. Oboukhov Tue, 10 Jul 2012 10:45:35 +0400 libdr-tarantool-perl (0.19-1) unstable; urgency=low * New upstream version: it is optimized for parallel requests. -- Dmitry E. Oboukhov Thu, 05 Jul 2012 23:50:03 +0400 libdr-tarantool-perl (0.18-1) unstable; urgency=low * HVs are created like perlxs: trying to be compatible with libcoro-perl. -- Dmitry E. Oboukhov Mon, 02 Jul 2012 10:12:39 +0400 libdr-tarantool-perl (0.17-2) unstable; urgency=low * Rebuilt for perl 5.14. -- Dmitry E. Oboukhov Fri, 29 Jun 2012 07:20:46 +0400 libdr-tarantool-perl (0.17-1) unstable; urgency=low * New upstream version (perl 5.8.8 compatible). -- Dmitry E. Oboukhov Wed, 27 Jun 2012 10:38:57 +0400 libdr-tarantool-perl (0.16-1) unstable; urgency=low * New upstream version. Add some functions to iterators. -- Dmitry E. Oboukhov Sat, 23 Jun 2012 16:27:22 +0400 libdr-tarantool-perl (0.15-1) unstable; urgency=low * New upstream version. Fix tuple destructor (it doesn't crashes in global destructor). -- Dmitry E. Oboukhov Thu, 07 Jun 2012 00:08:53 +0400 libdr-tarantool-perl (0.14-1) unstable; urgency=low * New version: Coro can be uninstalled: some tests will be skipped. -- Dmitry E. Oboukhov Mon, 04 Jun 2012 10:21:49 +0400 libdr-tarantool-perl (0.12-1) unstable; urgency=low * New version (provides new field types). -- Dmitry E. Oboukhov Sat, 02 Jun 2012 22:35:47 +0400 libdr-tarantool-perl (0.11-1) unstable; urgency=low * New version. You can use parts of indexes in 'select'. -- Dmitry E. Oboukhov Tue, 29 May 2012 21:21:05 +0400 libdr-tarantool-perl (0.10-1) unstable; urgency=low * New version. Add DR::Tarantool::CoroClient. -- Dmitry E. Oboukhov Mon, 28 May 2012 20:05:12 +0400 libdr-tarantool-perl (0.09-2) unstable; urgency=low * Fix homepage section in debian/control. -- Dmitry E. Oboukhov Mon, 28 May 2012 10:00:48 +0400 libdr-tarantool-perl (0.09-1) unstable; urgency=low * New version. Fix tuple iterator. -- Dmitry E. Oboukhov Sat, 26 May 2012 13:46:38 +0400 libdr-tarantool-perl (0.08-2) unstable; urgency=low * Add libjson-xs-perl into depends. -- Dmitry E. Oboukhov Fri, 25 May 2012 11:20:52 +0400 libdr-tarantool-perl (0.08-1) unstable; urgency=low * New version. Add 'JSON' to fields type list. -- Dmitry E. Oboukhov Fri, 25 May 2012 11:13:30 +0400 libdr-tarantool-perl (0.07-1) unstable; urgency=low * Iterators can construct objects. New version. -- Dmitry E. Oboukhov Thu, 24 May 2012 18:06:52 +0400 libdr-tarantool-perl (0.06-1) unstable; urgency=low * New version (sync methods return tuple or undef). -- Dmitry E. Oboukhov Thu, 24 May 2012 13:51:52 +0400 libdr-tarantool-perl (0.05-1) unstable; urgency=low * New version (some fixes in call_lua). -- Dmitry E. Oboukhov Thu, 24 May 2012 11:52:34 +0400 libdr-tarantool-perl (0.04-1) unstable; urgency=low * New version (upstream upgrades library). -- Dmitry E. Oboukhov Tue, 22 May 2012 17:51:25 +0400 libdr-tarantool-perl (0.03-1) unstable; urgency=low * New version. * Add depends on Devel::GlobalDestruction. -- Dmitry E. Oboukhov Sun, 20 May 2012 17:16:21 +0400 libdr-tarantool-perl (0.02-1) unstable; urgency=low * New version. * Fixed documentation. -- Dmitry E. Oboukhov Sun, 20 May 2012 09:36:46 +0400 libdr-tarantool-perl (0.01-1) unstable; urgency=low * Initial release. (Closes: #673646) -- Dmitry E. Oboukhov Sun, 20 May 2012 01:53:06 +0400 libdr-tarantool-perl-0.45/debian/compat000066400000000000000000000000021300064270600201150ustar00rootroot000000000000007 libdr-tarantool-perl-0.45/debian/control000066400000000000000000000014431300064270600203240ustar00rootroot00000000000000Source: libdr-tarantool-perl Section: perl Homepage: http://search.cpan.org/dist/DR-Tarantool/ Maintainer: Dmitry E. Oboukhov Build-Depends: debhelper (>= 7), cdbs, libanyevent-perl, libdevel-globaldestruction-perl, libjson-xs-perl, tarantool (<< 1.6) | tarantool-lts, aspell-en, libtest-spelling-perl, liblist-moreutils-perl Standards-Version: 3.9.6 Priority: extra VCS-Browser: https://github.com/dr-co/dr-tarantool Package: libdr-tarantool-perl Depends: ${perl:Depends}, ${misc:Depends}, ${shlibs:Depends}, libanyevent-perl, libjson-xs-perl, libdevel-globaldestruction-perl, liblist-moreutils-perl Recommends: libcoro-perl Architecture: any Suggests: tarantool Description: perl driver for Tarantool The package contains sync and async drivers for tarantool database. libdr-tarantool-perl-0.45/debian/copyright000066400000000000000000000037031300064270600206550ustar00rootroot00000000000000Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 Maintainer: Dmitry E. Oboukhov Source: http://search.cpan.org/dist/DR-Tarantool/ Name: DR::Tarantool Files: * Copyright: 2011-2012 Dmitry E. Oboukhov 2011-2012 Roman V. Nikolaev License: Artistic License: Artistic This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, which comes with Perl. . On Debian systems, the complete text of the Artistic License can be found in `/usr/share/common-licenses/Artistic'. File: tp.h Copyright: 2012-2013 Mail.Ru Group License: BSD Copyright (c) 2012-2013 Mail.Ru Group . Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. libdr-tarantool-perl-0.45/debian/rules000077500000000000000000000015161300064270600200020ustar00rootroot00000000000000#!/usr/bin/make -f include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/perl-makemaker.mk MAIN_MODULE = lib/DR/Tarantool.pm DEBVERSION = $(shell dpkg-parsechangelog \ |grep ^Version|awk '{print $$2}'|sed 's/-.*//' ) PERLVERSION = $(shell grep '^our[[:space:]]\+$$VERSION' $(MAIN_MODULE) \ |head -n 1 \ |awk '{print $$4}'|sed "s/[';']//g" ) install/libdr-tarantool-perl:: test $(DEBVERSION) = $(PERLVERSION) make tardist clean:: rm -f Makefile.old rm -fr .pc rm -f DR-Tarantool-*.tar.gz* manifest: clean find -type f | grep -v '^./\.git'|sed 's/^..//' | sort -u > MANIFEST tarball: cd .. && tar \ --exclude=debian \ --exclude=.git \ -czf libdr-tarantool-perl_$(DEBVERSION).orig.tar.gz \ libdr-tarantool-perl-$(DEBVERSION) DEB_INSTALL_CHANGELOGS_ALL := DEB_DH_INSTALLCHANGELOGS_ARGS := -XChanges libdr-tarantool-perl-0.45/debian/source/000077500000000000000000000000001300064270600202175ustar00rootroot00000000000000libdr-tarantool-perl-0.45/debian/source/format000066400000000000000000000000141300064270600214250ustar00rootroot000000000000003.0 (quilt) libdr-tarantool-perl-0.45/debian/source/options000066400000000000000000000000631300064270600216340ustar00rootroot00000000000000extend-diff-ignore = "^\.(travis|gitlab-ci)\.yml$" libdr-tarantool-perl-0.45/debian/watch000066400000000000000000000002021300064270600177420ustar00rootroot00000000000000version=3 http://search.cpan.org/dist/DR-Tarantool/ \ /CPAN/authors/id/U/UN/UNERA/DR-Tarantool-(\d+(?:\.\d+)+).tar.gz libdr-tarantool-perl-0.45/lib/000077500000000000000000000000001300064270600162435ustar00rootroot00000000000000libdr-tarantool-perl-0.45/lib/DR/000077500000000000000000000000001300064270600165505ustar00rootroot00000000000000libdr-tarantool-perl-0.45/lib/DR/Tarantool.pm000066400000000000000000000245331300064270600210600ustar00rootroot00000000000000package DR::Tarantool; =head1 NAME DR::Tarantool - a Perl driver for L =head1 SYNOPSIS use DR::Tarantool ':constant', 'tarantool'; use DR::Tarantool ':all'; my $tnt = tarantool host => '127.0.0.1', port => 123, spaces => { ... } ; $tnt->update( ... ); my $tnt = coro_tarantool host => '127.0.0.1', port => 123, spaces => { ... } ; use DR::Tarantool ':constant', 'async_tarantool'; async_tarantool host => '127.0.0.1', port => 123, spaces => { ... }, sub { ... } ; $tnt->update(...); =head1 DESCRIPTION This module provides a synchronous and asynchronous driver for L. The driver does not have external dependencies, but includes the official light-weight Tarantool C client (a single C header which implements all protocol formatting) for packing requests and unpacking server responses. This driver implements "iproto" protocol described in https://github.com/mailru/tarantool/blob/master/doc/box-protocol.txt It is built on top of L - an asynchronous event framework, and is therefore easiest to integrate into a program which is already based on L. A synchronous version of the driver exists as well, it starts L event machine for every request. The driver supports three work flow types: =over =item L The primary type, provides an asynchronous, callback-based API. Requires a running L machine. =item L Is built on top of L. Starts L machine for every request. After a request is served, the event loop is stopped, and the results are returned to the caller, or, in case of an error, an exception is thrown. =item L Is also built on top of L, but is designed to work in cooperative multitasking environment provided by L. Is fully syntax-compatible with L, but requires a running event loop to operate, like L. Requests from different coroutines are served concurrently. =back L binary protocol contains no representation of database schema or tuple field types. Due to this deficiency, to easily integrate with Perl and automatically convert tuple fields to Perl values, the driver needs to know field names and types. To tell the driver about them, an instance of a dedicated class must be used. L is essentially a Perl hash which describes field types and names for each space used in the program. It can hardly be useful on its own, but once a connection is "enlightened" with an instance of this class, access to all tuple fields by a field name becomes possible. Type conversion, as well as packing/unpacking from Tarantool binary format is performed automatically. Please follow the docs for L to learn how to describe a schema. =head2 Establishing a connection =head3 L DR::Tarantool::AsyncClient->connect( host => $host, port => $port, spaces => { ... }, sub { my ($tnt) = @_; ... } ); The callback passed to connect() gets invoked after a connection is established. The only argument of the callback is the newly established connection handle. The handle's type is L. =head3 L and L my $tnt = DR::Tarantool::SyncClient->connect( host => $host, port => $port, spaces => { ... } ); my $tnt = DR::Tarantool::CoroClient->connect( host => $host, port => $port, spaces => { ... } ); The only difference of synchronous versions from the asynchronous one is absence of a callback. The created connection handle is returned directly from connect(). In this spirit, the only difference of any synchronous API all from the asynchronous counterpart is also in absence of the callback. =head2 Working with tuples =head3 Querying my $user123 = $tnt->select('users' => 123); my $users_by_roles = $tnt->select('users' => 'admins' => 'role_index'); It is possible to select data by a primary key (expects a Perl scalar), secondary, multi-part key (expects an array). The default index used for selection is the primary one, a non-default index can be set by providing index name. The contents of the result set is interpreted in accordance with schema description provided in L. Supported data types are numbers, Unicode strings, JSON, fixed-point decimals. =head3 Insertion $tnt->insert('users' => [ 123, 'vasya', 'admin' ]); Insert a tuple into space 'users', defined in B hash on connect. =head3 Deletion $tnt->delete(users => 123); Delete a tuple from space 'users'. The deletion is always performed by the primary key. =head3 Update $tnt->update(users => 123 => [[ role => set => 'not_admin' ]]); It is possible to modify any field in a tuple. A field can be accessed by field name or number. A set of modifications can be provided in a Perl array. The following update operations are supported: =over =item set Assign a field =item add, and, or, xor Arithmetic and bitwise operations for integers. =item substr Replace a substring with a paste (similar to Perl splice). =item insert Insert a field before the given field. =item delete Delete a field. =item push Append a field at the tail of the tuple. =item pop Pop a field from the tail of the tuple. =back =head3 Lua $tnt->call_lua(my_proc_name => [ arguments, ...]); Invoke a Lua stored procedure by name. =head2 Supported data types The driver supports all Tarantool types (B, B, B), as well as some client-only types, which are converted to the above server types automatically on the client: =over =item UTF8STR A unicode string. =item MONEY Fixed decimal currency. Stores the value on the server in B type, by multiplying the given amount by 100. The largest amount that can be stored in this type is, therefore, around 20 000 000. Can store negative values. =item BIGMONEY The same as above, but uses B as the underlying storage. =item JSON An arbitrary Perl object is automatically serialized to JSON with L on insertion, and deserialized on selection. =back The basic data transfer unit in Tarantool protocol is a single tuple. A selected tuple is automatically wrapped into an instance of class L. An object of this class can be used as an associative container, in which any field can be accessed by field name: my $user = $tnt->select(users => 123); printf("user: %s, role: %s\n", $user->name, $user->role); To run driver tests, the following Perl modules are also necessary: L, L, L, L, L, L. To run tests, do: perl Makefile.PL make make test The test suite attempts to find the server and start it, thus make sure L is available in the path, or export TARANTOOL_BOX=/path/to/tarantool_box. =cut use 5.008008; use strict; use warnings; use Carp; $Carp::Internal{ (__PACKAGE__) }++; use base qw(Exporter); our %EXPORT_TAGS = ( client => [ qw( tarantool async_tarantool coro_tarantool) ], constant => [ qw( TNT_INSERT TNT_SELECT TNT_UPDATE TNT_DELETE TNT_CALL TNT_PING TNT_FLAG_RETURN TNT_FLAG_ADD TNT_FLAG_REPLACE ) ], ); our @EXPORT_OK = ( map { @$_ } values %EXPORT_TAGS ); $EXPORT_TAGS{all} = \@EXPORT_OK; our @EXPORT = @{ $EXPORT_TAGS{client} }; our $VERSION = '0.45'; =head1 EXPORT =head2 tarantool connects to L in synchronous mode using L. =cut sub tarantool { require DR::Tarantool::SyncClient; no warnings 'redefine'; *tarantool = sub { DR::Tarantool::SyncClient->connect(@_); }; goto \&tarantool; } =head2 rsync_tarantool connects to L in synchronous mode using L. =cut sub rsync_tarantool { require DR::Tarantool::RealSyncClient; no warnings 'redefine'; *rsync_tarantool = sub { DR::Tarantool::RealSyncClient->connect(@_); }; goto \&rsync_tarantool; } =head2 async_tarantool connects to L in async mode using L. =cut sub async_tarantool { require DR::Tarantool::AsyncClient; no warnings 'redefine'; *async_tarantool = sub { DR::Tarantool::AsyncClient->connect(@_); }; goto \&async_tarantool; } =head2 coro_tarantol connects to L in async mode using L. =cut sub coro_tarantool { require DR::Tarantool::CoroClient; no warnings 'redefine'; *coro_tarantool = sub { DR::Tarantool::CoroClient->connect(@_); }; goto \&coro_tarantool; } =head2 :constant Exports constants to use in a client request as flags: =over =item TNT_FLAG_RETURN With this flag on, each INSERT/UPDATE request returns the new value of the tuple. DELETE returns the deleted tuple, if it is found. =item TNT_FLAG_ADD With this flag on, INSERT returns an error if an old tuple with the same primary key already exists. No tuple is inserted in this case. =item TNT_FLAG_REPLACE With this flag on, INSERT returns an error if an old tuple for the primary key does not exist. Without either of the flags, INSERT replaces the old tuple if it doesn't exist. =back =cut require XSLoader; XSLoader::load('DR::Tarantool', $VERSION); =head2 :all Exports all functions and constants. =head1 TODO =over =item * Support push, pop in UPDATE. =item * Make it possible to construct B