diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-08 13:16:39 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-08 13:16:39 +0200 |
commit | 067d63d298a15810171555f7f0acf96fb1946667 (patch) | |
tree | 45590d2a8f795ffd426e840c1fc6f1937d78887f | |
parent | f490124e04a9dda412d1979ca9e3e7a51f7ab8d3 (diff) | |
download | vmod-tbf-067d63d298a15810171555f7f0acf96fb1946667.tar.gz vmod-tbf-067d63d298a15810171555f7f0acf96fb1946667.tar.bz2 |
Update the docs.
-rw-r--r-- | src/tbf.c | 4 | ||||
-rw-r--r-- | src/vmod-tbf.3 | 78 |
2 files changed, 59 insertions, 23 deletions
@@ -193,13 +193,13 @@ tree_delete_node_unlocked(struct tree *tree, struct node *node) /* No right subtree: link the left subtree to the parent slot */ *slot = node->child[CHILD_LEFT]; if (node->child[CHILD_LEFT]) node->child[CHILD_LEFT]->parent = parent; } else { /* Node has both subtrees. Find the largest value in the - right subtree */ + left subtree */ struct node *p; for (p = node->child[CHILD_LEFT]; p->child[CHILD_RIGHT]; p = p->child[CHILD_RIGHT]) ; p->child[CHILD_RIGHT] = node->child[CHILD_RIGHT]; @@ -833,13 +833,13 @@ tbf_release_tree(struct tree **t) { tree_unref(t); } static void -tbf_exit() +tbf_exit(void) { if (tbf_dump_file_name) { struct tree *t = tbf_get_tree(); tree_dump(t, tbf_dump_file_name); tbf_release_tree(&t); } diff --git a/src/vmod-tbf.3 b/src/vmod-tbf.3 index 8af8b65..626341c 100644 --- a/src/vmod-tbf.3 +++ b/src/vmod-tbf.3 @@ -10,30 +10,38 @@ .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>. -.TH VMOD-TBF 1 "January 26, 2016" "VMOD-TBF" "User Reference" +.TH VMOD-TBF 1 "February 8, 2016" "VMOD-TBF" "User Reference" .SH NAME vmod-tbf \- token bucket filtering for Varnish .SH SYNOPSIS .B import tbf; .BI "BOOL tbf.rate(STRING " key ", INT " COST ", DURATION " interval ", INT " burst_size ");" .BI "BOOL tbf.check(STRING " key ", STRING " rate ");" -.BI "VOID tbf.debug(INT " level ");" - .BI "VOID tbf.dump(STRING " file ");" +.BI "VOID tbf.dump_at_exit(STRING " file ");" + +.BI "VOID tbf.load(STRING " file ");" + .BI "VOID tbf.gc(DURATION " interval ");" .BI "VOID tbf.set_gc_interval(DURATION " interval ");" +.BI "VOID tbf.debug(INT " level ");" + +.BI "VOID tbf.log_tree(INT " prio ");" + +.BI "VOID tbf.log_stats(INT " prio ");" + .BI "REAL tbf.getla(INT " sample ");" .BI "INT tbf.systime();" .BI "STRING tbf.strftime(STRING " format ", INT " timestamp ");" @@ -135,42 +143,70 @@ function. Garbage collection can also be triggered explicitly, using the .B tbf.gc function with the interval as its argument. .PP The function .B tbf.dump -dumps entire tree to the disk file. +dumps entire tree to the disk file. The function +.B tbf.load +loads the named dump file into the tree. .PP The function -.B tbf.debug -sets the debug level. +.B tbf.dump_at_exit +configures the module to dump the tree before +.B varnishd +terminates. Use this to keep the \fBtbf\fR state across +\fBvarnishd\fR restarts. For example: +.PP +.EX +sub vcl_init { + tbf.load("/var/run/tbf.dump"); + tbf.dump_at_exit("/var/run/tbf.dump"); +} +.EE +.SS Debugging +.TP +.BI "VOID tbf.debug(INT " level ");" +Sets the debug verbosity level. Meaningful argument values are +\fB0\fR (no debugging info) to \fB2\fR (maximum verbosity). +.TP +.BI "VOID tbf.log_tree(INT " prio ");" +Logs the content of the \fBtbf\fR tree to \fBsyslog\fR priority +\fIprio\fR. Note that this can produce extremely big amounts of info. +.TP +.BI "VOID tbf.log_stats(INT " prio ");" +Logs the tree statistics to \fBsyslog\fR priority \fIprio\fR. The +following information is logged: total number of nodes in tree, number +of leaves, shortest, longest and average paths. .SS Other functions .PP Several functions are provided that do not exactly belong to the TBF algorithm, but which may come useful when implementing rate control. -.PP -The \fBtbf.getla\fR function returns the system load average. Its -argument identifies the interval for which to compute it: 1, 5 or -15 minutes. -.PP -The \fBtbf.systime\fR function returns the current time of day as the -number of seconds since the Epoch (1970-01-01 00:00:00 UTC). -.PP -The \fBtbf.strftime\fR function formats the \fBtimestamp\fR according -to the specification in \fBformat\fR. See +.TP +.BI "REAL tbf.getla(INT " sample ");" +Returns the system load average. The argument identifies interval +for which to compute it: 1, 5 or 15 minutes. +.TP +.BI "INT tbf.systime();" +Returns the current time of day as the number of seconds since the +Epoch (1970-01-01 00:00:00 UTC). +.TP +.BI "STRING tbf.strftime(STRING " format ", INT " timestamp ");" +Function formats the \fItimestamp\fR according to the specification in +\fIformat\fR. See .BR strftime (3), for a description of available formats. For example, the following -statements assigns the current year to the \f(CWX\-Year\fR header: -.PP +statement assigns the current year to the \f(CWX\-Year\fR header: + .EX set req.http.X-Year = tbf.strftime("%Y", systime()); .EE -.PP -The \fBtbf.sleep\fR function suspends execution for a specified amount -of time. +.TP +.BI "VOID tbf.sleep(DURATION " time ");" +Suspends execution for a specified amount of time. .\" .\" The MANCGI variable is set by man.cgi script on Ulysses. .\" The download.inc file contains the default DOWNLOAD section .\" for man-based doc pages. .if "\V[MANCGI]"WEBDOC" \{\ . ds package vmod-tbf |