Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
c7b96c31
Commit
c7b96c31
authored
Feb 26, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add directors.lookup()
parent
cddc0974
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
1 deletion
+69
-1
b00016.vtc
bin/varnishtest/tests/b00016.vtc
+10
-1
changes.rst
doc/changes.rst
+5
-0
Makefile.am
lib/libvmod_directors/Makefile.am
+1
-0
misc.c
lib/libvmod_directors/misc.c
+47
-0
vmod.vcc
lib/libvmod_directors/vmod.vcc
+6
-0
No files found.
bin/varnishtest/tests/b00016.vtc
View file @
c7b96c31
...
@@ -6,7 +6,12 @@ server s1 -repeat 2 -keepalive {
...
@@ -6,7 +6,12 @@ server s1 -repeat 2 -keepalive {
} -start
} -start
varnish v1 -vcl+backend {
varnish v1 -vcl+backend {
import directors;
sub vcl_recv {
sub vcl_recv {
if (req.url == "/lookup") {
set req.http.foo = directors.lookup("s1");
}
return (pass);
return (pass);
}
}
...
@@ -19,6 +24,10 @@ client c1 {
...
@@ -19,6 +24,10 @@ client c1 {
txreq -url "/"
txreq -url "/"
rxresp
rxresp
expect resp.http.X-Backend-Name == "s1"
expect resp.http.X-Backend-Name == "s1"
txreq -url "/lookup"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
} -run
varnish v1 -vcl+backend {
varnish v1 -vcl+backend {
...
@@ -26,7 +35,7 @@ varnish v1 -vcl+backend {
...
@@ -26,7 +35,7 @@ varnish v1 -vcl+backend {
sub vcl_init {
sub vcl_init {
new bar = directors.random();
new bar = directors.random();
bar.add_backend(
s1
, 1);
bar.add_backend(
directors.lookup("s1")
, 1);
}
}
sub vcl_recv {
sub vcl_recv {
...
...
doc/changes.rst
View file @
c7b96c31
...
@@ -104,6 +104,11 @@ VCL
...
@@ -104,6 +104,11 @@ VCL
* Added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_)
* Added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_)
bundled vmods
-------------
* Added ``directors.lookup()``
bundled tools
bundled tools
-------------
-------------
...
...
lib/libvmod_directors/Makefile.am
View file @
c7b96c31
...
@@ -5,6 +5,7 @@ libvmod_directors_la_SOURCES = \
...
@@ -5,6 +5,7 @@ libvmod_directors_la_SOURCES = \
vdir.h
\
vdir.h
\
fall_back.c
\
fall_back.c
\
hash.c
\
hash.c
\
misc.c
\
random.c
\
random.c
\
round_robin.c
\
round_robin.c
\
vmod_shard.c
\
vmod_shard.c
\
...
...
lib/libvmod_directors/misc.c
0 → 100644
View file @
c7b96c31
/*-
* Copyright 2019 UPLEX - Nils Goroll Systemoptimierung
* All rights reserved.
*
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "vdef.h"
#include "vrt.h"
#include "vcl.h"
#include "vcc_if.h"
VCL_BACKEND
VPFX
(
lookup
)(
VRT_CTX
,
VCL_STRING
name
)
{
if
((
ctx
->
method
&
VCL_MET_TASK_H
)
==
0
)
{
VRT_fail
(
ctx
,
"lookup() may only be called from vcl_init / vcl_fini"
);
return
(
NULL
);
}
return
(
VRT_LookupDirector
(
ctx
,
name
));
}
lib/libvmod_directors/vmod.vcc
View file @
c7b96c31
...
@@ -687,6 +687,12 @@ This method may only be used in backend context.
...
@@ -687,6 +687,12 @@ This method may only be used in backend context.
For use with the `param` argument of `vmod_directors.shard.backend`_ to associate
For use with the `param` argument of `vmod_directors.shard.backend`_ to associate
this shard parameter set with a shard director.
this shard parameter set with a shard director.
$Function BACKEND lookup(STRING)
Lookup a backend by its name.
This function can only be used from ``vcl_init{}`` and ``vcl_fini{}``.
ACKNOWLEDGEMENTS
ACKNOWLEDGEMENTS
================
================
...
...
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