Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-weightadjust
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-weightadjust
Commits
529f6c55
Commit
529f6c55
authored
Oct 03, 2017
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update vcc/readme
parent
75e2bac1
Pipeline
#298
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
58 deletions
+17
-58
README.rst
README.rst
+11
-54
vmod_weightadjust.vcc
src/vmod_weightadjust.vcc
+6
-4
No files found.
README.rst
View file @
529f6c55
...
...
@@ -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
src/vmod_weightadjust.vcc
View file @
529f6c55
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment