[PATCH] add documentation about backend naming for VMOD authors
geoff at uplex.de
Mon Nov 2 01:32:31 CET 2015
-----BEGIN PGP SIGNED MESSAGE-----
On 11/02/2015 12:42 AM, Poul-Henning Kamp wrote:
>>> But that reminds me: What was the consensus on my proposal for
>>> .%d suffix for colliding backend names ?
The previous conversation was just you and me talking, so I don't know
if we could call anything "consensus", but one point was that with the
suffix, VBE stats would exist for every backend. Otherwise, VBE stats
are only set up for one backend with a duplicated name, and all other
backends with the same name get no stats at all.
But on further consideration, could we always ensure that any backend
created by a VMOD might get the suffix if it needs to?
The message of the "Writing a Director" doc is that a VMOD creates a
struct director, never a struct backend. If you want it to be a
backend, then you leave the resolve function as NULL. An easy way to
do that is to use VRT_new_backend, which in turn calls VCL_AddBackend,
and that's where the suffix can be added if necessary.
But you don't have to do it that way. A VMOD author can set up
everything in a struct director, implementing all of the functions in
the interface (and connection pools, probes, stats, a listener for the
event function, the works; all of which are necessary for backends
that don't speak HTTP over TCP). Then these objects can be used for
everything you can do with VCL_BACKEND -- add it to a director, assign
it to req.backend_hint etc. -- with no other part of Varnish intervening.
In that case, the VMOD assigns a name to the vcl_name field; and it
can assign a suffix if it wants to, but I don't see any way to force it.
So unless we add a requirement like "you have to call VCL_Something()
to 'register' the director/backend", so that VCL_Something() can
change the name, I don't think we can use suffixes or anything else to
enforce unique names. (And as of now, I don't see why a VMOD backend
wouldn't work even if it doesn't call VCL_Something().)
** * * UPLEX - Nils Goroll Systemoptimierung
Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
-----END PGP SIGNATURE-----
More information about the varnish-dev