[master] 4bf0b9df5 directors: Optional weight in hash::add_backend()

Nils Goroll nils.goroll at uplex.de
Fri Oct 9 09:26:06 UTC 2020


commit 4bf0b9df5a555368c6db4c7cb3d18b76a3c30629
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Oct 8 18:28:27 2020 +0200

    directors: Optional weight in hash::add_backend()
    
    It makes it easier to substitute the hash director with say, the round
    robin director, when weight is not a concern.

diff --git a/bin/varnishtest/tests/d00003.vtc b/bin/varnishtest/tests/d00003.vtc
index 30c73cfb5..238d5e52d 100644
--- a/bin/varnishtest/tests/d00003.vtc
+++ b/bin/varnishtest/tests/d00003.vtc
@@ -26,7 +26,7 @@ varnish v1 -vcl+backend {
 
 	sub vcl_init {
 		new h1 = directors.hash();
-		h1.add_backend(s1, 1);
+		h1.add_backend(s1);
 		h1.add_backend(s2, 1);
 	}
 
diff --git a/lib/libvmod_directors/vmod_directors.vcc b/lib/libvmod_directors/vmod_directors.vcc
index 5238250f1..f0a32af50 100644
--- a/lib/libvmod_directors/vmod_directors.vcc
+++ b/lib/libvmod_directors/vmod_directors.vcc
@@ -201,23 +201,24 @@ Example::
 
 	new vdir = directors.hash();
 
-$Method VOID .add_backend(BACKEND, REAL)
+$Method VOID .add_backend(BACKEND, REAL weight = 1.0)
 
 Add a backend to the director with a certain weight.
 
-Weight is used as in the random director. Recommended value is 1.0
-unless you have special needs.
+Weight is used as in the random director. Recommended and default value
+is 1.0 unless you have special needs.
 
 Example::
 
-	vdir.add_backend(backend1, 1.0);
+	vdir.add_backend(normal_backend);
+	vdir.add_backend(larger_backend, 1.5);
 
 $Method VOID .remove_backend(BACKEND)
 
 Remove a backend from the director.
 
 Example::
-	vdir.remove_backend(backend1);
+	vdir.remove_backend(larger_backend);
 
 $Method BACKEND .backend(STRANDS)
 


More information about the varnish-commit mailing list