Skip to content

Commit 6eb1e74

Browse files
committed
Connection pool is removed, use persistent_list instead
1 parent 5fc8f9b commit 6eb1e74

14 files changed

+581
-603
lines changed

README.md

Lines changed: 33 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ Place it into project library path in your IDE.
8282
3. [Manipulation connection](#manipulation-connection)
8383
* [Tarantool::connect](#tarantoolconnect)
8484
* [Tarantool::disconnect](#tarantooldisconnect)
85-
* [Tarantool::authenticate](#tarantoolauthenticate)
8685
* [Tarantool::flushSchema](#tarantoolflushschema)
8786
* [Tarantool::ping](#tarantoolping)
8887
4. [Database queries](#database-queries)
@@ -98,45 +97,44 @@ Place it into project library path in your IDE.
9897

9998
_**Description**_: Available Tarantool Constants
10099

101-
* `TARANTOOL_ITER_EQ` - Equality iterator (ALL)
102-
* `TARANTOOL_ITER_REQ` - Reverse equality iterator
103-
* `TARANTOOL_ITER_ALL` - Get all rows
104-
* `TARANTOOL_ITER_LT` - Less then iterator
105-
* `TARANTOOL_ITER_LE` - Less and equal iterator
106-
* `TARANTOOL_ITER_GE` - Greater and equal iterator
107-
* `TARANTOOL_ITER_GT` - Gtreater then iterator
108-
* `TARANTOOL_ITER_BITSET_ALL_SET` - check if all given bits are set (BITSET only)
109-
* `TARANTOOL_ITER_BITSET_ANY_SET` - check if any given bits are set (BITSET only)
110-
* `TARANTOOL_ITER_BITSET_ALL_NOT_SET` - check if all given bits are not set
100+
* `Tarantool::ITERATOR_EQ` - Equality iterator (ALL)
101+
* `Tarantool::ITERATOR_REQ` - Reverse equality iterator
102+
* `Tarantool::ITERATOR_ALL` - Get all rows
103+
* `Tarantool::ITERATOR_LT` - Less then iterator
104+
* `Tarantool::ITERATOR_LE` - Less and equal iterator
105+
* `Tarantool::ITERATOR_GE` - Greater and equal iterator
106+
* `Tarantool::ITERATOR_GT` - Gtreater then iterator
107+
* `Tarantool::ITERATOR_BITSET_ALL_SET` - check if all given bits are set (BITSET only)
108+
* `Tarantool::ITERATOR_BITSET_ANY_SET` - check if any given bits are set (BITSET only)
109+
* `Tarantool::ITERATOR_BITSET_ALL_NOT_SET` - check if all given bits are not set
111110
(BITSET only)
112-
* `TARANTOOL_ITER_OVERLAPS` - find dots in the n-dimension cube (RTREE only)
113-
* `TARANTOOL_ITER_NEIGHBOR` - find nearest dots (RTREE only)
111+
* `Tarantool::ITERATOR_OVERLAPS` - find dots in the n-dimension cube (RTREE only)
112+
* `Tarantool::ITERATOR_NEIGHBOR` - find nearest dots (RTREE only)
114113

115114
### Class Tarantool
116115

117116
``` php
118117
Tarantool {
119-
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 ] ] )
120-
public bool Tarantool::connect ( void )
121-
public bool Tarantool::disconnect ( void )
122-
public Tarantool::authenticate(string $login [, string $password = NULL ] )
123-
public bool Tarantool::flushSchema ( void )
124-
public bool Tarantool::ping ( void )
125-
public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = TARANTOOL_ITER_EQ ] ] ] ] ] )
126-
public array Tarantool::insert(mixed $space, array $tuple)
127-
public array Tarantool::replace(mixed $space, array $tuple)
128-
public array Tarantool::call(string $procedure [, mixed args])
129-
public array Tarantool::evaluate(string $expression [, mixed args])
130-
public array Tarantool::delete(mixed $space, mixed $key [, mixed $index])
131-
public array Tarantool::update(mixed $space, mixed $key, array $ops [, number $index] )
132-
public array Tarantool::upsert(mixed $space, mixed $key, array $ops [, number $index] )
118+
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
119+
public bool Tarantool::connect ( void )
120+
public bool Tarantool::disconnect ( void )
121+
public bool Tarantool::flushSchema ( void )
122+
public bool Tarantool::ping ( void )
123+
public array Tarantool::select (mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = TARANTOOL_ITERATOR_EQ ] ] ] ] ] )
124+
public array Tarantool::insert (mixed $space, array $tuple)
125+
public array Tarantool::replace (mixed $space, array $tuple)
126+
public array Tarantool::call (string $procedure [, mixed args] )
127+
public array Tarantool::evaluate (string $expression [, mixed args] )
128+
public array Tarantool::delete (mixed $space, mixed $key [, mixed $index] )
129+
public array Tarantool::update (mixed $space, mixed $key, array $ops [, number $index] )
130+
public array Tarantool::upsert (mixed $space, mixed $key, array $ops [, number $index] )
133131
}
134132
```
135133

136134
#### Tarantool::__construct
137135

138136
```
139-
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 ] ] )
137+
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
140138
```
141139

142140
_**Description**_: Creates a Tarantool client
@@ -145,6 +143,10 @@ _**Parameters**_
145143

146144
* `host`: string, default is `'localhost'`
147145
* `port`: number, default is `3301`
146+
* `user`: string, default is `'guest'`
147+
* `password`: string
148+
* `persistent_id`: string (set it, and connection will be persistent, if
149+
`persistent` in config isn't set)
148150

149151
_**Return Value**_
150152

@@ -187,36 +189,6 @@ _**Return Value**_
187189

188190
**BOOL**: True
189191

190-
### Tarantool::authenticate
191-
192-
``` php
193-
public Tarantool::authenticate(string $login [, string $password = NULL ] )
194-
```
195-
196-
_**Description**_: Authenticate to Tarantool using given login/password
197-
198-
_**Parameters**_
199-
200-
* `login`: string - user login (mandatory)
201-
* `password`: string - user password (mandatory, but ignored, if user is guest)
202-
203-
_**Return Value**_ NULL
204-
205-
#### *Example*
206-
207-
``` php
208-
/**
209-
* - user is 'valdis'
210-
* - password is 'pelsh'
211-
*/
212-
$tnt->connect('valdis', 'pelsh')
213-
/**
214-
* - user is 'guest'
215-
* - password is empty and ignored, anyway
216-
*/
217-
$tnt->connect('guest')
218-
```
219-
220192
### Tarantool::flushSchema
221193

222194
``` php
@@ -248,7 +220,7 @@ Throws `Exception` on error.
248220
### Tarantool::select
249221

250222
``` php
251-
public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = TARANTOOL_ITER_EQ ] ] ] ] ] )
223+
public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = TARANTOOL_ITERATOR_EQ ] ] ] ] ] )
252224
```
253225

254226
_**Description**_: Execute select query from Tarantool server.
@@ -262,7 +234,7 @@ _**Parameters**_
262234
* `limit`: Number, limit number of rows to return from select (INT_MAX by default)
263235
* `offset`: Number, offset to select from (0 by default)
264236
* `iterator`: Constant, iterator type. See [Predefined Constants](#predefined-constants)
265-
for more information (`TARANTOOL_ITER_EQ` by default)
237+
for more information (`TARANTOOL_ITERATOR_EQ` by default)
266238

267239
_**Return Value**_
268240

@@ -286,7 +258,7 @@ $tnt->select("test", array(1, "hello"), "isec");
286258
$tnt->select("test", null, null, 100, 100);
287259
// Selects second hundred of rows from space test in reverse equality order
288260
// It meanse: select penultimate hundred
289-
$tnt->select("test", null, null, 100, 100, TARANTOOL_ITER_REQ);
261+
$tnt->select("test", null, null, 100, 100, TARANTOOL_ITERATOR_REQ);
290262
```
291263

292264
### Tarantool::insert, Tarantool::replace

config.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if test "$PHP_TARANTOOL" != "no"; then
77
src/tarantool.c \
88
src/tarantool_network.c \
99
src/tarantool_msgpack.c \
10-
src/tarantool_manager.c \
1110
src/tarantool_schema.c \
1211
src/tarantool_proto.c \
1312
src/tarantool_tp.c \

src/php_tarantool.h

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
#include <ext/standard/info.h>
1212

13+
#ifdef HAVE_CONFIG_H
14+
# include "config.h"
15+
#endif
16+
1317
#if PHP_VERSION_ID >= 70000
1418
# include <ext/standard/php_smart_string.h>
1519
#else
@@ -40,8 +44,7 @@ extern zend_module_entry tarantool_module_entry;
4044
#include "TSRM.h"
4145
#endif
4246

43-
struct pool_manager;
44-
struct tarantool_schema;
47+
typedef struct tarantool_schema tarantool_schema;
4548

4649
#define SSTR_BEG(str) (str->c)
4750
#define SSTR_END(str) (str->c + str->a)
@@ -55,49 +58,63 @@ PHP_RINIT_FUNCTION(tarantool);
5558
PHP_MSHUTDOWN_FUNCTION(tarantool);
5659
PHP_MINFO_FUNCTION(tarantool);
5760

58-
PHP_METHOD(tarantool_class, __construct);
59-
PHP_METHOD(tarantool_class, connect);
60-
PHP_METHOD(tarantool_class, reconnect);
61-
PHP_METHOD(tarantool_class, close);
62-
PHP_METHOD(tarantool_class, authenticate);
63-
PHP_METHOD(tarantool_class, ping);
64-
PHP_METHOD(tarantool_class, select);
65-
PHP_METHOD(tarantool_class, insert);
66-
PHP_METHOD(tarantool_class, replace);
67-
PHP_METHOD(tarantool_class, call);
68-
PHP_METHOD(tarantool_class, eval);
69-
PHP_METHOD(tarantool_class, delete);
70-
PHP_METHOD(tarantool_class, update);
71-
PHP_METHOD(tarantool_class, upsert);
72-
PHP_METHOD(tarantool_class, flush_schema);
61+
PHP_METHOD(Tarantool, __construct);
62+
PHP_METHOD(Tarantool, connect);
63+
PHP_METHOD(Tarantool, reconnect);
64+
PHP_METHOD(Tarantool, close);
65+
PHP_METHOD(Tarantool, authenticate);
66+
PHP_METHOD(Tarantool, ping);
67+
PHP_METHOD(Tarantool, select);
68+
PHP_METHOD(Tarantool, insert);
69+
PHP_METHOD(Tarantool, replace);
70+
PHP_METHOD(Tarantool, call);
71+
PHP_METHOD(Tarantool, eval);
72+
PHP_METHOD(Tarantool, delete);
73+
PHP_METHOD(Tarantool, update);
74+
PHP_METHOD(Tarantool, upsert);
75+
PHP_METHOD(Tarantool, flush_schema);
7376

7477
ZEND_BEGIN_MODULE_GLOBALS(tarantool)
78+
zend_bool persistent;
7579
long sync_counter;
7680
long retry_count;
7781
double retry_sleep;
7882
double timeout;
7983
double request_timeout;
80-
struct pool_manager *manager;
8184
ZEND_END_MODULE_GLOBALS(tarantool)
8285

8386
ZEND_EXTERN_MODULE_GLOBALS(tarantool);
8487

8588
typedef struct tarantool_object {
86-
zend_object zo;
87-
char *host;
88-
int port;
89-
char *login;
90-
char *passwd;
91-
php_stream *stream;
92-
char *persistent_id;
93-
smart_string *value;
94-
struct tp *tps;
95-
char auth;
96-
char *greeting;
97-
char *salt;
98-
struct tarantool_schema *schema;
89+
zend_object zo;
90+
91+
struct tarantool_connection {
92+
char *host;
93+
int port;
94+
char *login;
95+
char *passwd;
96+
php_stream *stream;
97+
tarantool_schema *schema;
98+
smart_string *value;
99+
struct tp *tps;
100+
char *greeting;
101+
char *salt;
102+
/* Only for persistent connections */
103+
char *orig_login;
104+
char *suffix;
105+
int suffix_len;
106+
char *persistent_id;
107+
} *obj;
108+
109+
zend_bool is_persistent;
99110
} tarantool_object;
100111

112+
typedef struct tarantool_connection tarantool_connection;
113+
114+
PHP_TARANTOOL_API zend_class_entry *php_tarantool_get_ce(void);
115+
PHP_TARANTOOL_API zend_class_entry *php_tarantool_get_exception(void);
116+
PHP_TARANTOOL_API zend_class_entry *php_tarantool_get_exception_base(int root TSRMLS_DC);
117+
101118
#ifdef ZTS
102119
# define TARANTOOL_G(v) TSRMG(tarantool_globals_id, zend_tarantool_globals *, v)
103120
#else

0 commit comments

Comments
 (0)