durable_rules 0.34.13 → 0.34.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/librb/durable.rb +9 -3
- data/librb/engine.rb +6 -6
- data/src/rules/Makefile +4 -3
- data/src/rules/events.c +13 -0
- data/src/rules/json.h +1 -0
- data/src/rules/net.c +90 -241
- data/src/rules/regex.c +1240 -0
- data/src/rules/regex.h +20 -0
- data/src/rules/rete.c +107 -26
- data/src/rules/rete.h +12 -0
- data/src/rules/rules.h +9 -1
- data/src/rulesrb/rules.c +6 -5
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aeecc3ee5cdf6e3bd695b9dcd7e8509b4506b0c
|
4
|
+
data.tar.gz: 4d6702f881de8b18f93e498bcc21a6cc2299c11e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b91eda96fb2f9ff19faf9a92f0be6f97da3f577d5b997d067627f5d8b2d3a7976e479095302cb1487b83705263bea66e8943aea4858ae4ad502c228f648fc450
|
7
|
+
data.tar.gz: d55512808c130ff767d6172e969a612d691d6ff0600042907c47d28284cdbb4277669d0533b154a58351d795de317d1451c11754f69941cff3287a6b0b39d0c1
|
data/librb/durable.rb
CHANGED
@@ -5,11 +5,11 @@ module Durable
|
|
5
5
|
@@rulesets = {}
|
6
6
|
@@start_blocks = []
|
7
7
|
|
8
|
-
def self.create_queue(ruleset_name, database = {:host => 'localhost', :port => 6379, :password => nil}, state_cache_size = 1024)
|
8
|
+
def self.create_queue(ruleset_name, database = {:host => 'localhost', :port => 6379, :password => nil, :db => 0}, state_cache_size = 1024)
|
9
9
|
Engine::Queue.new ruleset_name, database, state_cache_size
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.create_host(databases = [{:host => 'localhost', :port => 6379, :password => nil}], state_cache_size = 1024)
|
12
|
+
def self.create_host(databases = [{:host => 'localhost', :port => 6379, :password => nil, :db => 0}], state_cache_size = 1024)
|
13
13
|
main_host = Engine::Host.new @@rulesets, databases, state_cache_size
|
14
14
|
for block in @@start_blocks
|
15
15
|
main_host.instance_exec main_host, &block
|
@@ -18,7 +18,7 @@ module Durable
|
|
18
18
|
main_host
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.run_all(databases = [{:host => 'localhost', :port => 6379, :password => nil}], host_name = nil, port = nil, run = nil, state_cache_size = 1024)
|
21
|
+
def self.run_all(databases = [{:host => 'localhost', :port => 6379, :password => nil, :db => 0}], host_name = nil, port = nil, run = nil, state_cache_size = 1024)
|
22
22
|
main_host = self.create_host databases, state_cache_size
|
23
23
|
Interface::Application.set_host main_host
|
24
24
|
if run
|
@@ -241,6 +241,12 @@ module Durable
|
|
241
241
|
self
|
242
242
|
end
|
243
243
|
|
244
|
+
def matches(other)
|
245
|
+
@__op = :$mt
|
246
|
+
@right = other
|
247
|
+
self
|
248
|
+
end
|
249
|
+
|
244
250
|
def -@
|
245
251
|
@__op = :$nex
|
246
252
|
@right = 1
|
data/librb/engine.rb
CHANGED
@@ -419,9 +419,9 @@ module Engine
|
|
419
419
|
def bind(databases)
|
420
420
|
for db in databases do
|
421
421
|
if db.kind_of? String
|
422
|
-
Rules.bind_ruleset @handle, db, 0, nil
|
422
|
+
Rules.bind_ruleset @handle, db, 0, nil, 0
|
423
423
|
else
|
424
|
-
Rules.bind_ruleset @handle, db[:host], db[:port], db[:password]
|
424
|
+
Rules.bind_ruleset @handle, db[:host], db[:port], db[:password], db[:db]
|
425
425
|
end
|
426
426
|
end
|
427
427
|
end
|
@@ -1086,7 +1086,7 @@ module Engine
|
|
1086
1086
|
|
1087
1087
|
class Host
|
1088
1088
|
|
1089
|
-
def initialize(ruleset_definitions = nil, databases = [{:host => 'localhost', :port => 6379, :password => nil}], state_cache_size = 1024)
|
1089
|
+
def initialize(ruleset_definitions = nil, databases = [{:host => 'localhost', :port => 6379, :password => nil, :db => 0}], state_cache_size = 1024)
|
1090
1090
|
@ruleset_directory = {}
|
1091
1091
|
@ruleset_list = []
|
1092
1092
|
@databases = databases
|
@@ -1303,13 +1303,13 @@ module Engine
|
|
1303
1303
|
|
1304
1304
|
class Queue
|
1305
1305
|
|
1306
|
-
def initialize(ruleset_name, database = {:host => 'localhost', :port => 6379, :password => nil}, state_cache_size = 1024)
|
1306
|
+
def initialize(ruleset_name, database = {:host => 'localhost', :port => 6379, :password => nil, :db => 0}, state_cache_size = 1024)
|
1307
1307
|
@_ruleset_name = ruleset_name.to_s
|
1308
1308
|
@handle = Rules.create_client @_ruleset_name, state_cache_size
|
1309
1309
|
if database.kind_of? String
|
1310
|
-
Rules.bind_ruleset @handle, database, 0, nil
|
1310
|
+
Rules.bind_ruleset @handle, database, 0, nil, 0
|
1311
1311
|
else
|
1312
|
-
Rules.bind_ruleset @handle, database[:host], database[:port], database[:password]
|
1312
|
+
Rules.bind_ruleset @handle, database[:host], database[:port], database[:password], database[:db]
|
1313
1313
|
end
|
1314
1314
|
end
|
1315
1315
|
|
data/src/rules/Makefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
OBJ=events.o json.o net.o rete.o state.o
|
1
|
+
OBJ=events.o json.o net.o rete.o state.o regex.o
|
2
2
|
LIBNAME=librules
|
3
3
|
|
4
4
|
# Fallback to gcc when $CC is not in $PATH.
|
@@ -16,11 +16,12 @@ STLIB_MAKE_CMD=ld $(ARCH) -o $(STLIBNAME) -L../../deps/hiredis/ -lhiredis -r
|
|
16
16
|
all: $(STLIBNAME)
|
17
17
|
|
18
18
|
# Deps (use make dep to generate this)
|
19
|
-
events.o: events.c rules.h net.h json.h
|
19
|
+
events.o: events.c rules.h net.h json.h regex.h
|
20
20
|
json.o: json.c json.h rules.h
|
21
21
|
net.o: net.c net.h rules.h json.h rete.h
|
22
|
-
rete.o: rete.c rete.h net.h json.h state.h
|
22
|
+
rete.o: rete.c rete.h net.h json.h state.h regex.h
|
23
23
|
state.o: state.c state.h json.h net.h
|
24
|
+
regex.o: regex.c regex.h rules.h
|
24
25
|
|
25
26
|
$(STLIBNAME): $(OBJ)
|
26
27
|
$(STLIB_MAKE_CMD) $(OBJ)
|
data/src/rules/events.c
CHANGED
@@ -5,6 +5,9 @@
|
|
5
5
|
#include "rules.h"
|
6
6
|
#include "net.h"
|
7
7
|
#include "json.h"
|
8
|
+
#include "regex.h"
|
9
|
+
|
10
|
+
#include <time.h>
|
8
11
|
|
9
12
|
#define MAX_EVENT_PROPERTIES 64
|
10
13
|
#define MAX_RESULT_NODES 32
|
@@ -35,6 +38,7 @@
|
|
35
38
|
#define OP_STRING_DOUBLE 0x0103
|
36
39
|
#define OP_STRING_STRING 0x0101
|
37
40
|
#define OP_STRING_NIL 0x0107
|
41
|
+
#define OP_STRING_REGEX 0x010C
|
38
42
|
#define OP_NIL_BOOL 0x0704
|
39
43
|
#define OP_NIL_INT 0x0702
|
40
44
|
#define OP_NIL_DOUBLE 0x0703
|
@@ -893,6 +897,15 @@ static unsigned int isMatch(ruleset *tree,
|
|
893
897
|
}
|
894
898
|
|
895
899
|
break;
|
900
|
+
case OP_STRING_REGEX:
|
901
|
+
*propertyMatch = evaluateRegex(tree,
|
902
|
+
message + currentProperty->valueOffset,
|
903
|
+
currentProperty->valueLength,
|
904
|
+
currentAlpha->right.value.regex.vocabularyLength,
|
905
|
+
currentAlpha->right.value.regex.statesLength,
|
906
|
+
currentAlpha->right.value.regex.stateMachineOffset);
|
907
|
+
break;
|
908
|
+
|
896
909
|
}
|
897
910
|
|
898
911
|
if (releaseRightState) {
|
data/src/rules/json.h
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
#define JSON_EVENT_PROPERTY 0x09
|
15
15
|
#define JSON_STATE_IDIOM 0x0A
|
16
16
|
#define JSON_EVENT_IDIOM 0x0B
|
17
|
+
#define JSON_REGEX 0x0C
|
17
18
|
|
18
19
|
unsigned int readNextName(char *start, char **first, char **last, unsigned int *hash);
|
19
20
|
unsigned int readNextValue(char *start, char **first, char **last, unsigned char *type);
|
data/src/rules/net.c
CHANGED
@@ -11,6 +11,39 @@
|
|
11
11
|
#include "rules.h"
|
12
12
|
#include "json.h"
|
13
13
|
|
14
|
+
#define VERIFY(result, origin) do { \
|
15
|
+
if (result != REDIS_OK) { \
|
16
|
+
return ERR_REDIS_ERROR; \
|
17
|
+
} \
|
18
|
+
redisReply *reply; \
|
19
|
+
result = tryGetReply(reContext, &reply); \
|
20
|
+
if (result != RULES_OK) { \
|
21
|
+
return result; \
|
22
|
+
} \
|
23
|
+
if (reply->type == REDIS_REPLY_ERROR) { \
|
24
|
+
printf(origin); \
|
25
|
+
printf(" err string %s\n", reply->str); \
|
26
|
+
freeReplyObject(reply); \
|
27
|
+
return ERR_REDIS_ERROR; \
|
28
|
+
} \
|
29
|
+
freeReplyObject(reply);\
|
30
|
+
} while(0)
|
31
|
+
|
32
|
+
#define GET_REPLY(result, origin, reply) do { \
|
33
|
+
if (result != REDIS_OK) { \
|
34
|
+
return ERR_REDIS_ERROR; \
|
35
|
+
} \
|
36
|
+
result = tryGetReply(reContext, &reply); \
|
37
|
+
if (result != RULES_OK) { \
|
38
|
+
return result; \
|
39
|
+
} \
|
40
|
+
if (reply->type == REDIS_REPLY_ERROR) { \
|
41
|
+
printf(origin); \
|
42
|
+
printf(" err string %s\n", reply->str); \
|
43
|
+
freeReplyObject(reply); \
|
44
|
+
return ERR_REDIS_ERROR; \
|
45
|
+
} \
|
46
|
+
} while(0)
|
14
47
|
|
15
48
|
#ifdef _WIN32
|
16
49
|
int asprintf(char** ret, char* format, ...){
|
@@ -39,6 +72,25 @@ int asprintf(char** ret, char* format, ...){
|
|
39
72
|
}
|
40
73
|
#endif
|
41
74
|
|
75
|
+
static unsigned int tryGetReply(redisContext *reContext,
|
76
|
+
redisReply **reply) {
|
77
|
+
|
78
|
+
if (redisGetReply(reContext, (void**)reply) != REDIS_OK) {
|
79
|
+
printf("getReply err %d, %d, %s\n", reContext->err, errno, reContext->errstr);
|
80
|
+
#ifndef _WIN32
|
81
|
+
if (redisReconnect(reContext) != REDIS_OK) {
|
82
|
+
printf("reconnect err %d, %d, %s\n", reContext->err, errno, reContext->errstr);
|
83
|
+
return ERR_REDIS_ERROR;
|
84
|
+
}
|
85
|
+
return ERR_TRY_AGAIN;
|
86
|
+
#else
|
87
|
+
return ERR_REDIS_ERROR;
|
88
|
+
#endif
|
89
|
+
}
|
90
|
+
|
91
|
+
return RULES_OK;
|
92
|
+
}
|
93
|
+
|
42
94
|
static unsigned int createIdiom(ruleset *tree, jsonValue *newValue, char **idiomString) {
|
43
95
|
char *rightProperty;
|
44
96
|
char *rightAlias;
|
@@ -322,13 +374,8 @@ static unsigned int loadPartitionCommand(ruleset *tree, binding *rulesBinding) {
|
|
322
374
|
return ERR_OUT_OF_MEMORY;
|
323
375
|
}
|
324
376
|
|
325
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
326
|
-
|
327
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
328
|
-
printf("%s\n", reply->str);
|
329
|
-
freeReplyObject(reply);
|
330
|
-
return ERR_REDIS_ERROR;
|
331
|
-
}
|
377
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
378
|
+
GET_REPLY(result, "loadPartitionCommand", reply);
|
332
379
|
|
333
380
|
strncpy(rulesBinding->partitionHash, reply->str, 40);
|
334
381
|
rulesBinding->partitionHash[40] = '\0';
|
@@ -373,15 +420,8 @@ static unsigned int loadRemoveActionCommand(ruleset *tree, binding *rulesBinding
|
|
373
420
|
return ERR_OUT_OF_MEMORY;
|
374
421
|
}
|
375
422
|
|
376
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
377
|
-
|
378
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
379
|
-
printf("%s\n", reply->str);
|
380
|
-
freeReplyObject(reply);
|
381
|
-
free(lua);
|
382
|
-
return ERR_REDIS_ERROR;
|
383
|
-
}
|
384
|
-
|
423
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
424
|
+
GET_REPLY(result, "loadRemoveActionCommand", reply);
|
385
425
|
strncpy(rulesBinding->removeActionHash, reply->str, 40);
|
386
426
|
rulesBinding->removeActionHash[40] = '\0';
|
387
427
|
freeReplyObject(reply);
|
@@ -410,13 +450,8 @@ static unsigned int loadTimerCommand(ruleset *tree, binding *rulesBinding) {
|
|
410
450
|
return ERR_OUT_OF_MEMORY;
|
411
451
|
}
|
412
452
|
|
413
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
414
|
-
|
415
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
416
|
-
printf("%s\n", reply->str);
|
417
|
-
freeReplyObject(reply);
|
418
|
-
return ERR_REDIS_ERROR;
|
419
|
-
}
|
453
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
454
|
+
GET_REPLY(result, "loadTimerCommand", reply);
|
420
455
|
|
421
456
|
strncpy(rulesBinding->timersHash, reply->str, 40);
|
422
457
|
rulesBinding->timersHash[40] = '\0';
|
@@ -440,13 +475,8 @@ static unsigned int loadUpdateActionCommand(ruleset *tree, binding *rulesBinding
|
|
440
475
|
return ERR_OUT_OF_MEMORY;
|
441
476
|
}
|
442
477
|
|
443
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
444
|
-
|
445
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
446
|
-
printf("%s\n", reply->str);
|
447
|
-
freeReplyObject(reply);
|
448
|
-
return ERR_REDIS_ERROR;
|
449
|
-
}
|
478
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
479
|
+
GET_REPLY(result, "loadUpdateActionCommand", reply);
|
450
480
|
|
451
481
|
strncpy(rulesBinding->updateActionHash, reply->str, 40);
|
452
482
|
rulesBinding->updateActionHash[40] = '\0';
|
@@ -548,14 +578,8 @@ static unsigned int loadDeleteSessionCommand(ruleset *tree, binding *rulesBindin
|
|
548
578
|
}
|
549
579
|
|
550
580
|
free(deleteSessionLua);
|
551
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
552
|
-
|
553
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
554
|
-
printf("%s\n", reply->str);
|
555
|
-
freeReplyObject(reply);
|
556
|
-
free(lua);
|
557
|
-
return ERR_REDIS_ERROR;
|
558
|
-
}
|
581
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
582
|
+
GET_REPLY(result, "loadDeleteSessionCommand", reply);
|
559
583
|
|
560
584
|
strncpy(rulesBinding->deleteSessionHash, reply->str, 40);
|
561
585
|
rulesBinding->deleteSessionHash[40] = '\0';
|
@@ -708,14 +732,8 @@ static unsigned int loadAddMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
708
732
|
}
|
709
733
|
|
710
734
|
free(addMessageLua);
|
711
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
712
|
-
|
713
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
714
|
-
printf("%s\n", reply->str);
|
715
|
-
freeReplyObject(reply);
|
716
|
-
free(lua);
|
717
|
-
return ERR_REDIS_ERROR;
|
718
|
-
}
|
735
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
736
|
+
GET_REPLY(result, "loadAddMessageCommand", reply);
|
719
737
|
|
720
738
|
strncpy(rulesBinding->addMessageHash, reply->str, 40);
|
721
739
|
rulesBinding->addMessageHash[40] = '\0';
|
@@ -1188,14 +1206,8 @@ static unsigned int loadPeekActionCommand(ruleset *tree, binding *rulesBinding)
|
|
1188
1206
|
return ERR_OUT_OF_MEMORY;
|
1189
1207
|
}
|
1190
1208
|
free(peekActionLua);
|
1191
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
1192
|
-
|
1193
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
1194
|
-
printf("%s\n", reply->str);
|
1195
|
-
freeReplyObject(reply);
|
1196
|
-
free(lua);
|
1197
|
-
return ERR_REDIS_ERROR;
|
1198
|
-
}
|
1209
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
1210
|
+
GET_REPLY(result, "loadPeekActionCommand", reply);
|
1199
1211
|
|
1200
1212
|
strncpy(rulesBinding->peekActionHash, reply->str, 40);
|
1201
1213
|
rulesBinding->peekActionHash[40] = '\0';
|
@@ -2140,14 +2152,8 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2140
2152
|
}
|
2141
2153
|
|
2142
2154
|
free(oldLua);
|
2143
|
-
redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
2144
|
-
|
2145
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
2146
|
-
printf("%s\n", reply->str);
|
2147
|
-
freeReplyObject(reply);
|
2148
|
-
free(lua);
|
2149
|
-
return ERR_REDIS_ERROR;
|
2150
|
-
}
|
2155
|
+
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
2156
|
+
GET_REPLY(result, "loadEvalMessageCommand", reply);
|
2151
2157
|
|
2152
2158
|
strncpy(rulesBinding->evalMessageHash, reply->str, 40);
|
2153
2159
|
rulesBinding->evalMessageHash[40] = '\0';
|
@@ -2262,7 +2268,8 @@ static unsigned int loadCommands(ruleset *tree, binding *rulesBinding) {
|
|
2262
2268
|
unsigned int bindRuleset(void *handle,
|
2263
2269
|
char *host,
|
2264
2270
|
unsigned int port,
|
2265
|
-
char *password
|
2271
|
+
char *password,
|
2272
|
+
unsigned char db) {
|
2266
2273
|
ruleset *tree = (ruleset*)handle;
|
2267
2274
|
bindingsList *list;
|
2268
2275
|
if (tree->bindingsList) {
|
@@ -2293,32 +2300,26 @@ unsigned int bindRuleset(void *handle,
|
|
2293
2300
|
return ERR_CONNECT_REDIS;
|
2294
2301
|
}
|
2295
2302
|
|
2303
|
+
int result = REDIS_OK;
|
2304
|
+
|
2305
|
+
#ifndef _WIN32
|
2296
2306
|
struct timeval tv;
|
2297
2307
|
tv.tv_sec = 10;
|
2298
2308
|
tv.tv_usec = 0;
|
2299
|
-
|
2309
|
+
result = redisSetTimeout(reContext, tv);
|
2300
2310
|
if (result != REDIS_OK) {
|
2301
2311
|
return ERR_REDIS_ERROR;
|
2302
2312
|
}
|
2313
|
+
#endif
|
2303
2314
|
|
2304
2315
|
if (password != NULL) {
|
2305
2316
|
result = redisAppendCommand(reContext, "auth %s", password);
|
2306
|
-
|
2307
|
-
|
2308
|
-
}
|
2309
|
-
|
2310
|
-
redisReply *reply;
|
2311
|
-
result = redisGetReply(reContext, (void**)&reply);
|
2312
|
-
if (result != REDIS_OK) {
|
2313
|
-
return ERR_REDIS_ERROR;
|
2314
|
-
}
|
2315
|
-
|
2316
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
2317
|
-
freeReplyObject(reply);
|
2318
|
-
return ERR_REDIS_ERROR;
|
2319
|
-
}
|
2317
|
+
VERIFY(result, "bindRuleset");
|
2318
|
+
}
|
2320
2319
|
|
2321
|
-
|
2320
|
+
if (db) {
|
2321
|
+
result = redisAppendCommand(reContext, "select %d", db);
|
2322
|
+
VERIFY(result, "bindRuleset");
|
2322
2323
|
}
|
2323
2324
|
|
2324
2325
|
if (!list->bindings) {
|
@@ -2365,20 +2366,8 @@ unsigned int getBindingIndex(ruleset *tree, unsigned int sidHash, unsigned int *
|
|
2365
2366
|
firstBinding->partitionHash,
|
2366
2367
|
sidHash,
|
2367
2368
|
list->bindingsLength);
|
2368
|
-
if (result != REDIS_OK) {
|
2369
|
-
return ERR_REDIS_ERROR;
|
2370
|
-
}
|
2371
|
-
|
2372
2369
|
redisReply *reply;
|
2373
|
-
result
|
2374
|
-
if (result != REDIS_OK) {
|
2375
|
-
return ERR_REDIS_ERROR;
|
2376
|
-
}
|
2377
|
-
|
2378
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
2379
|
-
freeReplyObject(reply);
|
2380
|
-
return ERR_REDIS_ERROR;
|
2381
|
-
}
|
2370
|
+
GET_REPLY(result, "loadEvalMessageCommand", reply);
|
2382
2371
|
|
2383
2372
|
*bindingIndex = reply->integer;
|
2384
2373
|
freeReplyObject(reply);
|
@@ -2746,25 +2735,6 @@ unsigned int startNonBlockingBatch(void *rulesBinding,
|
|
2746
2735
|
return result;
|
2747
2736
|
}
|
2748
2737
|
|
2749
|
-
static unsigned int tryGetReply(redisContext *reContext,
|
2750
|
-
redisReply **reply) {
|
2751
|
-
|
2752
|
-
if (redisGetReply(reContext, (void**)reply) != REDIS_OK) {
|
2753
|
-
printf("getReply err %d, %d, %s\n", reContext->err, errno, reContext->errstr);
|
2754
|
-
#ifndef _WIN32
|
2755
|
-
if (redisReconnect(reContext) != REDIS_OK) {
|
2756
|
-
printf("reconnect err %d, %d, %s\n", reContext->err, errno, reContext->errstr);
|
2757
|
-
return ERR_REDIS_ERROR;
|
2758
|
-
}
|
2759
|
-
return ERR_TRY_AGAIN;
|
2760
|
-
#else
|
2761
|
-
return ERR_REDIS_ERROR;
|
2762
|
-
#endif
|
2763
|
-
}
|
2764
|
-
|
2765
|
-
return RULES_OK;
|
2766
|
-
}
|
2767
|
-
|
2768
2738
|
unsigned int completeNonBlockingBatch(void *rulesBinding,
|
2769
2739
|
unsigned int replyCount) {
|
2770
2740
|
if (replyCount == 0) {
|
@@ -2873,23 +2843,7 @@ unsigned int removeMessage(void *rulesBinding, char *sid, char *mid) {
|
|
2873
2843
|
currentBinding->factsHashset,
|
2874
2844
|
sid,
|
2875
2845
|
mid);
|
2876
|
-
|
2877
|
-
return ERR_REDIS_ERROR;
|
2878
|
-
}
|
2879
|
-
|
2880
|
-
redisReply *reply;
|
2881
|
-
result = tryGetReply(reContext, &reply);
|
2882
|
-
if (result != RULES_OK) {
|
2883
|
-
return result;
|
2884
|
-
}
|
2885
|
-
|
2886
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
2887
|
-
printf("removeMessage err string %s\n", reply->str);
|
2888
|
-
freeReplyObject(reply);
|
2889
|
-
return ERR_REDIS_ERROR;
|
2890
|
-
}
|
2891
|
-
|
2892
|
-
freeReplyObject(reply);
|
2846
|
+
VERIFY(result, "removeMessage");
|
2893
2847
|
return RULES_OK;
|
2894
2848
|
}
|
2895
2849
|
|
@@ -2980,23 +2934,7 @@ unsigned int registerTimer(void *rulesBinding, unsigned int duration, char *time
|
|
2980
2934
|
currentBinding->timersSortedset,
|
2981
2935
|
currentTime + duration,
|
2982
2936
|
timer);
|
2983
|
-
|
2984
|
-
return ERR_REDIS_ERROR;
|
2985
|
-
}
|
2986
|
-
|
2987
|
-
redisReply *reply;
|
2988
|
-
result = tryGetReply(reContext, &reply);
|
2989
|
-
if (result != RULES_OK) {
|
2990
|
-
return result;
|
2991
|
-
}
|
2992
|
-
|
2993
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
2994
|
-
printf("registerTimer err string %s\n", reply->str);
|
2995
|
-
freeReplyObject(reply);
|
2996
|
-
return ERR_REDIS_ERROR;
|
2997
|
-
}
|
2998
|
-
|
2999
|
-
freeReplyObject(reply);
|
2937
|
+
VERIFY(result, "registerTimer");
|
3000
2938
|
return RULES_OK;
|
3001
2939
|
}
|
3002
2940
|
|
@@ -3008,23 +2946,7 @@ unsigned int removeTimer(void *rulesBinding, char *timer) {
|
|
3008
2946
|
"zrem %s p:%s",
|
3009
2947
|
currentBinding->timersSortedset,
|
3010
2948
|
timer);
|
3011
|
-
|
3012
|
-
return ERR_REDIS_ERROR;
|
3013
|
-
}
|
3014
|
-
|
3015
|
-
redisReply *reply;
|
3016
|
-
result = tryGetReply(reContext, &reply);
|
3017
|
-
if (result != RULES_OK) {
|
3018
|
-
return result;
|
3019
|
-
}
|
3020
|
-
|
3021
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
3022
|
-
printf("deleteTimer err string %s\n", reply->str);
|
3023
|
-
freeReplyObject(reply);
|
3024
|
-
return ERR_REDIS_ERROR;
|
3025
|
-
}
|
3026
|
-
|
3027
|
-
freeReplyObject(reply);
|
2949
|
+
VERIFY(result, "removeTimer");
|
3028
2950
|
return RULES_OK;
|
3029
2951
|
}
|
3030
2952
|
|
@@ -3059,23 +2981,7 @@ unsigned int registerMessage(void *rulesBinding, unsigned int queueAction, char
|
|
3059
2981
|
break;
|
3060
2982
|
}
|
3061
2983
|
|
3062
|
-
|
3063
|
-
return ERR_REDIS_ERROR;
|
3064
|
-
}
|
3065
|
-
|
3066
|
-
redisReply *reply;
|
3067
|
-
result = tryGetReply(reContext, &reply);
|
3068
|
-
if (result != RULES_OK) {
|
3069
|
-
return result;
|
3070
|
-
}
|
3071
|
-
|
3072
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
3073
|
-
printf("registerMessage err string %s\n", reply->str);
|
3074
|
-
freeReplyObject(reply);
|
3075
|
-
return ERR_REDIS_ERROR;
|
3076
|
-
}
|
3077
|
-
|
3078
|
-
freeReplyObject(reply);
|
2984
|
+
VERIFY(result, "registerMessage");
|
3079
2985
|
return RULES_OK;
|
3080
2986
|
}
|
3081
2987
|
|
@@ -3086,21 +2992,8 @@ unsigned int getSession(void *rulesBinding, char *sid, char **state) {
|
|
3086
2992
|
"hget %s %s",
|
3087
2993
|
currentBinding->sessionHashset,
|
3088
2994
|
sid);
|
3089
|
-
if (result != REDIS_OK) {
|
3090
|
-
return ERR_REDIS_ERROR;
|
3091
|
-
}
|
3092
|
-
|
3093
2995
|
redisReply *reply;
|
3094
|
-
result
|
3095
|
-
if (result != RULES_OK) {
|
3096
|
-
return result;
|
3097
|
-
}
|
3098
|
-
|
3099
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
3100
|
-
freeReplyObject(reply);
|
3101
|
-
return ERR_REDIS_ERROR;
|
3102
|
-
}
|
3103
|
-
|
2996
|
+
GET_REPLY(result, "getSession", reply);
|
3104
2997
|
if (reply->type != REDIS_REPLY_STRING) {
|
3105
2998
|
freeReplyObject(reply);
|
3106
2999
|
return ERR_NEW_SESSION;
|
@@ -3122,21 +3015,9 @@ unsigned int getSessionVersion(void *rulesBinding, char *sid, unsigned long *sta
|
|
3122
3015
|
"hget %s!v %s",
|
3123
3016
|
currentBinding->sessionHashset,
|
3124
3017
|
sid);
|
3125
|
-
|
3126
|
-
return ERR_REDIS_ERROR;
|
3127
|
-
}
|
3128
|
-
|
3018
|
+
|
3129
3019
|
redisReply *reply;
|
3130
|
-
result
|
3131
|
-
if (result != RULES_OK) {
|
3132
|
-
return result;
|
3133
|
-
}
|
3134
|
-
|
3135
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
3136
|
-
freeReplyObject(reply);
|
3137
|
-
return ERR_REDIS_ERROR;
|
3138
|
-
}
|
3139
|
-
|
3020
|
+
GET_REPLY(result, "getSessionVersion", reply);
|
3140
3021
|
if (reply->type != REDIS_REPLY_INTEGER) {
|
3141
3022
|
*stateVersion = 0;
|
3142
3023
|
} else {
|
@@ -3155,23 +3036,7 @@ unsigned int deleteSession(void *rulesBinding, char *sid) {
|
|
3155
3036
|
"evalsha %s 0 %s",
|
3156
3037
|
currentBinding->deleteSessionHash,
|
3157
3038
|
sid);
|
3158
|
-
|
3159
|
-
return ERR_REDIS_ERROR;
|
3160
|
-
}
|
3161
|
-
|
3162
|
-
redisReply *reply;
|
3163
|
-
result = tryGetReply(reContext, &reply);
|
3164
|
-
if (result != RULES_OK) {
|
3165
|
-
return result;
|
3166
|
-
}
|
3167
|
-
|
3168
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
3169
|
-
printf("deleteSession err string %s\n", reply->str);
|
3170
|
-
freeReplyObject(reply);
|
3171
|
-
return ERR_REDIS_ERROR;
|
3172
|
-
}
|
3173
|
-
|
3174
|
-
freeReplyObject(reply);
|
3039
|
+
VERIFY(result, "deleteSession");
|
3175
3040
|
return REDIS_OK;
|
3176
3041
|
}
|
3177
3042
|
|
@@ -3185,22 +3050,6 @@ unsigned int updateAction(void *rulesBinding, char *sid) {
|
|
3185
3050
|
currentBinding->updateActionHash,
|
3186
3051
|
sid,
|
3187
3052
|
currentTime + 15);
|
3188
|
-
|
3189
|
-
return ERR_REDIS_ERROR;
|
3190
|
-
}
|
3191
|
-
|
3192
|
-
redisReply *reply;
|
3193
|
-
result = tryGetReply(reContext, &reply);
|
3194
|
-
if (result != RULES_OK) {
|
3195
|
-
return result;
|
3196
|
-
}
|
3197
|
-
|
3198
|
-
if (reply->type == REDIS_REPLY_ERROR) {
|
3199
|
-
printf("updateAction err string %s\n", reply->str);
|
3200
|
-
freeReplyObject(reply);
|
3201
|
-
return ERR_REDIS_ERROR;
|
3202
|
-
}
|
3203
|
-
|
3204
|
-
freeReplyObject(reply);
|
3053
|
+
VERIFY(result, "updateAction");
|
3205
3054
|
return RULES_OK;
|
3206
3055
|
}
|