Those of you subscribed to the subversion commitlogs will have noticed
that I am working on the VCL compiler right now.

The two most recent changes is that multiple definitions of the
vcl methods are concatenated so that

        sub vcl_pipe {
                foo;
        }
        sub vcl_pipe {
                bar;
        }

is the same as

        sub vcl_pipe {
                foo;
                bar;
        }

Together with the other change, that adds

        include "somefile" ;

to the syntax, this should allow us to implement a sort of VCL
library which can easily be shared.

For instance, a vcl file implementing the squid purge functionality
could look like:

        sub vcl_recv {
                if (req.request == "PURGE") {
                        lookup;
                }
        }

        sub vcl_hit {
                if (req.request == "PURGE") {
                        set obj.ttl = 0s;
                        error 200 "Purged.";
                }
        }

        sub vcl_miss {
                if (req.request == "PURGE") {
                        error 404 "Not in cache.";
                }
        }

Wanting to apply an acl to the PURGE functionality, it could be
called from a VCL program as such:


        sub vcl_recv {
                if (req.request == "PURGE") {
                        if (!client.ip ~ acl_purge) {
                                error 405 "Not allowed.";
                        }
                }
        }

        include "squid_purge.vcl";


If we come up with a set of such generally useful VCL snippets,
we could decide to add the "library" to the binary so tha tone
could just write:

        include "@squid_purge"

and have The Right Thing Happen.

As always: feedback and input most welcome!

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED]         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
varnish-misc mailing list
[email protected]
http://projects.linpro.no/mailman/listinfo/varnish-misc

Reply via email to