Hi List,

My coworkers and I are working on a sharding VMOD and we got to the point
it's actually working (woohoo!).


Now, our implementation is pretty straightforward:


 - get id from url
 - do a "id mod n" to pick correct shard ( = director)
 - set req.backend = shardN


Right now we have a very long if/elsif codepath that looks like this:


    var.set_int("shard", sharding.get_mod_n(req.url,420));


    if (var.get_int("shard") == 0) {
        set req.backend = shard0;
        set req.http.X-Varnish-Backend = "shard0";
    }
    elsif (var.get_int("shard") == 1) {
        set req.backend = shard1;
        set req.http.X-Varnish-Backend = "shard1";
    }
    ...


So my question is, is it possible to *generate* the correct backend director,
so we only need one line of VCL, instead of the long if/else, like so:


    set req.backend = shard + sharding.get_mod_n(req.url,420);


Yet, this does not work, maybe there's a workaround, or maybe someone else 
found a solution?
Thanks in advance!


Regards,


Enno
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to