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
8aa77803
Commit
8aa77803
authored
Feb 23, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Illustrate directors.shard_param() use
parent
97ef14c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
vmod.vcc
lib/libvmod_directors/vmod.vcc
+40
-6
No files found.
lib/libvmod_directors/vmod.vcc
View file @
8aa77803
...
@@ -349,10 +349,12 @@ Set the default rampup duration. See `rampup` parameter of
...
@@ -349,10 +349,12 @@ Set the default rampup duration. See `rampup` parameter of
$Method VOID .associate(BLOB param=0)
$Method VOID .associate(BLOB param=0)
Associate a default `vmod_directors.shard_param`_ object or clear an association.
Associate a default `vmod_directors.shard_param`_ object or clear an
association.
The value of the `param` argument must be a call to the
The value of the `param` argument must be a call to the
`vmod_directors.shard_param.use`_ method. No argument clears the association.
`vmod_directors.shard_param.use`_ method. No argument clears the
association.
The association can be changed per backend request using the `param`
The association can be changed per backend request using the `param`
argument of `vmod_directors.shard.backend`_.
argument of `vmod_directors.shard.backend`_.
...
@@ -567,10 +569,10 @@ $Object shard_param()
...
@@ -567,10 +569,10 @@ $Object shard_param()
Create a shard parameter set.
Create a shard parameter set.
A parameter set allows for re-use of `vmod_directors.shard.backend`_
arguments
A parameter set allows for re-use of `vmod_directors.shard.backend`_
a
cross many shard director instances and simplifies advanced use cases
a
rguments across many shard director instances and simplifies advanced
(e.g. shard director with custom parameters layered below other
use cases (e.g. shard director with custom parameters layered below
directors).
other
directors).
Parameter sets have two scopes:
Parameter sets have two scopes:
...
@@ -583,6 +585,38 @@ respective backend request.
...
@@ -583,6 +585,38 @@ respective backend request.
Parameter sets can not be used in client context.
Parameter sets can not be used in client context.
The following example is a typical use case: A parameter set is
associated with several directors. Director choice happens on the
client side and parameters are changed on the backend side to
implement retries on alternative backends::
sub vcl_init {
new shard_param = directors.shard_param();
new dir_A = directors.shard();
dir_A.add_backend(...);
dir_A.reconfigure(shard_param);
dir_A.associate(shard_param.use()); # <-- !
new dir_B = directors.shard();
dir_B.add_backend(...);
dir_B.reconfigure(shard_param);
dir_B.associate(shard_param.use()); # <-- !
}
sub vcl_recv {
if (...) {
set req.backend_hint = dir_A.backend(resolve=LAZY);
} else {
set req.backend_hint = dir_B.backend(resolve=LAZY);
}
}
sub vcl_backend_fetch {
# changes dir_A and dir_B behaviour
shard_param.set(alt=bereq.retries);
}
$Method VOID .clear()
$Method VOID .clear()
Reset the parameter set to default values as documented for
Reset the parameter set to default values as documented for
...
...
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