Commit 529f6c55 authored by Nils Goroll's avatar Nils Goroll

update vcc/readme

parent 75e2bac1
Pipeline #298 skipped
......@@ -10,28 +10,22 @@ import weightadjust;
DESCRIPTION
===========
Weightadjust Varnish vmod demonstrating how to write an out-of-tree Varnish vmod.
Random director with dynamic weight update based on http requests to
backends.
Implements the traditional Hello World as a vmod.
Example:
FUNCTIONS
=========
hello
-----
::
Prototype
::
vcl_init {
new director = random();
hello(STRING S)
Return value
STRING
Description
Returns "Hello, " prepended to S
Weightadjust
::
director.add_backend(backend,
weight=1.1,
weight_update="^X-Weight: *(\d+\.\d+)",
url="/get-weight.php");
set resp.http.hello = weightadjust.hello("World");
See vmod documentation/man page for details.
INSTALLATION
============
......@@ -82,40 +76,3 @@ By default, the vmod ``configure`` script installs the built vmod in the
directory relevant to the prefix. The vmod installation directory can be
overridden by passing the ``vmoddir`` variable to ``make install``.
USAGE
=====
In your VCL you could then use this vmod along the following lines::
import weightadjust;
sub vcl_deliver {
# This sets resp.http.hello to "Hello, World"
set resp.http.hello = weightadjust.hello("World");
}
COMMON PROBLEMS
===============
* configure: error: Need varnish.m4 -- see README.rst
Check whether ``PKG_CONFIG_PATH`` and ``ACLOCAL_PATH`` were set correctly
before calling ``autogen.sh`` and ``configure``
* Incompatibilities with different Varnish Cache versions
Make sure you build this vmod against its correspondent Varnish Cache version.
For instance, to build against Varnish Cache 4.1, this vmod must be built from
branch 4.1.
START YOUR OWN VMOD
===================
The basic steps to start a new vmod from this weightadjust are::
name=myvmod
git clone libvmod-weightadjust libvmod-$name
cd libvmod-$name
./rename-vmod-script $name
and follow the instructions output by rename-vmod-script
......@@ -58,12 +58,14 @@ Description
time exceeds it.
The *buffer* parameter defines a maximum size for the http
response, headers and body.
response (headers and body) to scan with the *weight_update*
regular expression.
Example
# 2/3 to backend1, 1/3 to backend2.
vdir.add_backend(backend1, 10.0);
vdir.add_backend(backend2, 5.0);
vdir.add_backend(backend1, 10.0,
"^X-Weight: *(\d+\.\d+)", "/get-weight.php")
vdir.add_backend(backend2, 2.0,
"^X-Weight: *(\d+\.\d+)", "/get-weight.php")
$Method VOID .remove_backend(BACKEND)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment