Browse code

htable: docs for iterator sets and seti functions

Daniel-Constantin Mierla authored on 12/10/2021 20:19:37
Showing 1 changed files
... ...
@@ -1116,6 +1116,56 @@ sht_iterator_end("i1");
1116 1116
     }
1117 1117
     sht_iterator_end("i1");
1118 1118
 ...
1119
+</programlisting>
1120
+		</example>
1121
+	</section>
1122
+	<section id="htable.f.sht_iterator_sets">
1123
+		<title>
1124
+		<function moreinfo="none">sht_iterator_sets(iname, sval)</function>
1125
+		</title>
1126
+		<para>
1127
+			Set the value of the current item to the string in the sval.
1128
+		</para>
1129
+		<para>
1130
+			The parameters can be dynamic strings with variables.
1131
+		</para>
1132
+		<para>
1133
+			This function can be used from ANY_ROUTE.
1134
+		</para>
1135
+		<example>
1136
+		<title><function>sht_iterator_sets</function> usage</title>
1137
+		<programlisting format="linespecific">
1138
+...
1139
+    sht_iterator_start("i1", "h1");
1140
+    sht_iterator_next("i1");
1141
+    sht_iterator_sets("i1", "$ci");
1142
+    sht_iterator_end("i1");
1143
+...
1144
+</programlisting>
1145
+		</example>
1146
+	</section>
1147
+	<section id="htable.f.sht_iterator_seti">
1148
+		<title>
1149
+		<function moreinfo="none">sht_iterator_seti(iname, ival)</function>
1150
+		</title>
1151
+		<para>
1152
+			Set the value of the current item to the integer in the ival.
1153
+		</para>
1154
+		<para>
1155
+			The parameters can be dynamic strings or integers with variables.
1156
+		</para>
1157
+		<para>
1158
+			This function can be used from ANY_ROUTE.
1159
+		</para>
1160
+		<example>
1161
+		<title><function>sht_iterator_seti</function> usage</title>
1162
+		<programlisting format="linespecific">
1163
+...
1164
+    sht_iterator_start("i1", "h1");
1165
+    sht_iterator_next("i1");
1166
+    sht_iterator_seti("i1", "20");
1167
+    sht_iterator_end("i1");
1168
+...
1119 1169
 </programlisting>
1120 1170
 		</example>
1121 1171
 	</section>
Browse code

htable: added iterator function to remove current item

Daniel-Constantin Mierla authored on 08/10/2021 07:47:06
Showing 1 changed files
... ...
@@ -1081,6 +1081,41 @@ sht_iterator_end("i1");
1081 1081
     }
1082 1082
     sht_iterator_end("i1");
1083 1083
 ...
1084
+</programlisting>
1085
+		</example>
1086
+	</section>
1087
+	<section id="htable.f.sht_iterator_rm">
1088
+		<title>
1089
+		<function moreinfo="none">sht_iterator_rm(iname)</function>
1090
+		</title>
1091
+		<para>
1092
+			Remove the current item in the iterator and move the iterator to
1093
+			the next one.
1094
+		</para>
1095
+		<para>
1096
+			The return code is 1 (true) if the item was removed and next item
1097
+			exists; -2 (false) if the item was removed and there is no next item
1098
+			(end of items); other negative value (false) can be returned on
1099
+			error (e.g., iterator or item not found).
1100
+		</para>
1101
+		<para>
1102
+			The parameter can be dynamic string with variables.
1103
+		</para>
1104
+		<para>
1105
+			This function can be used from ANY_ROUTE.
1106
+		</para>
1107
+		<example>
1108
+		<title><function>sht_iterator_rm</function> usage</title>
1109
+		<programlisting format="linespecific">
1110
+...
1111
+    sht_iterator_start("i1", "h1");
1112
+    while(sht_iterator_next("i1")) {
1113
+        while($shtitkey(i1) =~ "xyz" and sht_iterator_rm("i1")) {
1114
+            xdbg("item removed\n");
1115
+        }
1116
+    }
1117
+    sht_iterator_end("i1");
1118
+...
1084 1119
 </programlisting>
1085 1120
 		</example>
1086 1121
 	</section>
Browse code

htable: fix documentation - reported by arkadiam on Github

Ovidiu Sas authored on 15/06/2021 17:03:07
Showing 1 changed files
... ...
@@ -1363,7 +1363,7 @@ kamcmd htable.sets test x[0] abc
1363 1363
 kamcmd htable.seti test x 123
1364 1364
 
1365 1365
 # Set first entry in array key x $sht(test=>x[0]) as integer
1366
-kamcmd htable.sets test x[0] 123
1366
+kamcmd htable.seti test x[0] 123
1367 1367
 ...
1368 1368
 </programlisting>
1369 1369
 	</section>
Browse code

htable: docs - not about use of event_route[htable:mod-init]

Daniel-Constantin Mierla authored on 11/02/2021 16:32:45
Showing 1 changed files
... ...
@@ -1528,6 +1528,18 @@ kamcmd htable.stats
1528 1528
 			once, after core and module initialization, but before &kamailio; forks any
1529 1529
 			child processes.
1530 1530
 		</para>
1531
+		<para>
1532
+			Note: do not expect to use functions from all other modules here,
1533
+			even if they are loaded before the htable module, because many of
1534
+			them initialize their runtime structures inside child init callbacks,
1535
+			which are executed after this moment, when forking child processes.
1536
+			For example, sqlops cannot be used, connections to database are
1537
+			initialized in child init. Even more, it is recommended not to use
1538
+			functions from other modules, because it can mess up what they
1539
+			created in mod init callback and expect in child init callback. It
1540
+			should be ok to use functions from htable module or assignment
1541
+			operations.
1542
+		</para>
1531 1543
 <programlisting  format="linespecific">
1532 1544
 ...
1533 1545
 event_route[htable:mod-init] {
Browse code

htable: docs - more details about size attribute for htable

Daniel-Constantin Mierla authored on 01/05/2020 15:26:39
Showing 1 changed files
... ...
@@ -341,11 +341,17 @@ $ kamcmd htable.dump htable
341 341
 		</listitem>
342 342
 		<listitem>
343 343
 		<para>
344
-			<emphasis>size</emphasis> - number specifying the size of hash
345
-			table.  Larger value means less collisions. The number of entries
346
-			(aka slots or buckets) in the table is 2^size. The possible range
344
+			<emphasis>size</emphasis> - number to control how many slots
345
+			(buckets) to create for the hash table. Larger value means more
346
+			slots with higher probability for less collisions. The actual number
347
+			slots (or buckets) created for the table is 2^size. The possible range
347 348
 			for this value is from 2 to 31, smaller or larger values will be
348
-			increased to 3 (8 slots) or decreased to 14 (16384 slots).
349
+			increased to 3 (8 slots) or decreased to 14 (16384 slots). Note
350
+			that each slot can store more than one item, when there are
351
+			collisions of hash ids computed for keys. The items in the same
352
+			slot are stored in a linked list. In other words, the size is not
353
+			setting a limit of how many items can be stored in a hash table, as
354
+			long as there is enough free shared memory, new items can be added.
349 355
 		</para>
350 356
 		</listitem>
351 357
 		<listitem>
Browse code

htable: docs for rpc command htable.store

Daniel-Constantin Mierla authored on 25/03/2020 18:36:37
Showing 1 changed files
... ...
@@ -1253,7 +1253,6 @@ if(sht_match_str_value("ha", "eq", "alice")) {
1253 1253
                         </listitem>
1254 1254
                         <listitem><para>key : Key name of the hash table value to dump</para>
1255 1255
                         </listitem>
1256
-
1257 1256
                 </itemizedlist>
1258 1257
                 <para>
1259 1258
                 Example:
... ...
@@ -1284,7 +1283,6 @@ kamcmd htable.get students course[0]
1284 1283
                         </listitem>
1285 1284
                         <listitem><para>key : Key name of the hash table value to delete</para>
1286 1285
                         </listitem>
1287
-
1288 1286
                 </itemizedlist>
1289 1287
                 <para>
1290 1288
                 Example:
... ...
@@ -1317,7 +1315,6 @@ kamcmd htable.delete students course[0]
1317 1315
                         </listitem>
1318 1316
                         <listitem><para>Value : String value for the item</para>
1319 1317
                         </listitem>
1320
-
1321 1318
                 </itemizedlist>
1322 1319
                 <para>
1323 1320
                 Example:
... ...
@@ -1350,7 +1347,6 @@ kamcmd htable.sets test x[0] abc
1350 1347
                         </listitem>
1351 1348
                         <listitem><para>Value : Integer value for the item</para>
1352 1349
                         </listitem>
1353
-
1354 1350
                 </itemizedlist>
1355 1351
                 <para>
1356 1352
                 Example:
... ...
@@ -1373,13 +1369,12 @@ kamcmd htable.sets test x[0] 123
1373 1369
 		Lists all the values in a hash table
1374 1370
                 </para>
1375 1371
                 <para>
1376
-                Name: <emphasis>dhtable.dump</emphasis>
1372
+                Name: <emphasis>htable.dump</emphasis>
1377 1373
                 </para>
1378 1374
                 <para>Parameters:</para>
1379 1375
                 <itemizedlist>
1380 1376
                         <listitem><para>htable : Name of the hash table to dump</para>
1381 1377
                         </listitem>
1382
-
1383 1378
                 </itemizedlist>
1384 1379
                 <para>
1385 1380
                 Example:
... ...
@@ -1395,16 +1390,15 @@ kamcmd htable.dump ipban
1395 1390
                 <function moreinfo="none">htable.reload htable</function>
1396 1391
                 </title>
1397 1392
                 <para>
1398
-		Reload hash table from database.
1393
+                Reload hash table from database.
1399 1394
                 </para>
1400 1395
                 <para>
1401
-                Name: <emphasis>dhtable.reload</emphasis>
1396
+                Name: <emphasis>htable.reload</emphasis>
1402 1397
                 </para>
1403 1398
                 <para>Parameters:</para>
1404 1399
                 <itemizedlist>
1405 1400
                         <listitem><para>htable : Name of the hash table to reload</para>
1406 1401
                         </listitem>
1407
-
1408 1402
                 </itemizedlist>
1409 1403
                 <para>
1410 1404
                 Example:
... ...
@@ -1413,6 +1407,30 @@ kamcmd htable.dump ipban
1413 1407
 ...
1414 1408
 kamcmd htable.reload ipban
1415 1409
 ...
1410
+</programlisting>
1411
+	</section>
1412
+        <section id="htable.rpc.store">
1413
+                <title>
1414
+                <function moreinfo="none">htable.store htable</function>
1415
+                </title>
1416
+                <para>
1417
+                Store hash table to database.
1418
+                </para>
1419
+                <para>
1420
+                Name: <emphasis>htable.store</emphasis>
1421
+                </para>
1422
+                <para>Parameters:</para>
1423
+                <itemizedlist>
1424
+                        <listitem><para>htable : Name of the hash table to store</para>
1425
+                        </listitem>
1426
+                </itemizedlist>
1427
+                <para>
1428
+                Example:
1429
+                </para>
1430
+<programlisting  format="linespecific">
1431
+...
1432
+kamcmd htable.store ipban
1433
+...
1416 1434
 </programlisting>
1417 1435
 	</section>
1418 1436
 	<section id="htable.rpc.flush">
... ...
@@ -1452,7 +1470,6 @@ kamcmd htable.flush ipban
1452 1470
                 <itemizedlist>
1453 1471
                         <listitem><para>None</para>
1454 1472
                         </listitem>
1455
-
1456 1473
                 </itemizedlist>
1457 1474
                 <para>
1458 1475
                 Example:
... ...
@@ -1479,7 +1496,6 @@ kamcmd htable.listTables
1479 1496
                 <itemizedlist>
1480 1497
                         <listitem><para>None</para>
1481 1498
                         </listitem>
1482
-
1483 1499
                 </itemizedlist>
1484 1500
                 <para>
1485 1501
                 Example:
Browse code

htable: docs fix parameter name

Bastian Triller authored on 14/03/2020 17:15:32 • Henning Westerholt committed on 14/03/2020 20:17:04
Showing 1 changed files
... ...
@@ -414,7 +414,7 @@ $ kamcmd htable.dump htable
414 414
 		</emphasis>
415 415
 		</para>
416 416
 		<example>
417
-		<title>Set <varname>hash_size</varname> parameter</title>
417
+		<title>Set <varname>htable</varname> parameter</title>
418 418
 		<programlisting format="linespecific">
419 419
 ...
420 420
 modparam("htable", "htable", "a=&gt;size=4;autoexpire=7200;dbtable=htable_a;")
Browse code

htable: docs updated with sth_has_name() and sht_has_str_value()

Daniel-Constantin Mierla authored on 08/08/2019 14:35:52
Showing 1 changed files
... ...
@@ -1132,6 +1132,14 @@ if(sht_match_name("ha", "eq", "alice")) {
1132 1132
 </programlisting>
1133 1133
 		</example>
1134 1134
 	</section>
1135
+	<section id="htable.f.sht_has_name">
1136
+		<title>
1137
+		<function moreinfo="none">sht_has_name(htable, op, mval)</function>
1138
+		</title>
1139
+		<para>
1140
+			Alias for sht_match_name().
1141
+		</para>
1142
+	</section>
1135 1143
 	<section id="htable.f.sht_match_str_value">
1136 1144
 		<title>
1137 1145
 		<function moreinfo="none">sht_match_str_value(htable, op, mval)</function>
... ...
@@ -1186,6 +1194,14 @@ if(sht_match_str_value("ha", "eq", "alice")) {
1186 1194
 </programlisting>
1187 1195
 		</example>
1188 1196
 	</section>
1197
+	<section id="htable.f.sht_has_str_value">
1198
+		<title>
1199
+		<function moreinfo="none">sht_has_str_value(htable, op, mval)</function>
1200
+		</title>
1201
+		<para>
1202
+			Alias for sht_match_str_value().
1203
+		</para>
1204
+	</section>
1189 1205
 	</section>
1190 1206
 		<section>
1191 1207
 		<title>Exported pseudo-variables</title>
Browse code

htable: docs - updates to new function names for matching items

Daniel-Constantin Mierla authored on 31/07/2019 10:40:45
Showing 1 changed files
... ...
@@ -1078,9 +1078,9 @@ sht_iterator_end("i1");
1078 1078
 </programlisting>
1079 1079
 		</example>
1080 1080
 	</section>
1081
-	<section id="htable.f.sht_has_name">
1081
+	<section id="htable.f.sht_match_name">
1082 1082
 		<title>
1083
-		<function moreinfo="none">sht_has_name(htable, op, mval)</function>
1083
+		<function moreinfo="none">sht_match_name(htable, op, mval)</function>
1084 1084
 		</title>
1085 1085
 		<para>
1086 1086
 			Return greater than 0 (true) if the htable has an item that matches
... ...
@@ -1122,19 +1122,19 @@ sht_iterator_end("i1");
1122 1122
 			This function can be used from ANY_ROUTE.
1123 1123
 		</para>
1124 1124
 		<example>
1125
-		<title><function>sht_has_name</function> usage</title>
1125
+		<title><function>sht_match_name</function> usage</title>
1126 1126
 		<programlisting format="linespecific">
1127 1127
 ...
1128
-if(sht_has_name("ha", "eq", "alice")) {
1128
+if(sht_match_name("ha", "eq", "alice")) {
1129 1129
   ...
1130 1130
 }
1131 1131
 ...
1132 1132
 </programlisting>
1133 1133
 		</example>
1134 1134
 	</section>
1135
-	<section id="htable.f.sht_has_str_value">
1135
+	<section id="htable.f.sht_match_str_value">
1136 1136
 		<title>
1137
-		<function moreinfo="none">sht_has_str_value(htable, op, mval)</function>
1137
+		<function moreinfo="none">sht_match_str_value(htable, op, mval)</function>
1138 1138
 		</title>
1139 1139
 		<para>
1140 1140
 			Return greater than 0 (true) if the htable has an item that matches
... ...
@@ -1176,10 +1176,10 @@ if(sht_has_name("ha", "eq", "alice")) {
1176 1176
 			This function can be used from ANY_ROUTE.
1177 1177
 		</para>
1178 1178
 		<example>
1179
-		<title><function>sht_has_name</function> usage</title>
1179
+		<title><function>sht_match_name</function> usage</title>
1180 1180
 		<programlisting format="linespecific">
1181 1181
 ...
1182
-if(sht_has_str_value("ha", "eq", "alice")) {
1182
+if(sht_match_str_value("ha", "eq", "alice")) {
1183 1183
   ...
1184 1184
 }
1185 1185
 ...
Browse code

htable: docs - rephrased info for db_expires to clarify its purpose

Daniel-Constantin Mierla authored on 28/06/2019 12:53:02
Showing 1 changed files
... ...
@@ -600,9 +600,16 @@ modparam("htable", "timer_interval", 10)
600 600
 	<section id="htable.p.db_expires">
601 601
 		<title><varname>db_expires</varname> (integer)</title>
602 602
 		<para>
603
-			If set to 1, the module will load/save the expires values of the items in
604
-			hash table from/to database. It applies only to hash tables that
605
-			have the auto-expires attribute defined.
603
+			If set to 1, the module loads/saves the value for expire of
604
+			the items in hash table from/to database. It applies only to hash
605
+			tables that have the auto-expires attribute defined. If set to 0,
606
+			only the key name and the value are loaded, the expires for each
607
+			item being set to 0.
608
+		</para>
609
+		<para>
610
+			Note that the module is not reloading automatically the items from
611
+			database when they expire, the reloading can be done only via RPC
612
+			command.
606 613
 		</para>
607 614
 		<para>
608 615
 		<emphasis>
Browse code

htable: Add RPC htable.flush <htable>

Empties the entire specified hash table

Alex Hermann authored on 31/01/2019 12:56:53
Showing 1 changed files
... ...
@@ -1390,6 +1390,29 @@ kamcmd htable.dump ipban
1390 1390
 ...
1391 1391
 kamcmd htable.reload ipban
1392 1392
 ...
1393
+</programlisting>
1394
+	</section>
1395
+	<section id="htable.rpc.flush">
1396
+          <title>
1397
+                <function moreinfo="none">htable.flush htable</function>
1398
+          </title>
1399
+          <para>
1400
+            Empty the hash table
1401
+          </para>
1402
+          <para>
1403
+            Name: <emphasis>htable.flush</emphasis>
1404
+          </para>
1405
+          <para>Parameters:</para>
1406
+          <itemizedlist>
1407
+            <listitem><para>htable : Name of the hash table to flush</para></listitem>
1408
+          </itemizedlist>
1409
+          <para>
1410
+          Example:
1411
+          </para>
1412
+<programlisting  format="linespecific">
1413
+...
1414
+kamcmd htable.flush ipban
1415
+...
1393 1416
 </programlisting>
1394 1417
 	</section>
1395 1418
         <section id="htable.rpc.listTables">
Browse code

htable: added startup synchronization over dmq

Charles Chance authored on 28/09/2018 17:09:28
Showing 1 changed files
... ...
@@ -647,6 +647,28 @@ modparam("htable", "db_expires", 1)
647 647
 ...
648 648
 modparam("htable", "enable_dmq", 1)
649 649
 ...
650
+</programlisting>
651
+		</example>
652
+	</section>
653
+	<section id="htable.p.dmq_init_sync">
654
+		<title><varname>dmq_init_sync</varname> (integer)</title>
655
+		<para>
656
+			If set to 1, will request synchronization from other nodes at startup. It applies
657
+			to all tables having the "dmqreplicate" parameter set. As above, it is important to 
658
+			ensure the definition (size, autoexpire etc.) of replicated tables is identical 
659
+			across all instances.
660
+		</para>
661
+		<para>
662
+		<emphasis>
663
+			Default value is 0.
664
+		</emphasis>
665
+		</para>
666
+		<example>
667
+		<title>Set <varname>dmq_init_sync</varname> parameter</title>
668
+		<programlisting format="linespecific">
669
+...
670
+modparam("htable", "dmq_init_sync", 1)
671
+...
650 672
 </programlisting>
651 673
 		</example>
652 674
 	</section>
Browse code

htable: docs for sht_rm(htname, itname)

Daniel-Constantin Mierla authored on 09/09/2018 07:01:11
Showing 1 changed files
... ...
@@ -749,6 +749,26 @@ modparam("htable", "event_callback_mode", 1)
749 749
 ...
750 750
 sht_print();
751 751
 ...
752
+</programlisting>
753
+		</example>
754
+	</section>
755
+	<section id="htable.f.sht_rm">
756
+		<title>
757
+		<function moreinfo="none">sht_rm(htname, itname)</function>
758
+		</title>
759
+		<para>
760
+			Delete the item with the name 'itname' from hash table 'htname'.
761
+			This API function equivaluent to '$sht(htname=&gt;itname) = $null'.
762
+		</para>
763
+		<para>
764
+			This function can be used from ANY_ROUTE.
765
+		</para>
766
+		<example>
767
+		<title><function>sht_rm</function> usage</title>
768
+		<programlisting format="linespecific">
769
+...
770
+sht_rm("ha", "test"");
771
+...
752 772
 </programlisting>
753 773
 		</example>
754 774
 	</section>
Browse code

htable: docs for sht_has_name(...) and sht_has_str_value(...)

Daniel-Constantin Mierla authored on 04/09/2018 09:12:16
Showing 1 changed files
... ...
@@ -1026,6 +1026,114 @@ sht_iterator_end("i1");
1026 1026
     }
1027 1027
     sht_iterator_end("i1");
1028 1028
 ...
1029
+</programlisting>
1030
+		</example>
1031
+	</section>
1032
+	<section id="htable.f.sht_has_name">
1033
+		<title>
1034
+		<function moreinfo="none">sht_has_name(htable, op, mval)</function>
1035
+		</title>
1036
+		<para>
1037
+			Return greater than 0 (true) if the htable has an item that matches
1038
+			the name against the mval parameter.
1039
+		</para>
1040
+		<para>
1041
+			The op parameter can be:
1042
+		</para>
1043
+		<itemizedlist>
1044
+		<listitem>
1045
+		<para>
1046
+			<emphasis>eq</emphasis> - match the val parameter as string equal
1047
+			expression.
1048
+		</para>
1049
+		</listitem>
1050
+		<listitem>
1051
+		<para>
1052
+			<emphasis>ne</emphasis> - match the val parameter as string not-equal
1053
+			expression.
1054
+		</para>
1055
+		</listitem>
1056
+		<listitem>
1057
+		<para>
1058
+			<emphasis>re</emphasis> - match the val parameter as regular
1059
+			expression.
1060
+		</para>
1061
+		</listitem>
1062
+		<listitem>
1063
+		<para>
1064
+			<emphasis>sw</emphasis> - match the val parameter as 'starts
1065
+			with' expression.
1066
+		</para>
1067
+		</listitem>
1068
+		</itemizedlist>
1069
+		<para>
1070
+			All parameters can be static strings or contain variables.
1071
+		</para>
1072
+		<para>
1073
+			This function can be used from ANY_ROUTE.
1074
+		</para>
1075
+		<example>
1076
+		<title><function>sht_has_name</function> usage</title>
1077
+		<programlisting format="linespecific">
1078
+...
1079
+if(sht_has_name("ha", "eq", "alice")) {
1080
+  ...
1081
+}
1082
+...
1083
+</programlisting>
1084
+		</example>
1085
+	</section>
1086
+	<section id="htable.f.sht_has_str_value">
1087
+		<title>
1088
+		<function moreinfo="none">sht_has_str_value(htable, op, mval)</function>
1089
+		</title>
1090
+		<para>
1091
+			Return greater than 0 (true) if the htable has an item that matches
1092
+			the string value against the mval parameter.
1093
+		</para>
1094
+		<para>
1095
+			The op parameter can be:
1096
+		</para>
1097
+		<itemizedlist>
1098
+		<listitem>
1099
+		<para>
1100
+			<emphasis>eq</emphasis> - match the val parameter as string equal
1101
+			expression.
1102
+		</para>
1103
+		</listitem>
1104
+		<listitem>
1105
+		<para>
1106
+			<emphasis>ne</emphasis> - match the val parameter as string not-equal
1107
+			expression.
1108
+		</para>
1109
+		</listitem>
1110
+		<listitem>
1111
+		<para>
1112
+			<emphasis>re</emphasis> - match the val parameter as regular
1113
+			expression.
1114
+		</para>
1115
+		</listitem>
1116
+		<listitem>
1117
+		<para>
1118
+			<emphasis>sw</emphasis> - match the val parameter as 'starts
1119
+			with' expression.
1120
+		</para>
1121
+		</listitem>
1122
+		</itemizedlist>
1123
+		<para>
1124
+			All parameters can be static strings or contain variables.
1125
+		</para>
1126
+		<para>
1127
+			This function can be used from ANY_ROUTE.
1128
+		</para>
1129
+		<example>
1130
+		<title><function>sht_has_name</function> usage</title>
1131
+		<programlisting format="linespecific">
1132
+...
1133
+if(sht_has_str_value("ha", "eq", "alice")) {
1134
+  ...
1135
+}
1136
+...
1029 1137
 </programlisting>
1030 1138
 		</example>
1031 1139
 	</section>
Browse code

htable: docs for event_callback_mode parameter

Daniel-Constantin Mierla authored on 03/05/2018 19:19:59
Showing 1 changed files
... ...
@@ -701,6 +701,30 @@ function ksr_htable_event(evname)
701 701
 	return 1;
702 702
 end
703 703
 ...
704
+</programlisting>
705
+		</example>
706
+	</section>
707
+	<section id="htable.p.event_callback_mode">
708
+		<title><varname>event_callback_mode</varname> (int)</title>
709
+		<para>
710
+			Control when event_route[htable:init] is executed: 0 - after all
711
+			modules were initialized; 1 - in first worker process.
712
+		</para>
713
+		<para>
714
+			Set it to 1 if used in a KEMI script or when needing to use database
715
+			(e.g., via sqlops) inside event_route[htable:init].
716
+		</para>
717
+		<para>
718
+		<emphasis>
719
+			Default value is 0.
720
+		</emphasis>
721
+		</para>
722
+		<example>
723
+		<title>Set <varname>event_callback_mode</varname> parameter</title>
724
+		<programlisting format="linespecific">
725
+...
726
+modparam("htable", "event_callback_mode", 1)
727
+...
704 728
 </programlisting>
705 729
 		</example>
706 730
 	</section>
Browse code

htable: Fix typos in module documentation

Florian Floimair authored on 26/02/2018 21:12:51 • Daniel-Constantin Mierla committed on 28/02/2018 17:00:48
Showing 1 changed files
... ...
@@ -56,7 +56,7 @@ $sht(a=&gt;$ci::srcip) = $si;
56 56
 	<para>
57 57
 		The next example shows a way to protect against dictionary attacks. If
58 58
 		someone fails to authenticate 3 times, it is forbidden for 15 minutes.
59
-		Authenticatiion against database is expensive as it does a select
59
+		Authentication against database is expensive as it does a select
60 60
 		on the <quote>subscriber</quote> table. By disabling the DB auth for 15 minutes,
61 61
 		resources on the server are saved and time to discover the password is increased
62 62
 		substantially. Additional alerting can be done by writing a message
... ...
@@ -896,7 +896,7 @@ sht_lock("ha=>test");
896 896
 		<function moreinfo="none">sht_unlock(htable=>key)</function>
897 897
 		</title>
898 898
 		<para>
899
-			Unlock the slot in htable corespoding to the key item. Note that
899
+			Unlock the slot in htable corresponding to the key item. Note that
900 900
 			the locking is re-entrant for the process, therefore the lock
901 901
 			and unlock should be done by the same process.
902 902
 		</para>
... ...
@@ -950,7 +950,7 @@ sht_iterator_start("i1", "h1");
950 950
 		</title>
951 951
 		<para>
952 952
 			Close the iterator identified by iname parameter and release
953
-			the hash table slot aquired by the iterator. The iname value
953
+			the hash table slot acquired by the iterator. The iname value
954 954
 			must be the same used for sht_iterator_start().
955 955
 		</para>
956 956
 		<para>
... ...
@@ -1163,7 +1163,7 @@ kamcmd htable.sets test x[0] abc
1163 1163
 # Set $sht(test=>x) as integer
1164 1164
 kamcmd htable.seti test x 123
1165 1165
 
1166
-# Set firsti entry in array key x $sht(test=>x[0]) as integer
1166
+# Set first entry in array key x $sht(test=>x[0]) as integer
1167 1167
 kamcmd htable.sets test x[0] 123
1168 1168
 ...
1169 1169
 </programlisting>
Browse code

htable: implemented starts with matching for remove functions

Daniel-Constantin Mierla authored on 23/05/2017 00:33:19
Showing 1 changed files
... ...
@@ -788,6 +788,12 @@ sht_rm_value_re("ha=>.*");
788 788
 			expression.
789 789
 		</para>
790 790
 		</listitem>
791
+		<listitem>
792
+		<para>
793
+			<emphasis>sw</emphasis> - match the val parameter as 'starts
794
+			with'.
795
+		</para>
796
+		</listitem>
791 797
 		</itemizedlist>
792 798
 		<para>
793 799
 			All parameters can be static strings or contain variables.
... ...
@@ -822,6 +828,12 @@ sht_rm_name("ha", "re", ".*");
822 828
 			expression.
823 829
 		</para>
824 830
 		</listitem>
831
+		<listitem>
832
+		<para>
833
+			<emphasis>sw</emphasis> - match the val parameter as 'starts
834
+			with'.
835
+		</para>
836
+		</listitem>
825 837
 		</itemizedlist>
826 838
 		<para>
827 839
 			All parameters can be static strings or contain variables.
... ...
@@ -830,7 +842,7 @@ sht_rm_name("ha", "re", ".*");
830 842
 			This function can be used from ANY_ROUTE.
831 843
 		</para>
832 844
 		<example>
833
-		<title><function>sht_rm_value_re</function> usage</title>
845
+		<title><function>sht_rm_value</function> usage</title>
834 846
 		<programlisting format="linespecific">
835 847
 ...
836 848
 sht_rm_value("ha", "re", ".*");
Browse code

htable: added functions to remove items using variables

Daniel-Constantin Mierla authored on 22/05/2017 11:04:15
Showing 1 changed files
... ...
@@ -767,6 +767,74 @@ sht_rm_name_re("ha=>.*");
767 767
 ...
768 768
 sht_rm_value_re("ha=>.*");
769 769
 ...
770
+</programlisting>
771
+		</example>
772
+	</section>
773
+	<section id="htable.f.sht_rm_name">
774
+		<title>
775
+		<function moreinfo="none">sht_rm_name(htable, op, val)</function>
776
+		</title>
777
+		<para>
778
+			Delete all entries in the htable that match the name against
779
+			the val parameter.
780
+		</para>
781
+		<para>
782
+			The op parameter can be:
783
+		</para>
784
+		<itemizedlist>
785
+		<listitem>
786
+		<para>
787
+			<emphasis>re</emphasis> - match the val parameter as regular
788
+			expression.
789
+		</para>
790
+		</listitem>
791
+		</itemizedlist>
792
+		<para>
793
+			All parameters can be static strings or contain variables.
794
+		</para>
795
+		<para>
796
+			This function can be used from ANY_ROUTE.
797
+		</para>
798
+		<example>
799
+		<title><function>sht_rm_name</function> usage</title>
800
+		<programlisting format="linespecific">
801
+...
802
+sht_rm_name("ha", "re", ".*");
803
+...
804
+</programlisting>
805
+		</example>
806
+	</section>
807
+	<section id="htable.f.sht_rm_value">
808
+		<title>
809
+		<function moreinfo="none">sht_rm_value(htable, op, val)</function>
810
+		</title>
811
+		<para>
812
+			Delete all entries in the htable that match the value against
813
+			the val parameter.
814
+		</para>
815
+		<para>
816
+			The op parameter can be:
817
+		</para>
818
+		<itemizedlist>
819
+		<listitem>
820
+		<para>
821
+			<emphasis>re</emphasis> - match the val parameter as regular
822
+			expression.
823
+		</para>
824
+		</listitem>
825
+		</itemizedlist>
826
+		<para>
827
+			All parameters can be static strings or contain variables.
828
+		</para>
829
+		<para>
830
+			This function can be used from ANY_ROUTE.
831
+		</para>
832
+		<example>
833
+		<title><function>sht_rm_value_re</function> usage</title>
834
+		<programlisting format="linespecific">
835
+...
836
+sht_rm_value("ha", "re", ".*");
837
+...
770 838
 </programlisting>
771 839
 		</example>
772 840
 	</section>
Browse code

htable: more details about kemi callback function parameter

Daniel-Constantin Mierla authored on 04/04/2017 13:49:43
Showing 1 changed files
... ...
@@ -677,8 +677,12 @@ modparam("htable", "timer_procs", 4)
677 677
 		<para>
678 678
 			The name of the function in the kemi configuration file (embedded
679 679
 			scripting language such as Lua, Python, ...) to be executed instead
680
-			of event_route[...] blocks. The function receives a string parameter
681
-			with the name of the event.
680
+			of event_route[...] blocks.
681
+		</para>
682
+		<para>
683
+			The function receives a string parameter with the name of the event,
684
+			the values can be: 'htable:mod-init', 'htable:expired:htname'
685
+			('htname' being the name of hash table).
682 686
 		</para>
683 687
 		<para>
684 688
 		<emphasis>
Browse code

htable: documentation fix for expires_column parameter

Ovidiu Sas authored on 01/03/2017 21:03:19
Showing 1 changed files
... ...
@@ -534,7 +534,7 @@ modparam("htable", "key_value_column", "kvalue")
534 534
 		<title>Set <varname>expires_column</varname> parameter</title>
535 535
 		<programlisting format="linespecific">
536 536
 ...
537
-modparam("htable", "expires", "expiry")
537
+modparam("htable", "expires_column", "expiry")
538 538
 ...
539 539
 </programlisting>
540 540
 		</example>
Browse code

Merge pull request #926 from mslehto/doc

documentation updates

Daniel-Constantin Mierla authored on 14/01/2017 12:02:24 • GitHub committed on 14/01/2017 12:02:24
Showing 0 changed files
Browse code

modules: update documentation to mention RPC instead of MI

Mikko Lehto authored on 13/01/2017 10:15:28
Showing 1 changed files
... ...
@@ -623,7 +623,7 @@ modparam("htable", "db_expires", 1)
623 623
 		<para>
624 624
 			If set to 1, will enable DMQ replication of actions performed upon
625 625
 			entries in all tables having "dmqreplicate" parameter set. Any update
626
-			action performed via pseudo-variables, MI and RPC commands will be
626
+			action performed via pseudo-variables and RPC commands will be
627 627
 			repeated on all other nodes. Therefore, it is important to ensure the
628 628
 			table definition (size, autoexpire etc.) is identical across all instances.
629 629
 		</para>
Browse code

modules: docs - coherent name for rpc commands section

Daniel-Constantin Mierla authored on 10/01/2017 22:16:03
Showing 1 changed files
... ...
@@ -955,7 +955,7 @@ sht_iterator_end("i1");
955 955
 		</para>
956 956
 	</section>
957 957
 	<section>
958
-        <title>Exported RPC Commands</title>
958
+        <title>RPC Commands</title>
959 959
         <section id="htable.rpc.get">
960 960
                 <title>
961 961
                 <function moreinfo="none">htable.get htable key</function>
Browse code

htable: removed mi commands

Daniel-Constantin Mierla authored on 24/12/2016 07:45:37
Showing 1 changed files
... ...
@@ -954,92 +954,14 @@ sht_iterator_end("i1");
954 954
 		Exported pseudo-variables are documented at &kamwikilink;.
955 955
 		</para>
956 956
 	</section>
957
-	<section>
958
-	<title>MI Commands</title>
959
-	<section>
960
-		<title>
961
-		<function moreinfo="none">sht_reload</function>
962
-		</title>
963
-		<para>
964
-		Reload a hash table from database.
965
-		</para>
966
-		<para>
967
-		Name: <emphasis>sht_reload</emphasis>
968
-		</para>
969
-		<para>Parameters: <emphasis>_hash_table_name_</emphasis> - the name
970
-		of hash table to reload.</para>
971
- 		<para>
972
-		MI FIFO Command Format:
973
-		</para>
974
-        <programlisting  format="linespecific">
975
-		:sht_reload:_reply_fifo_file_
976
-		_hash_table_name_
977
-		_empty_line_
978
-		</programlisting>
979
-    </section>
980
-    <section>
981
-		<title>
982
-		<function moreinfo="none">sht_dump</function>
983
-		</title>
984
-		<para>
985
-		Dump content of a hash table via MI.
986
-		</para>
987
-		<para>
988
-		Name: <emphasis>sht_dump</emphasis>
989
-		</para>
990
-		<para>Parameters: <emphasis>_hash_table_name_</emphasis> - the name
991
-		of hash table to dump.</para>
992
- 		<para>
993
-		MI FIFO Command Format:
994
-		</para>
995
-		<programlisting  format="linespecific">
996
-		:sht_dump:_reply_fifo_file_
997
-		_hash_table_name_
998
-		_empty_line_
999
-		</programlisting>
1000
-    </section>
1001
-    <section>
1002
-		<title>
1003
-		<function moreinfo="none">sht_delete</function>
1004
-		</title>
1005
-		<para>
1006
-		Delete a key from a hash table via MI.
1007
-		</para>
1008
-		<para>
1009
-		Name: <emphasis>sht_delete</emphasis>
1010
-		</para>
1011
-		<para>Parameters:</para>
1012
-		<itemizedlist>
1013
-			<listitem><para><emphasis>_hash_table_name: </emphasis>The table name to delete the key from</para></listitem>
1014
-			<listitem><para><emphasis>_key_name: </emphasis>The key to delete from the htable</para></listitem>
1015
-		</itemizedlist>
1016
-
1017
- 		<para>
1018
-		MI FIFO Command Format:
1019
-		</para>
1020
-		<programlisting  format="linespecific">
1021
-		:sht_delete:_reply_fifo_file_
1022
-		_hash_table_name_
1023
-		_key_name_
1024
-		_empty_line_
1025
-		</programlisting>
1026
-
1027
- 		<para>
1028
-		Example (note the quoting when executing it via FIFO):
1029
-		</para>
1030
-		<programlisting  format="linespecific">
1031
-		kamctl fifo sht_delete auth '"user@example.org::last_auth"'
1032
-		</programlisting>
1033
-    </section>
1034
-    </section>
1035 957
 	<section>
1036 958
         <title>Exported RPC Commands</title>
1037
-        <section>
959
+        <section id="htable.rpc.get">
1038 960
                 <title>
1039 961
                 <function moreinfo="none">htable.get htable key</function>
1040 962
                 </title>
1041 963
                 <para>
1042
-		Lists one value in a hash table