Coder Social home page Coder Social logo

igorcoding / ev-tarantool16 Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 7.0 641 KB

High performance low-level EV based Tarantool 1.6+ client

Home Page: https://packagecloud.io/igorcoding/tarantoolcontrib

Shell 2.23% Perl 20.65% Lua 1.27% C 69.03% XS 6.82%
perl libev async-programming database-connector tarantool high-performance

ev-tarantool16's Introduction

Build Status

master Travis CI Build status (master)

NAME

EV::Tarantool16 - EV client for Tarantool 1.6

VESRION

Version 1.39

SYNOPSIS

use EV::Tarantool16;
my $c; $c = EV::Tarantool16->new({
    host => '127.0.0.1',
    port => 3301,
    username => 'test_user',
    password => 'test_passwd',
    reconnect => 0.2,
    connected => sub {
        warn "connected: @_";
        EV::unloop;
    },
    connfail => sub {
        warn "connfail: @_ / $!";
        EV::unloop;
    },
    disconnected => sub {
        warn "discon: @_ / $!";
        EV::unloop;
    },
});

$c->connect;
EV::loop;

$c->ping(sub {
    my $a = @_[0];
    diag Dumper \@_ if !$a;
    EV::unloop;
});
EV::loop;

SUBROUTINES/METHODS

new {option => value,...}

Create new EV::Tarantool16 instance.

host => $address

Address connect to.

port => $port

Port connect to.

username => $username

Username.

password => $password

Password.

reconnect => $reconnect

Reconnect timeout.

log_level => $log_level

Logging level. Values: (0: None), (1: Error), (2: Warning), (3: Info), (4: Debug)

cnntrace => $cnntrace

Enable (1) or disable(0) evcnn tracing.

ares_reuse => $ares_reuse

Enable (1) or disable(0) c-ares connection reuse (default = 0).

wbuf_limit => $wbuf_limit

Write vector buffer length limit. Defaults to 16384. Set wbuf_limit = 0 to disable write buffer length check on every request.

connected => $sub

Called when connection to Tarantool 1.6 instance is established, authenticated successfully and retrieved spaces information from it.

connfail => $sub

Called when connection to Tarantool 1.6 instance failed.

disconnected => $sub

Called when Tarantool 1.6 instance disconnected.

connect

Connect to Tarantool 1.6 instance. EV::Tarantool16->connected is called when connection is established.

disconnect

Disconnect from Tarantool 1.6 instance. EV::Tarantool16->disconnected is called afterwards.

ping $opts, $cb->($result)

Execute ping request

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

eval $lua_expression, $tuple_args, $opts, $cb->($result)

Execute eval request

$lua_expression

Lua code that will be run in tarantool

tuple_args

Tuple (ARRAYREF) that will be passed as argument in lua code

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

space => $space

This space definition will be used to decode response tuple

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

call $function_name, $tuple_args, $opts, $cb->($result)

Execute eval request

$function_name

Lua function that will be called in tarantool

tuple_args

Tuple (ARRAYREF) that will be passed as argument in lua code

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

space => $space

This space definition will be used to decode response tuple

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

select $space_name, $keys, $opts, $cb->($result)

Execute select request

$space_name

Tarantool space name.

$keys

Select keys (ARRAYREF or HASHREF).

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

hash => $hash

Use hash as result

index => $index

Index name or id to use

limit => $limit

Select limit

offset => $offset

Select offset

iterator => $iterator

Select iterator type. It is recommended to use the predefined constants EV::Tarantool16::INDEX_#iterator_name# (eg. EV::Tarantool16::INDEX_EQ, EV::Tarantool16::INDEX_GE and so on).

List of possible iterator names:

  • EQ

  • REQ

  • ALL

  • LT

  • LE

  • GE

  • GT

  • BITS_ALL_SET

  • BITS_ANY_SET

  • BITS_ALL_NOT_SET

  • OVERLAPS

  • NEIGHBOR

You can also use string names as the value to this option (like 'EQ' or 'LT').

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

insert $space_name, $tuple, $opts, $cb->($result)

Execute insert request

$space_name

Tarantool space name.

$tuple

Tuple to be inserted (ARRAYREF or HASHREF).

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

hash => $hash

Use hash as result

replace => $replace

Insert(0) or replace(1) a tuple

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

replace $space_name, $tuple, $opts, $cb->($result)

Execute replace request (same as insert, but replaces tuple if already exists). ($opts->{replace} = 1)

update $space_name, $key, $operations, $opts, $cb->($result)

Execute update request

$space_name

Tarantool space name.

$key

Select key where to perform update (ARRAYREF or HASHREF).

$operations

Update operations (ARRAYREF) in this format: [$field_no => $operation, $operation_args] Please refer to Tarantool 1.6 documentaion for more details.

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

hash => $hash

Use hash as result

index => $index

Index name or id to use

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

upsert $space_name, $tuple, $operations, $opts, $cb->($result)

Execute upsert request

$space_name

Tarantool space name.

$tuple

A tuple that will be inserted to Tarantool if there is no tuple like it already (ARRAYREF or HASHREF).

$operations

Update operations (ARRAYREF) in this format: [$field_no => $operation, $operation_args] Please refer to Tarantool 1.6 documentaion for more details.

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

hash => $hash

Use hash as result

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

delete $space_name, $key, $opts, $cb->($result)

Execute delete request

$space_name

Tarantool space name.

$key

Select key (ARRAYREF or HASHREF).

$opts

HASHREF of additional options to the request

timeout => $timeout

Request execution timeout

hash => $hash

Use hash as result

index => $index

Index name or id to use

in => $in

Format for parsing input (string). One char is for one argument ('s' = string, 'n' = number, 'a' = array, '*' = anything (type is determined automatically))

lua $function_name, $args, $opts, $cb->($result)

Execute call request (added for backward compatibility with EV::Tarantool). See 'call' method.

stats $cb->($result)

Get Tarantool stats

Result

Returns a HASHREF, consisting of the following data:

arena
size

Arena allocated size

used

Arena used size

slabs

Slabs memory use

info
lsn

Tarantool log sequence number

lut

Last update time (current_time - box_info.replication.idle)

lag

Replication lag

pid

Process pid

uptime

Server's uptime

op

Total operations count for each operation (select, insert, ...)

space

Tuples count in each space

RESULT

Success result

count => 1,
tuples => [
            {
              _t1 => 'tt1',
              _t2 => 'tt2',
              _t3 => 456,
              _t4 => 5
            }
          ],
status => 'ok',
code => 0,
sync => 5
count

Tuples count

tuples

Tuples themeselves

status

Status string ('ok')

code

Return code (0 if ok, else error code (https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h))

sync

Request id

Error result

[undef, $error_msg, {
    errstr => $error_msg,
    status => 'error',
    code => $error_code,
    sync => 3
}]
errstr

Error string

status

Status string ('error')

code

Return code (0 if ok, else error code (https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h))

sync

Request id

AUTHOR

igorcoding, <[email protected]>, Mons Anderson, <[email protected]>

BUGS

Please report any bugs or feature requests in https://github.com/igorcoding/EV-Tarantool16/issues

COPYRIGHT AND LICENSE

Copyright (C) 2015 by igorcoding

This program is released under the following license: GPL

ev-tarantool16's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ev-tarantool16's Issues

Compiling error: MP_SOURCE is not supported anymore, please link libmsgpuck.a

Running Mkbootstrap for EV::Tarantool16 ()
chmod 644 Tarantool16.bs
cc -c  -I. -I./xstnt -I./xsmy -I./libs/evcnn/src -I./libs/msgpuck -I./libs/crypto -I/usr/include -I/usr/local/lib/x86_64-linux-gnu/perl/5.20.2/EV -I/usr/local/lib/x86_64-linux-gnu/perl/5.20.2 -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"1.37\" -DXS_VERSION=\"1.37\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.20/CORE"  -g -ggdb -O0 -std=c99 -Wall Tarantool16.c
In file included from ./xstnt/xstnt16.h:10:0,
                 from Tarantool16.xs:13:
/usr/include/msgpuck.h:127:2: error: #error MP_SOURCE is not supported anymore, please link libmsgpuck.a
 #error MP_SOURCE is not supported anymore, please link libmsgpuck.a
  ^
Makefile:355: recipe for target 'Tarantool16.o' failed
make: *** [Tarantool16.o] Error 1

How i can fix it ?

need install module Test::Tarantool16 before run tests

t/04-writeio.t .... Can't locate Test/Tarantool16.pm in @INC (you may need to install the Test::Tarantool16 module) (@INC contains: t/lib lib /home/max/trash/source/EV-Tarantool16/EV-Tarantool16-1.37/t/../blib/lib /home/max/trash/source/EV-Tarantool16/EV-Tarantool16-1.37/t/../blib/arch /home/max/trash/source/EV-Tarantool16/EV-Tarantool16-1.37/blib/lib /home/max/trash/source/EV-Tarantool16/EV-Tarantool16-1.37/blib/arch /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at t/04-writeio.t line 15.
BEGIN failed--compilation aborted at t/04-writeio.t line 15.
t/04-writeio.t .... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 

Building RPM

Igor, if you have some time it will be great if you provide ability for build RPM. Looks like .spec exists, but I don't know where.

Thank you !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.