durable_rules 0.34.55 → 0.34.56
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/src/rules/net.c +220 -244
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1839ca20ebfc39836490893e76d37423ce6bde97
|
4
|
+
data.tar.gz: 6c701a34e592b43a49fad96c2aa5d9e1c245fc2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d8038add6e89b2f41e93ea44f2f36788c42efc1d03bc6a73aeb30088b3b66f152b4a9da60b7dfee79f2a911af01033b8d75b31151bf8f8ae7ec7a6a0a9239a0
|
7
|
+
data.tar.gz: 31283e8ff9e14560170b600d098963eaa60862c8382d4429c8c5862d7d2de21d52c8ae282ccc5d0d377fe1150ef668811ed1c3709cb406ed59ed95024b021f9d
|
data/src/rules/net.c
CHANGED
@@ -1463,40 +1463,19 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1463
1463
|
for (unsigned int ii = 0; ii < currentNode->value.c.joinsLength; ++ii) {
|
1464
1464
|
unsigned int currentJoinOffset = tree->nextPool[currentNode->value.c.joinsOffset + ii];
|
1465
1465
|
join *currentJoin = &tree->joinPool[currentJoinOffset];
|
1466
|
-
oldLua = lua;
|
1467
|
-
if (asprintf(&lua,
|
1468
|
-
"%scontext[\"results_key\"] = \"%s!%d!r!\" .. sid\n"
|
1469
|
-
"context[\"expressions_count\"] = %d\n",
|
1470
|
-
lua,
|
1471
|
-
actionName,
|
1472
|
-
ii,
|
1473
|
-
currentJoin->expressionsLength) == -1) {
|
1474
|
-
return ERR_OUT_OF_MEMORY;
|
1475
|
-
}
|
1476
|
-
free(oldLua);
|
1477
|
-
|
1478
1466
|
for (unsigned int iii = 0; iii < currentJoin->expressionsLength; ++iii) {
|
1479
1467
|
unsigned int expressionOffset = tree->nextPool[currentJoin->expressionsOffset + iii];
|
1480
1468
|
expression *expr = &tree->expressionPool[expressionOffset];
|
1481
1469
|
char *currentKey = &tree->stringPool[expr->nameOffset];
|
1482
1470
|
char *currentAlias = &tree->stringPool[expr->aliasOffset];
|
1483
|
-
|
1484
|
-
|
1471
|
+
unsigned int nextExpressionOffset = 0;
|
1485
1472
|
if (iii == (currentJoin->expressionsLength - 1)) {
|
1486
|
-
|
1487
|
-
if (!nextKeyTest) {
|
1488
|
-
return ERR_OUT_OF_MEMORY;
|
1489
|
-
}
|
1473
|
+
nextExpressionOffset = tree->nextPool[currentJoin->expressionsOffset];
|
1490
1474
|
} else {
|
1491
|
-
|
1492
|
-
expression *nextExpr = &tree->expressionPool[nextExpressionOffset];
|
1493
|
-
if (asprintf(&nextKeyTest,
|
1494
|
-
"or input_keys[\"%s\"]",
|
1495
|
-
&tree->stringPool[nextExpr->nameOffset]) == -1) {
|
1496
|
-
return ERR_OUT_OF_MEMORY;
|
1497
|
-
}
|
1475
|
+
nextExpressionOffset = tree->nextPool[currentJoin->expressionsOffset + iii + 1];
|
1498
1476
|
}
|
1499
|
-
|
1477
|
+
|
1478
|
+
expression *nextExpr = &tree->expressionPool[nextExpressionOffset];
|
1500
1479
|
if (iii == 0) {
|
1501
1480
|
if (expr->not) {
|
1502
1481
|
if (asprintf(&packFrameLua,
|
@@ -1512,39 +1491,42 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1512
1491
|
|
1513
1492
|
oldLua = lua;
|
1514
1493
|
if (asprintf(&lua,
|
1515
|
-
"%
|
1516
|
-
"
|
1517
|
-
"
|
1518
|
-
"
|
1519
|
-
"
|
1520
|
-
"
|
1521
|
-
"
|
1494
|
+
"%sfunction_tree[\"%s\"] = function(key, context)\n"
|
1495
|
+
" if not context then\n"
|
1496
|
+
" context = create_context()\n"
|
1497
|
+
" context[\"results_key\"] = \"%s!%d!r!\" .. sid\n"
|
1498
|
+
" context[\"expressions_count\"] = %d\n"
|
1499
|
+
" end\n"
|
1500
|
+
" context[\"keys\"][1] = \"%s\"\n"
|
1501
|
+
" context[\"inverse_directory\"][1] = true\n"
|
1502
|
+
" context[\"directory\"][\"%s\"] = 1\n"
|
1503
|
+
" context[\"reviewers\"][1] = function(message, frame, index)\n"
|
1522
1504
|
" if not message then\n"
|
1523
1505
|
" frame[\"%s\"] = \"$n\"\n"
|
1524
1506
|
" return true\n"
|
1525
1507
|
" end\n"
|
1526
1508
|
" return false\n"
|
1527
1509
|
" end\n"
|
1528
|
-
" frame_packers[1] = function(frame, full_encode)\n"
|
1510
|
+
" context[\"frame_packers\"][1] = function(frame, full_encode)\n"
|
1529
1511
|
" local result = {}\n%s"
|
1530
1512
|
" return cmsgpack.pack(result)\n"
|
1531
1513
|
" end\n"
|
1532
|
-
" frame_unpackers[1] = function(packed_frame)\n"
|
1514
|
+
" context[\"frame_unpackers\"][1] = function(packed_frame)\n"
|
1533
1515
|
" local frame = cmsgpack.unpack(packed_frame)\n"
|
1534
1516
|
" local result = {}\n%s"
|
1535
1517
|
" return result\n"
|
1536
1518
|
" end\n"
|
1537
|
-
" primary_message_keys[1] = function(message)\n"
|
1519
|
+
" context[\"primary_message_keys\"][1] = function(message)\n"
|
1538
1520
|
" return \"\"\n"
|
1539
1521
|
" end\n"
|
1540
|
-
" primary_frame_keys[1] = function(frame)\n"
|
1522
|
+
" context[\"primary_frame_keys\"][1] = function(frame)\n"
|
1541
1523
|
" return \"\"\n"
|
1542
|
-
" end\n"
|
1543
|
-
"end\n",
|
1524
|
+
" end\n",
|
1544
1525
|
lua,
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1526
|
+
&tree->stringPool[nextExpr->nameOffset],
|
1527
|
+
actionName,
|
1528
|
+
ii,
|
1529
|
+
currentJoin->expressionsLength,
|
1548
1530
|
currentKey,
|
1549
1531
|
currentKey,
|
1550
1532
|
currentAlias,
|
@@ -1555,64 +1537,68 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1555
1537
|
free(oldLua);
|
1556
1538
|
// not (expr->not)
|
1557
1539
|
} else {
|
1540
|
+
|
1558
1541
|
if (asprintf(&packFrameLua,
|
1559
|
-
"
|
1560
|
-
"
|
1561
|
-
"
|
1562
|
-
"
|
1563
|
-
"
|
1564
|
-
"
|
1542
|
+
" message = frame[\"%s\"]\n"
|
1543
|
+
" if full_encode and not message[\"$f\"] then\n"
|
1544
|
+
" result[1] = message\n"
|
1545
|
+
" else\n"
|
1546
|
+
" result[1] = message[\"id\"]\n"
|
1547
|
+
" end\n",
|
1565
1548
|
currentAlias) == -1) {
|
1566
1549
|
return ERR_OUT_OF_MEMORY;
|
1567
1550
|
}
|
1568
1551
|
|
1569
1552
|
if (asprintf(&unpackFrameLua,
|
1570
|
-
"
|
1571
|
-
"
|
1572
|
-
"
|
1573
|
-
"
|
1574
|
-
"
|
1553
|
+
" message = fetch_message(frame[1])\n"
|
1554
|
+
" if not message then\n"
|
1555
|
+
" return nil\n"
|
1556
|
+
" end\n"
|
1557
|
+
" result[\"%s\"] = message\n",
|
1575
1558
|
currentAlias) == -1) {
|
1576
1559
|
return ERR_OUT_OF_MEMORY;
|
1577
1560
|
}
|
1578
1561
|
|
1579
1562
|
oldLua = lua;
|
1580
1563
|
if (asprintf(&lua,
|
1581
|
-
"%
|
1582
|
-
"
|
1583
|
-
"
|
1584
|
-
"
|
1585
|
-
"
|
1586
|
-
"
|
1587
|
-
"
|
1564
|
+
"%sfunction_tree[\"%s\"] = function(key, context)\n"
|
1565
|
+
" if not context then\n"
|
1566
|
+
" context = create_context()\n"
|
1567
|
+
" context[\"results_key\"] = \"%s!%d!r!\" .. sid\n"
|
1568
|
+
" context[\"expressions_count\"] = %d\n"
|
1569
|
+
" end\n"
|
1570
|
+
" context[\"keys\"][1] = \"%s\"\n"
|
1571
|
+
" context[\"inverse_directory\"][1] = true\n"
|
1572
|
+
" context[\"directory\"][\"%s\"] = 1\n"
|
1573
|
+
" context[\"reviewers\"][1] = function(message, frame, index)\n"
|
1588
1574
|
" if message then\n"
|
1589
1575
|
" frame[\"%s\"] = message\n"
|
1590
1576
|
" return true\n"
|
1591
1577
|
" end\n"
|
1592
1578
|
" return false\n"
|
1593
1579
|
" end\n"
|
1594
|
-
" frame_packers[1] = function(frame, full_encode)\n"
|
1580
|
+
" context[\"frame_packers\"][1] = function(frame, full_encode)\n"
|
1595
1581
|
" local result = {}\n"
|
1596
1582
|
" local message\n%s"
|
1597
1583
|
" return cmsgpack.pack(result)\n"
|
1598
1584
|
" end\n"
|
1599
|
-
" frame_unpackers[1] = function(packed_frame)\n"
|
1585
|
+
" context[\"frame_unpackers\"][1] = function(packed_frame)\n"
|
1600
1586
|
" local frame = cmsgpack.unpack(packed_frame)\n"
|
1601
1587
|
" local result = {}\n"
|
1602
1588
|
" local message\n%s"
|
1603
1589
|
" return result\n"
|
1604
1590
|
" end\n"
|
1605
|
-
" primary_message_keys[1] = function(message)\n"
|
1591
|
+
" context[\"primary_message_keys\"][1] = function(message)\n"
|
1606
1592
|
" return \"\"\n"
|
1607
1593
|
" end\n"
|
1608
|
-
" primary_frame_keys[1] = function(frame)\n"
|
1594
|
+
" context[\"primary_frame_keys\"][1] = function(frame)\n"
|
1609
1595
|
" return \"\"\n"
|
1610
|
-
" end\n"
|
1611
|
-
"end\n",
|
1596
|
+
" end\n",
|
1612
1597
|
lua,
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1598
|
+
&tree->stringPool[nextExpr->nameOffset],
|
1599
|
+
actionName,
|
1600
|
+
ii,
|
1601
|
+
currentJoin->expressionsLength,
|
1616
1602
|
currentKey,
|
1617
1603
|
currentKey,
|
1618
1604
|
currentAlias,
|
@@ -1624,10 +1610,24 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1624
1610
|
}
|
1625
1611
|
// not (iii == 0)
|
1626
1612
|
} else {
|
1613
|
+
if (iii < (currentJoin->expressionsLength - 1)) {
|
1614
|
+
oldLua = lua;
|
1615
|
+
if (asprintf(&lua,
|
1616
|
+
"%s function_tree[\"%s\"](key, context)\n"
|
1617
|
+
"end\n"
|
1618
|
+
"function_tree[\"%s\"] = function(key, context)\n",
|
1619
|
+
lua,
|
1620
|
+
&tree->stringPool[nextExpr->nameOffset],
|
1621
|
+
&tree->stringPool[nextExpr->nameOffset]) == -1) {
|
1622
|
+
return ERR_OUT_OF_MEMORY;
|
1623
|
+
}
|
1624
|
+
free(oldLua);
|
1625
|
+
}
|
1626
|
+
|
1627
1627
|
char *test = NULL;
|
1628
1628
|
char *primaryKeyLua = NULL;
|
1629
1629
|
char *primaryFrameKeyLua = NULL;
|
1630
|
-
|
1630
|
+
|
1631
1631
|
unsigned int result = createTest(tree, expr, &test, &primaryKeyLua, &primaryFrameKeyLua);
|
1632
1632
|
if (result != RULES_OK) {
|
1633
1633
|
return result;
|
@@ -1654,42 +1654,44 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1654
1654
|
|
1655
1655
|
oldLua = lua;
|
1656
1656
|
if (asprintf(&lua,
|
1657
|
-
"%
|
1658
|
-
"
|
1659
|
-
"
|
1660
|
-
"
|
1661
|
-
"
|
1662
|
-
"
|
1663
|
-
"
|
1657
|
+
"%s if not context then\n"
|
1658
|
+
" context = create_context()\n"
|
1659
|
+
" context[\"results_key\"] = \"%s!%d!r!\" .. sid\n"
|
1660
|
+
" context[\"expressions_count\"] = %d\n"
|
1661
|
+
" end\n"
|
1662
|
+
" context[\"keys\"][%d] = \"%s\"\n"
|
1663
|
+
" context[\"inverse_directory\"][%d] = true\n"
|
1664
|
+
" context[\"directory\"][\"%s\"] = %d\n"
|
1665
|
+
" context[\"reviewers\"][%d] = function(message, frame, index)\n"
|
1664
1666
|
" if not message or not (%s) then\n"
|
1665
1667
|
" frame[\"%s\"] = \"$n\"\n"
|
1666
1668
|
" return true\n"
|
1667
1669
|
" end\n"
|
1668
1670
|
" return false\n"
|
1669
1671
|
" end\n"
|
1670
|
-
" frame_packers[%d] = function(frame, full_encode)\n"
|
1672
|
+
" context[\"frame_packers\"][%d] = function(frame, full_encode)\n"
|
1671
1673
|
" local result = {}\n"
|
1672
1674
|
" local message\n%s"
|
1673
1675
|
" return cmsgpack.pack(result)\n"
|
1674
1676
|
" end\n"
|
1675
|
-
" frame_unpackers[%d] = function(packed_frame)\n"
|
1677
|
+
" context[\"frame_unpackers\"][%d] = function(packed_frame)\n"
|
1676
1678
|
" local frame = cmsgpack.unpack(packed_frame)\n"
|
1677
1679
|
" local result = {}\n"
|
1678
1680
|
" local message\n%s"
|
1679
1681
|
" return result\n"
|
1680
1682
|
" end\n"
|
1681
|
-
" primary_message_keys[%d] = function(message)\n"
|
1683
|
+
" context[\"primary_message_keys\"][%d] = function(message)\n"
|
1682
1684
|
" local result = \"\"\n%s"
|
1683
1685
|
" return result\n"
|
1684
1686
|
" end\n"
|
1685
|
-
" primary_frame_keys[%d] = function(frame)\n"
|
1687
|
+
" context[\"primary_frame_keys\"][%d] = function(frame)\n"
|
1686
1688
|
" local result = \"\"\n%s"
|
1687
1689
|
" return result\n"
|
1688
|
-
" end\n"
|
1689
|
-
"end\n",
|
1690
|
+
" end\n",
|
1690
1691
|
lua,
|
1691
|
-
|
1692
|
-
|
1692
|
+
actionName,
|
1693
|
+
ii,
|
1694
|
+
currentJoin->expressionsLength,
|
1693
1695
|
iii + 1,
|
1694
1696
|
currentKey,
|
1695
1697
|
iii + 1,
|
@@ -1714,12 +1716,12 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1714
1716
|
} else {
|
1715
1717
|
oldPackFrameLua = packFrameLua;
|
1716
1718
|
if (asprintf(&packFrameLua,
|
1717
|
-
"%s
|
1718
|
-
"
|
1719
|
-
"
|
1720
|
-
"
|
1721
|
-
"
|
1722
|
-
"
|
1719
|
+
"%s message = frame[\"%s\"]\n"
|
1720
|
+
" if full_encode and not message[\"$f\"] then\n"
|
1721
|
+
" result[%d] = message\n"
|
1722
|
+
" else\n"
|
1723
|
+
" result[%d] = message[\"id\"]\n"
|
1724
|
+
" end\n",
|
1723
1725
|
packFrameLua,
|
1724
1726
|
currentAlias,
|
1725
1727
|
iii + 1,
|
@@ -1730,11 +1732,11 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1730
1732
|
|
1731
1733
|
oldUnpackFrameLua = unpackFrameLua;
|
1732
1734
|
if (asprintf(&unpackFrameLua,
|
1733
|
-
"%s
|
1734
|
-
"
|
1735
|
-
"
|
1736
|
-
"
|
1737
|
-
"
|
1735
|
+
"%s message = fetch_message(frame[%d])\n"
|
1736
|
+
" if not message then\n"
|
1737
|
+
" return nil\n"
|
1738
|
+
" end\n"
|
1739
|
+
" result[\"%s\"] = message\n",
|
1738
1740
|
unpackFrameLua,
|
1739
1741
|
iii + 1,
|
1740
1742
|
currentAlias) == -1) {
|
@@ -1744,41 +1746,43 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1744
1746
|
|
1745
1747
|
oldLua = lua;
|
1746
1748
|
if (asprintf(&lua,
|
1747
|
-
"%
|
1748
|
-
"
|
1749
|
-
"
|
1750
|
-
"
|
1751
|
-
"
|
1752
|
-
"
|
1749
|
+
"%s if not context then\n"
|
1750
|
+
" context = create_context()\n"
|
1751
|
+
" context[\"results_key\"] = \"%s!%d!r!\" .. sid\n"
|
1752
|
+
" context[\"expressions_count\"] = %d\n"
|
1753
|
+
" end\n"
|
1754
|
+
" context[\"keys\"][%d] = \"%s\"\n"
|
1755
|
+
" context[\"directory\"][\"%s\"] = %d\n"
|
1756
|
+
" context[\"reviewers\"][%d] = function(message, frame, index)\n"
|
1753
1757
|
" if message and %s then\n"
|
1754
1758
|
" frame[\"%s\"] = message\n"
|
1755
1759
|
" return true\n"
|
1756
1760
|
" end\n"
|
1757
1761
|
" return false\n"
|
1758
1762
|
" end\n"
|
1759
|
-
" frame_packers[%d] = function(frame, full_encode)\n"
|
1763
|
+
" context[\"frame_packers\"][%d] = function(frame, full_encode)\n"
|
1760
1764
|
" local result = {}\n"
|
1761
1765
|
" local message\n%s"
|
1762
1766
|
" return cmsgpack.pack(result)\n"
|
1763
1767
|
" end\n"
|
1764
|
-
" frame_unpackers[%d] = function(packed_frame)\n"
|
1768
|
+
" context[\"frame_unpackers\"][%d] = function(packed_frame)\n"
|
1765
1769
|
" local frame = cmsgpack.unpack(packed_frame)\n"
|
1766
1770
|
" local result = {}\n"
|
1767
1771
|
" local message\n%s"
|
1768
1772
|
" return result\n"
|
1769
1773
|
" end\n"
|
1770
|
-
" primary_message_keys[%d] = function(message)\n"
|
1774
|
+
" context[\"primary_message_keys\"][%d] = function(message)\n"
|
1771
1775
|
" local result = \"\"\n%s"
|
1772
1776
|
" return result\n"
|
1773
1777
|
" end\n"
|
1774
|
-
" primary_frame_keys[%d] = function(frame)\n"
|
1778
|
+
" context[\"primary_frame_keys\"][%d] = function(frame)\n"
|
1775
1779
|
" local result = \"\"\n%s"
|
1776
1780
|
" return result\n"
|
1777
|
-
" end\n"
|
1778
|
-
"end\n",
|
1781
|
+
" end\n",
|
1779
1782
|
lua,
|
1780
|
-
|
1781
|
-
|
1783
|
+
actionName,
|
1784
|
+
ii,
|
1785
|
+
currentJoin->expressionsLength,
|
1782
1786
|
iii + 1,
|
1783
1787
|
currentKey,
|
1784
1788
|
currentKey,
|
@@ -1799,7 +1803,6 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1799
1803
|
free(oldLua);
|
1800
1804
|
// done not (expr->not)
|
1801
1805
|
}
|
1802
|
-
free(nextKeyTest);
|
1803
1806
|
free(test);
|
1804
1807
|
free(primaryKeyLua);
|
1805
1808
|
free(primaryFrameKeyLua);
|
@@ -1810,14 +1813,9 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1810
1813
|
if (currentNode->value.c.cap > 0) {
|
1811
1814
|
oldLua = lua;
|
1812
1815
|
if (asprintf(&lua,
|
1813
|
-
"%
|
1814
|
-
" context[\"process_key\"] = process_key_with_cap\n"
|
1816
|
+
"%s context[\"process_key\"] = process_key_with_cap\n"
|
1815
1817
|
" context[\"process_key_count\"] = %d\n"
|
1816
|
-
"
|
1817
|
-
" return\n"
|
1818
|
-
" else\n"
|
1819
|
-
" cleanup_context()\n"
|
1820
|
-
" end\n"
|
1818
|
+
" return process_message(message, key, context)\n"
|
1821
1819
|
"end\n",
|
1822
1820
|
lua,
|
1823
1821
|
currentNode->value.c.cap) == -1) {
|
@@ -1828,14 +1826,9 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1828
1826
|
} else {
|
1829
1827
|
oldLua = lua;
|
1830
1828
|
if (asprintf(&lua,
|
1831
|
-
"%
|
1832
|
-
" context[\"process_key\"] = process_key_with_window\n"
|
1829
|
+
"%s context[\"process_key\"] = process_key_with_window\n"
|
1833
1830
|
" context[\"process_key_count\"] = %d\n"
|
1834
|
-
"
|
1835
|
-
" return\n"
|
1836
|
-
" else\n"
|
1837
|
-
" cleanup_context()\n"
|
1838
|
-
" end\n"
|
1831
|
+
" return process_message(message, key, context)\n"
|
1839
1832
|
"end\n",
|
1840
1833
|
lua,
|
1841
1834
|
currentNode->value.c.count) == -1) {
|
@@ -1843,6 +1836,22 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1843
1836
|
}
|
1844
1837
|
free(oldLua);
|
1845
1838
|
}
|
1839
|
+
|
1840
|
+
unsigned int firstExpressionOffset = tree->nextPool[currentJoin->expressionsOffset];
|
1841
|
+
unsigned int secondExpressionOffset = tree->nextPool[currentJoin->expressionsOffset + 1];
|
1842
|
+
expression *firstExpr = &tree->expressionPool[firstExpressionOffset];
|
1843
|
+
expression *secondExpr = &tree->expressionPool[secondExpressionOffset];
|
1844
|
+
if (currentJoin->expressionsLength > 1) {
|
1845
|
+
oldLua = lua;
|
1846
|
+
if (asprintf(&lua,
|
1847
|
+
"%sfunction_tree[\"%s\"] = function_tree[\"%s\"]\n",
|
1848
|
+
lua,
|
1849
|
+
&tree->stringPool[firstExpr->nameOffset],
|
1850
|
+
&tree->stringPool[secondExpr->nameOffset]) == -1) {
|
1851
|
+
return ERR_OUT_OF_MEMORY;
|
1852
|
+
}
|
1853
|
+
free(oldLua);
|
1854
|
+
}
|
1846
1855
|
}
|
1847
1856
|
|
1848
1857
|
free(unpackFrameLua);
|
@@ -1866,22 +1875,9 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1866
1875
|
"local events_message_cache = {}\n"
|
1867
1876
|
"local facts_mids_cache = {}\n"
|
1868
1877
|
"local events_mids_cache = {}\n"
|
1869
|
-
"local context_directory = {}\n"
|
1870
1878
|
"local input_keys = {}\n"
|
1871
|
-
"local
|
1872
|
-
"local expressions_count\n"
|
1879
|
+
"local function_tree = {}\n"
|
1873
1880
|
"local results\n"
|
1874
|
-
"local context\n"
|
1875
|
-
"local keys\n"
|
1876
|
-
"local reviewers\n"
|
1877
|
-
"local frame_packers\n"
|
1878
|
-
"local frame_unpackers\n"
|
1879
|
-
"local primary_message_keys\n"
|
1880
|
-
"local primary_frame_keys\n"
|
1881
|
-
"local directory\n"
|
1882
|
-
"local results_key\n"
|
1883
|
-
"local inverse_directory\n"
|
1884
|
-
"local key\n"
|
1885
1881
|
"local is_distinct_message = function(frame, message)\n"
|
1886
1882
|
" for name, frame_message in pairs(frame) do\n"
|
1887
1883
|
" if frame_message[\"id\"] == message[\"id\"] then\n"
|
@@ -1921,9 +1917,9 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1921
1917
|
" end\n"
|
1922
1918
|
" return false\n"
|
1923
1919
|
"end\n"
|
1924
|
-
"local cleanup_mids = function(index, frame, events_key, messages_key, mids_cache, message_cache)\n"
|
1920
|
+
"local cleanup_mids = function(index, frame, events_key, messages_key, mids_cache, message_cache, context)\n"
|
1925
1921
|
" local event_mids = mids_cache[events_key]\n"
|
1926
|
-
" local primary_key = primary_frame_keys[index](frame)\n"
|
1922
|
+
" local primary_key = context[\"primary_frame_keys\"][index](frame)\n"
|
1927
1923
|
" local new_mids = event_mids[primary_key]\n"
|
1928
1924
|
" local result_mids = {}\n"
|
1929
1925
|
" for i = 1, #new_mids, 1 do\n"
|
@@ -1938,9 +1934,9 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1938
1934
|
" redis.call(\"rpush\", events_key .. \"!m!\" .. primary_key, result_mids[i])\n"
|
1939
1935
|
" end\n"
|
1940
1936
|
"end\n"
|
1941
|
-
"local get_mids = function(index, frame, events_key, messages_key, mids_cache, message_cache)\n"
|
1937
|
+
"local get_mids = function(index, frame, events_key, messages_key, mids_cache, message_cache, context)\n"
|
1942
1938
|
" local event_mids = mids_cache[events_key]\n"
|
1943
|
-
" local primary_key = primary_frame_keys[index](frame)\n"
|
1939
|
+
" local primary_key = context[\"primary_frame_keys\"][index](frame)\n"
|
1944
1940
|
" local new_mids = nil\n"
|
1945
1941
|
" if not event_mids then\n"
|
1946
1942
|
" event_mids = {}\n"
|
@@ -1975,13 +1971,13 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
1975
1971
|
" end\n"
|
1976
1972
|
" return message\n"
|
1977
1973
|
"end\n"
|
1978
|
-
"local save_message = function(index, message, events_key, messages_key)\n"
|
1974
|
+
"local save_message = function(index, message, events_key, messages_key, context)\n"
|
1979
1975
|
" redis.call(\"hsetnx\", messages_key, message[\"id\"], cmsgpack.pack(message))\n"
|
1980
|
-
" local primary_key = primary_message_keys[index](message)\n"
|
1976
|
+
" local primary_key = context[\"primary_message_keys\"][index](message)\n"
|
1981
1977
|
" redis.call(\"lpush\", events_key .. \"!m!\" .. primary_key, message[\"id\"])\n"
|
1982
1978
|
"end\n"
|
1983
|
-
"local save_result = function(frame, index)\n"
|
1984
|
-
" table.insert(results, 1, frame_packers[index](frame, true))\n"
|
1979
|
+
"local save_result = function(frame, index, context)\n"
|
1980
|
+
" table.insert(results, 1, context[\"frame_packers\"][index](frame, true))\n"
|
1985
1981
|
" for name, message in pairs(frame) do\n"
|
1986
1982
|
" if message ~= \"$n\" and not message[\"$f\"] then\n"
|
1987
1983
|
" redis.call(\"hdel\", events_hashset, message[\"id\"])\n"
|
@@ -2001,31 +1997,31 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2001
1997
|
" return (message_count == index - 1)\n"
|
2002
1998
|
"end\n"
|
2003
1999
|
"local process_frame\n"
|
2004
|
-
"local process_event_and_frame = function(message, frame, index, use_facts)\n"
|
2000
|
+
"local process_event_and_frame = function(message, frame, index, use_facts, context)\n"
|
2005
2001
|
" local result = 0\n"
|
2006
2002
|
" local new_frame = {}\n"
|
2007
2003
|
" for name, new_message in pairs(frame) do\n"
|
2008
2004
|
" new_frame[name] = new_message\n"
|
2009
2005
|
" end\n"
|
2010
|
-
" if reviewers[index](message, new_frame, index) then\n"
|
2011
|
-
" if (index == expressions_count) then\n"
|
2012
|
-
" save_result(new_frame, index)\n"
|
2006
|
+
" if context[\"reviewers\"][index](message, new_frame, index) then\n"
|
2007
|
+
" if (index == context[\"expressions_count\"]) then\n"
|
2008
|
+
" save_result(new_frame, index, context)\n"
|
2013
2009
|
" return 1\n"
|
2014
2010
|
" else\n"
|
2015
|
-
" result = process_frame(new_frame, index + 1, use_facts)\n"
|
2011
|
+
" result = process_frame(new_frame, index + 1, use_facts, context)\n"
|
2016
2012
|
" if result == 0 or use_facts then\n"
|
2017
2013
|
" local frames_key\n"
|
2018
|
-
" local primary_key = primary_frame_keys[index + 1](new_frame)\n"
|
2019
|
-
" frames_key = keys[index + 1] .. \"!c!\" .. sid .. \"!\" .. primary_key\n"
|
2020
|
-
" redis.call(\"rpush\", frames_key, frame_packers[index](new_frame))\n"
|
2014
|
+
" local primary_key = context[\"primary_frame_keys\"][index + 1](new_frame)\n"
|
2015
|
+
" frames_key = context[\"keys\"][index + 1] .. \"!c!\" .. sid .. \"!\" .. primary_key\n"
|
2016
|
+
" redis.call(\"rpush\", frames_key, context[\"frame_packers\"][index](new_frame))\n"
|
2021
2017
|
" end\n"
|
2022
2018
|
" end\n"
|
2023
2019
|
" end\n"
|
2024
2020
|
" return result\n"
|
2025
2021
|
"end\n"
|
2026
|
-
"local process_frame_for_key = function(frame, index, events_key, use_facts)\n"
|
2022
|
+
"local process_frame_for_key = function(frame, index, events_key, use_facts, context)\n"
|
2027
2023
|
" local result = nil\n"
|
2028
|
-
" local inverse = inverse_directory[index]\n"
|
2024
|
+
" local inverse = context[\"inverse_directory\"][index]\n"
|
2029
2025
|
" local messages_key = events_hashset\n"
|
2030
2026
|
" local message_cache = events_message_cache\n"
|
2031
2027
|
" local mids_cache = events_mids_cache\n"
|
@@ -2040,26 +2036,26 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2040
2036
|
" for name, new_message in pairs(frame) do\n"
|
2041
2037
|
" new_frame[name] = new_message\n"
|
2042
2038
|
" end\n"
|
2043
|
-
" local new_mids = get_mids(index, frame, events_key, messages_key, mids_cache, message_cache)\n"
|
2039
|
+
" local new_mids = get_mids(index, frame, events_key, messages_key, mids_cache, message_cache, context)\n"
|
2044
2040
|
" for i = 1, #new_mids, 1 do\n"
|
2045
2041
|
" local message = get_message(new_mids[i], messages_key, message_cache)\n"
|
2046
2042
|
" if not message then\n"
|
2047
2043
|
" cleanup = true\n"
|
2048
|
-
" elseif not reviewers[index](message, new_frame, index) then\n"
|
2049
|
-
" local frames_key = keys[index] .. \"!i!\" .. sid .. \"!\" .. new_mids[i]\n"
|
2050
|
-
" redis.call(\"rpush\", frames_key, frame_packers[index - 1](new_frame))\n"
|
2044
|
+
" elseif not context[\"reviewers\"][index](message, new_frame, index) then\n"
|
2045
|
+
" local frames_key = context[\"keys\"][index] .. \"!i!\" .. sid .. \"!\" .. new_mids[i]\n"
|
2046
|
+
" redis.call(\"rpush\", frames_key, context[\"frame_packers\"][index - 1](new_frame))\n"
|
2051
2047
|
" result = 0\n"
|
2052
2048
|
" break\n"
|
2053
2049
|
" end\n"
|
2054
2050
|
" end\n"
|
2055
2051
|
" else\n"
|
2056
|
-
" local new_mids = get_mids(index, frame, events_key, messages_key, mids_cache, message_cache)\n"
|
2052
|
+
" local new_mids = get_mids(index, frame, events_key, messages_key, mids_cache, message_cache, context)\n"
|
2057
2053
|
" for i = 1, #new_mids, 1 do\n"
|
2058
2054
|
" local message = get_message(new_mids[i], messages_key, message_cache)\n"
|
2059
2055
|
" if not message then\n"
|
2060
2056
|
" cleanup = true\n"
|
2061
2057
|
" else\n"
|
2062
|
-
" local count = process_event_and_frame(message, frame, index, use_facts)\n"
|
2058
|
+
" local count = process_event_and_frame(message, frame, index, use_facts, context)\n"
|
2063
2059
|
" if not result then\n"
|
2064
2060
|
" result = 0\n"
|
2065
2061
|
" end\n"
|
@@ -2075,15 +2071,15 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2075
2071
|
" end\n"
|
2076
2072
|
" end\n"
|
2077
2073
|
" if cleanup then\n"
|
2078
|
-
" cleanup_mids(index, frame, events_key, messages_key, mids_cache, message_cache)\n"
|
2074
|
+
" cleanup_mids(index, frame, events_key, messages_key, mids_cache, message_cache, context)\n"
|
2079
2075
|
" end\n"
|
2080
2076
|
" return result\n"
|
2081
2077
|
"end\n"
|
2082
|
-
"process_frame = function(frame, index, use_facts)\n"
|
2083
|
-
" local first_result = process_frame_for_key(frame, index, keys[index] .. \"!e!\" .. sid, false)\n"
|
2084
|
-
" local second_result = process_frame_for_key(frame, index, keys[index] .. \"!f!\" .. sid, true)\n"
|
2078
|
+
"process_frame = function(frame, index, use_facts, context)\n"
|
2079
|
+
" local first_result = process_frame_for_key(frame, index, context[\"keys\"][index] .. \"!e!\" .. sid, false, context)\n"
|
2080
|
+
" local second_result = process_frame_for_key(frame, index, context[\"keys\"][index] .. \"!f!\" .. sid, true, context)\n"
|
2085
2081
|
" if not first_result and not second_result then\n"
|
2086
|
-
" return process_event_and_frame(nil, frame, index, use_facts)\n"
|
2082
|
+
" return process_event_and_frame(nil, frame, index, use_facts, context)\n"
|
2087
2083
|
" elseif not first_result then\n"
|
2088
2084
|
" return second_result\n"
|
2089
2085
|
" elseif not second_result then\n"
|
@@ -2092,7 +2088,7 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2092
2088
|
" return first_result + second_result\n"
|
2093
2089
|
" end\n"
|
2094
2090
|
"end\n"
|
2095
|
-
"local process_inverse_event = function(message, index, events_key, use_facts)\n"
|
2091
|
+
"local process_inverse_event = function(message, index, events_key, use_facts, context)\n"
|
2096
2092
|
" local result = 0\n"
|
2097
2093
|
" local messages_key = events_hashset\n"
|
2098
2094
|
" if use_facts then\n"
|
@@ -2100,42 +2096,42 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2100
2096
|
" end\n"
|
2101
2097
|
" redis.call(\"hdel\", messages_key, mid)\n"
|
2102
2098
|
" if index == 1 then\n"
|
2103
|
-
" result = process_frame({}, 1, use_facts)\n"
|
2099
|
+
" result = process_frame({}, 1, use_facts, context)\n"
|
2104
2100
|
" else\n"
|
2105
|
-
" local frames_key = keys[index] .. \"!i!\" .. sid .. \"!\" .. mid\n"
|
2101
|
+
" local frames_key = context[\"keys\"][index] .. \"!i!\" .. sid .. \"!\" .. mid\n"
|
2106
2102
|
" local packed_frames_len = redis.call(\"llen\", frames_key)\n"
|
2107
2103
|
" for i = 1, packed_frames_len, 1 do\n"
|
2108
2104
|
" local packed_frame = redis.call(\"rpop\", frames_key)\n"
|
2109
|
-
" local frame = frame_unpackers[index - 1](packed_frame)\n"
|
2105
|
+
" local frame = context[\"frame_unpackers\"][index - 1](packed_frame)\n"
|
2110
2106
|
" if frame then\n"
|
2111
|
-
" result = result + process_frame(frame, index, use_facts)\n"
|
2107
|
+
" result = result + process_frame(frame, index, use_facts, context)\n"
|
2112
2108
|
" end\n"
|
2113
2109
|
" end\n"
|
2114
2110
|
" end\n"
|
2115
2111
|
" return result\n"
|
2116
2112
|
"end\n"
|
2117
|
-
"local process_event = function(message, index, events_key, use_facts)\n"
|
2113
|
+
"local process_event = function(message, index, events_key, use_facts, context)\n"
|
2118
2114
|
" local result = 0\n"
|
2119
2115
|
" local messages_key = events_hashset\n"
|
2120
2116
|
" if use_facts then\n"
|
2121
2117
|
" messages_key = facts_hashset\n"
|
2122
2118
|
" end\n"
|
2123
2119
|
" if index == 1 then\n"
|
2124
|
-
" result = process_event_and_frame(message, {}, 1, use_facts)\n"
|
2120
|
+
" result = process_event_and_frame(message, {}, 1, use_facts, context)\n"
|
2125
2121
|
" else\n"
|
2126
2122
|
" local frames_key\n"
|
2127
|
-
" local primary_key = primary_message_keys[index](message)\n"
|
2123
|
+
" local primary_key = context[\"primary_message_keys\"][index](message)\n"
|
2128
2124
|
" if primary_key then\n"
|
2129
|
-
" frames_key = keys[index] .. \"!c!\" .. sid .. \"!\" .. primary_key\n"
|
2125
|
+
" frames_key = context[\"keys\"][index] .. \"!c!\" .. sid .. \"!\" .. primary_key\n"
|
2130
2126
|
" else\n"
|
2131
|
-
" frames_key = keys[index] .. \"!c!\" .. sid\n"
|
2127
|
+
" frames_key = context[\"keys\"][index] .. \"!c!\" .. sid\n"
|
2132
2128
|
" end\n"
|
2133
2129
|
" local packed_frames_len = redis.call(\"llen\", frames_key)\n"
|
2134
2130
|
" for i = 1, packed_frames_len, 1 do\n"
|
2135
2131
|
" local packed_frame = redis.call(\"rpop\", frames_key)\n"
|
2136
|
-
" local frame = frame_unpackers[index - 1](packed_frame)\n"
|
2132
|
+
" local frame = context[\"frame_unpackers\"][index - 1](packed_frame)\n"
|
2137
2133
|
" if frame then\n"
|
2138
|
-
" local count = process_event_and_frame(message, frame, index, use_facts)\n"
|
2134
|
+
" local count = process_event_and_frame(message, frame, index, use_facts, context)\n"
|
2139
2135
|
" result = result + count\n"
|
2140
2136
|
" if count == 0 or use_facts then\n"
|
2141
2137
|
" redis.call(\"lpush\", frames_key, packed_frame)\n"
|
@@ -2146,44 +2142,44 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2146
2142
|
" end\n"
|
2147
2143
|
" end\n"
|
2148
2144
|
" if result == 0 or use_facts then\n"
|
2149
|
-
" save_message(index, message, events_key, messages_key)\n"
|
2145
|
+
" save_message(index, message, events_key, messages_key, context)\n"
|
2150
2146
|
" end\n"
|
2151
2147
|
" return result\n"
|
2152
2148
|
"end\n"
|
2153
|
-
"local process_key_with_cap = function(message, cap)\n"
|
2154
|
-
" local index = directory[key]\n"
|
2149
|
+
"local process_key_with_cap = function(message, cap, key, context)\n"
|
2150
|
+
" local index = context[\"directory\"][key]\n"
|
2155
2151
|
" local result_recorded = false\n"
|
2156
2152
|
" if index then\n"
|
2157
2153
|
" local count = 0\n"
|
2158
2154
|
" if not message then\n"
|
2159
2155
|
" if assert_fact == 0 then\n"
|
2160
|
-
" count = process_inverse_event(message, index, keys[index] .. \"!e!\" .. sid, false)\n"
|
2156
|
+
" count = process_inverse_event(message, index, context[\"keys\"][index] .. \"!e!\" .. sid, false, context)\n"
|
2161
2157
|
" else\n"
|
2162
|
-
" count = process_inverse_event(message, index, keys[index] .. \"!f!\" .. sid, true)\n"
|
2158
|
+
" count = process_inverse_event(message, index, context[\"keys\"][index] .. \"!f!\" .. sid, true, context)\n"
|
2163
2159
|
" end\n"
|
2164
2160
|
" else\n"
|
2165
2161
|
" if assert_fact == 0 then\n"
|
2166
|
-
" count = process_event(message, index, keys[index] .. \"!e!\" .. sid, false)\n"
|
2162
|
+
" count = process_event(message, index, context[\"keys\"][index] .. \"!e!\" .. sid, false, context)\n"
|
2167
2163
|
" else\n"
|
2168
|
-
" count = process_event(message, index, keys[index] .. \"!f!\" .. sid, true)\n"
|
2164
|
+
" count = process_event(message, index, context[\"keys\"][index] .. \"!f!\" .. sid, true, context)\n"
|
2169
2165
|
" end\n"
|
2170
2166
|
" end\n"
|
2171
2167
|
" if (count > 0) then\n"
|
2172
2168
|
" result_recorded = true\n"
|
2173
2169
|
" for i = #results, 1, -1 do\n"
|
2174
|
-
" redis.call(\"lpush\", results_key, results[i])\n"
|
2170
|
+
" redis.call(\"lpush\", context[\"results_key\"], results[i])\n"
|
2175
2171
|
" end\n"
|
2176
2172
|
" local diff\n"
|
2177
2173
|
" local new_count, new_remain = math.modf(#results / cap)\n"
|
2178
2174
|
" local new_remain = #results %% cap\n"
|
2179
2175
|
" if new_count > 0 then\n"
|
2180
2176
|
" for i = 1, new_count, 1 do\n"
|
2181
|
-
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, results_key)\n"
|
2177
|
+
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, context[\"results_key\"])\n"
|
2182
2178
|
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, \"$c\" .. cap)\n"
|
2183
2179
|
" end\n"
|
2184
2180
|
" end\n"
|
2185
2181
|
" if new_remain > 0 then\n"
|
2186
|
-
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, results_key)\n"
|
2182
|
+
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, context[\"results_key\"])\n"
|
2187
2183
|
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, \"$c\" .. new_remain)\n"
|
2188
2184
|
" end\n"
|
2189
2185
|
" if new_remain > 0 or new_count > 0 then\n"
|
@@ -2195,37 +2191,37 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2195
2191
|
" end\n"
|
2196
2192
|
" return result_recorded\n"
|
2197
2193
|
"end\n"
|
2198
|
-
"local process_key_with_window = function(message, window)\n"
|
2199
|
-
" local index = directory[key]\n"
|
2194
|
+
"local process_key_with_window = function(message, window, key, context)\n"
|
2195
|
+
" local index = context[\"directory\"][key]\n"
|
2200
2196
|
" local result_recorded = false\n"
|
2201
2197
|
" if index then\n"
|
2202
2198
|
" local count = 0\n"
|
2203
2199
|
" if not message then\n"
|
2204
2200
|
" if assert_fact == 0 then\n"
|
2205
|
-
" count = process_inverse_event(message, index, keys[index] .. \"!e!\" .. sid, false)\n"
|
2201
|
+
" count = process_inverse_event(message, index, context[\"keys\"][index] .. \"!e!\" .. sid, false, context)\n"
|
2206
2202
|
" else\n"
|
2207
|
-
" count = process_inverse_event(message, index, keys[index] .. \"!f!\" .. sid, true)\n"
|
2203
|
+
" count = process_inverse_event(message, index, context[\"keys\"][index] .. \"!f!\" .. sid, true, context)\n"
|
2208
2204
|
" end\n"
|
2209
2205
|
" else\n"
|
2210
2206
|
" if assert_fact == 0 then\n"
|
2211
|
-
" count = process_event(message, index, keys[index] .. \"!e!\" .. sid, false)\n"
|
2207
|
+
" count = process_event(message, index, context[\"keys\"][index] .. \"!e!\" .. sid, false, context)\n"
|
2212
2208
|
" else\n"
|
2213
|
-
" count = process_event(message, index, keys[index] .. \"!f!\" .. sid, true)\n"
|
2209
|
+
" count = process_event(message, index, context[\"keys\"][index] .. \"!f!\" .. sid, true, context)\n"
|
2214
2210
|
" end\n"
|
2215
2211
|
" end\n"
|
2216
2212
|
" if (count > 0) then\n"
|
2217
2213
|
" result_recorded = true\n"
|
2218
2214
|
" for i = #results, 1, -1 do\n"
|
2219
|
-
" redis.call(\"lpush\", results_key, results[i])\n"
|
2215
|
+
" redis.call(\"lpush\", context[\"results_key\"], results[i])\n"
|
2220
2216
|
" end\n"
|
2221
2217
|
" local diff\n"
|
2222
|
-
" local length = redis.call(\"llen\", results_key)\n"
|
2218
|
+
" local length = redis.call(\"llen\", context[\"results_key\"])\n"
|
2223
2219
|
" local prev_count, prev_remain = math.modf((length - count) / window)\n"
|
2224
2220
|
" local new_count, prev_remain = math.modf(length / window)\n"
|
2225
2221
|
" diff = new_count - prev_count\n"
|
2226
2222
|
" if diff > 0 then\n"
|
2227
2223
|
" for i = 0, diff - 1, 1 do\n"
|
2228
|
-
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, results_key)\n"
|
2224
|
+
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, context[\"results_key\"])\n"
|
2229
2225
|
" redis.call(\"rpush\", actions_key .. \"!\" .. sid, \"$w\" .. window)\n"
|
2230
2226
|
" end\n"
|
2231
2227
|
" if not redis.call(\"zscore\", actions_key, sid) then\n"
|
@@ -2236,52 +2232,27 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2236
2232
|
" end\n"
|
2237
2233
|
" return result_recorded\n"
|
2238
2234
|
"end\n"
|
2239
|
-
"local process_message = function(message)\n"
|
2240
|
-
"
|
2241
|
-
"
|
2242
|
-
"
|
2243
|
-
"
|
2244
|
-
"
|
2245
|
-
"
|
2246
|
-
" reviewers = context[\"reviewers\"]\n"
|
2247
|
-
" frame_packers = context[\"frame_packers\"]\n"
|
2248
|
-
" frame_unpackers = context[\"frame_unpackers\"]\n"
|
2249
|
-
" primary_message_keys = context[\"primary_message_keys\"]\n"
|
2250
|
-
" primary_frame_keys = context[\"primary_frame_keys\"]\n"
|
2251
|
-
" directory = context[\"directory\"]\n"
|
2252
|
-
" results_key = context[\"results_key\"]\n"
|
2253
|
-
" inverse_directory = context[\"inverse_directory\"]\n"
|
2254
|
-
" expressions_count = context[\"expressions_count\"]\n"
|
2255
|
-
" local process_key = context[\"process_key\"]\n"
|
2256
|
-
" local process_key_count = context[\"process_key_count\"]\n"
|
2257
|
-
" local result_recorded = process_key(message, process_key_count)\n"
|
2258
|
-
" if assert_fact == 0 and result_recorded then\n"
|
2259
|
-
" return false\n"
|
2260
|
-
" end\n"
|
2261
|
-
" end\n"
|
2235
|
+
"local process_message = function(message, key, context)\n"
|
2236
|
+
" results = {}\n"
|
2237
|
+
" local process_key = context[\"process_key\"]\n"
|
2238
|
+
" local process_key_count = context[\"process_key_count\"]\n"
|
2239
|
+
" local result_recorded = process_key(message, process_key_count, key, context)\n"
|
2240
|
+
" if assert_fact == 0 and result_recorded then\n"
|
2241
|
+
" return false\n"
|
2262
2242
|
" end\n"
|
2263
2243
|
" return true\n"
|
2264
2244
|
"end\n"
|
2265
|
-
"local
|
2266
|
-
"
|
2267
|
-
"
|
2268
|
-
" context = {}\n"
|
2269
|
-
"
|
2270
|
-
" context[\"
|
2271
|
-
"
|
2272
|
-
" context[\"
|
2273
|
-
"
|
2274
|
-
" context[\"
|
2275
|
-
"
|
2276
|
-
" context[\"primary_message_keys\"] = primary_message_keys\n"
|
2277
|
-
" primary_frame_keys = {}\n"
|
2278
|
-
" context[\"primary_frame_keys\"] = primary_frame_keys\n"
|
2279
|
-
" keys = {}\n"
|
2280
|
-
" context[\"keys\"] = keys\n"
|
2281
|
-
" inverse_directory = {}\n"
|
2282
|
-
" context[\"inverse_directory\"] = inverse_directory\n"
|
2283
|
-
" directory = {[\"0\"] = 1}\n"
|
2284
|
-
" context[\"directory\"] = directory\n"
|
2245
|
+
"local create_context = function()\n"
|
2246
|
+
" local context = {}\n"
|
2247
|
+
" context[\"reviewers\"] = {}\n"
|
2248
|
+
" context[\"frame_packers\"] = {}\n"
|
2249
|
+
" context[\"frame_unpackers\"] = {}\n"
|
2250
|
+
" context[\"primary_message_keys\"] = {}\n"
|
2251
|
+
" context[\"primary_frame_keys\"] = {}\n"
|
2252
|
+
" context[\"keys\"] = {}\n"
|
2253
|
+
" context[\"inverse_directory\"] = {}\n"
|
2254
|
+
" context[\"directory\"] = {[\"0\"] = 1}\n"
|
2255
|
+
" return context\n"
|
2285
2256
|
"end\n"
|
2286
2257
|
"local message = nil\n"
|
2287
2258
|
"if #ARGV > (6 + keys_count) then\n"
|
@@ -2326,8 +2297,12 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2326
2297
|
"for index = 6, 5 + keys_count, 1 do\n"
|
2327
2298
|
" input_keys[ARGV[index]] = true\n"
|
2328
2299
|
"end\n"
|
2329
|
-
"
|
2330
|
-
"
|
2300
|
+
"%s"
|
2301
|
+
"for index = 6, 5 + keys_count, 1 do\n"
|
2302
|
+
" if function_tree[ARGV[index]](ARGV[index], nil) == false then\n"
|
2303
|
+
" return\n"
|
2304
|
+
" end\n"
|
2305
|
+
"end\n",
|
2331
2306
|
name,
|
2332
2307
|
name,
|
2333
2308
|
name,
|
@@ -2340,6 +2315,7 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
|
|
2340
2315
|
return ERR_OUT_OF_MEMORY;
|
2341
2316
|
}
|
2342
2317
|
|
2318
|
+
//printf("%s\n", lua);
|
2343
2319
|
free(oldLua);
|
2344
2320
|
unsigned int result = redisAppendCommand(reContext, "SCRIPT LOAD %s", lua);
|
2345
2321
|
GET_REPLY(result, "loadEvalMessageCommand", reply);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: durable_rules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.34.
|
4
|
+
version: 0.34.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesus Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|