Preventing dup backend names with dynamic backends in VMODs

Kacper Wysocki kacperw at gmail.com
Mon Nov 2 19:20:52 CET 2015


On Sun, Nov 1, 2015 at 6:06 PM, Geoff Simmons <geoff at uplex.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 10/30/2015 05:19 PM, Kacper Wysocki wrote:
>>
>> slightly related to this, could we possibly allow accessing the
>> name in VCL, like
>>
>> if(req.backend_hint ~ "zool") { /* do something */ }
>
> If you can wait until vcl_backend_response(), you do have
> beresp.backend.name as a string, and this will work:
>
> if (beresp.backend.name ~ "zool") {
>         /* do something */
> }
>
>> or even
>>
>> std.log("backend was " + req.backend_hint); ?
>
> That works, try it. Evidently because a STRING_LIST is required in
> std.log(), and VCC knows to do implicit string conversions for the
> various data types -- it even works without the concatenation.
>
> A regex match against req.backend_hint or bereq.backend doesn't work
> because a STRING is required. IIUC, VCC does implicit string
> conversions where a STRING_LIST is expected, but not where a STRING is
> expected.

Oh. I hadn't seen req.backend.name. I guess the type conversion is a
little counter to my intuition too.

thanks,
 -kacper



More information about the varnish-dev mailing list