VMOD for VCL variables as objects: constants, global variables, TASK and TOP scope
Find a file
2025-09-15 18:01:39 +02:00
src Adjust to Varnish-Cache 8.0 2025-09-15 18:01:39 +02:00
.gitignore Handle src/vmod_vcs_version.txt 2025-06-17 11:15:09 +02:00
bootstrap initial vcdk skeleton 2018-10-25 19:11:37 +02:00
configure.ac Fix AC_ARG_WITH syntax 2022-04-27 16:21:13 +02:00
INSTALL.rst Initial release 2018-10-27 16:35:22 +02:00
LICENSE Standardize LICENSE 2022-12-01 16:27:48 +01:00
Makefile.am Distribute the top-level docs. 2021-06-01 15:51:08 +00:00
README.rst Label master branch in README.rst 2021-06-02 15:33:44 +02:00

==============
varnish-objvar
==============

Compatibility
-------------

This is varnish-objvar for varnish-cache master.

Overview
--------

This bundle contains four varnish modules (vmods) implementing a next
level variable interface using the VCL object model:

* vmod_taskvar:

  `task` scoped variables as objects: Each client or backend request
  (`task`) has their own view of taskvar variables.

* vmod_topvar:

  `top` scoped variables as objects: Each client request including all
  esi include levels (`top`) has its own view of topvar variables.

* vmod_globalvar:

  globally (per vcl) scoped variables as objects: All vcl subroutines
  have the same view on variables, any change comes in effect
  immediately.

* vmod_constant:

  gobally (per vcl) scoped constants as objects: All vcl subroutines
  have the same view on constants.

Full type support
-----------------

The vmods in this bundle aim to support all native VCL types, which
currently are:

* ``ACL``

* ``BACKEND``

* ``BLOB``

* ``BODY``

* ``BOOL``

* ``BYTES``

* ``DURATION``

* ``HEADER``

* ``INT``

* ``IP``

* ``PROBE``

* ``REAL``

* ``STEVEDORE``

* ``STRANDS`` implicit via ``STRING``\ -folding

* ``STRING_LIST`` implicit via ``STRING``\ -folding

* ``STRING``

* ``TIME``


SYNOPSIS
========

Variable object construction is identical for all vmods from this
bundle, shown here by example of the ``int`` type, but the other types
mentioned above are supported likewise:

::

   import constant [from "path"] ;
   import globalvar [from "path"] ;
   import taskvar [from "path"] ;
   import topvar [from "path"] ;

   vcl_init {
	new xconst_int = constant.int(5);
	new xglob_int = globalvar.int(5);
	new xtask_int = taskvar.int(5);
	new xtop_int = topvar.int(5);
   }

All vmods support methods to ``.get()`` the value and check if the
variable is ``.defined()``.

All vmods except ``vmod_constant`` support ``.set()`` and
``.undefine()`` to assign a value to a variable or unset it.

``vmod_taskvar`` and ``vmod_topvar`` also support ``.protect()`` to
make a variable read-only for the rest of its lifetime and
``.protected()`` to check for protection status.

For details see the documentation of the individual vmods.

REQUIREMENTS
============

The VMOD requires the Varnish since version 6.0.0 or the master
branch. See the project repository for versions that are compatible
with other versions of Varnish.

INSTALLATION
============

See `INSTALL.rst <INSTALL.rst>`_ in the project source repository.


COPYRIGHT
=========

::

  Copyright 2018 UPLEX Nils Goroll Systemoptimierung
  All rights reserved

  This document is licensed under the same conditions as the varnish-objvar
  project. See LICENSE for details.

  Author: Nils Goroll <nils.goroll@uplex.de>