Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-objvar
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
uplex-varnish
varnish-objvar
Commits
6089fd5d
Commit
6089fd5d
authored
Oct 27, 2018
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid name clashes by using $Prefix
parent
c6d1800f
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
227 additions
and
207 deletions
+227
-207
tasktop.h
src/tasktop.h
+1
-1
vmod_constant.c
src/vmod_constant.c
+2
-2
vmod_constant.rst
src/vmod_constant.rst
+43
-39
vmod_constant.vcctpl
src/vmod_constant.vcctpl
+1
-0
vmod_globalvar.c
src/vmod_globalvar.c
+5
-5
vmod_globalvar.rst
src/vmod_globalvar.rst
+51
-47
vmod_globalvar.vcctpl
src/vmod_globalvar.vcctpl
+1
-0
vmod_taskvar.c
src/vmod_taskvar.c
+1
-1
vmod_taskvar.rst
src/vmod_taskvar.rst
+68
-64
vmod_taskvar.vcctpl
src/vmod_taskvar.vcctpl
+1
-0
vmod_topvar.c
src/vmod_topvar.c
+1
-1
vmod_topvar.rst
src/vmod_topvar.rst
+51
-47
vmod_topvar.vcctpl
src/vmod_topvar.vcctpl
+1
-0
No files found.
src/tasktop.h
View file @
6089fd5d
...
...
@@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
#define var_code(VMODPFX_, vmodpfx_, TYPE, type) \
#define var_code(
vmod_,
VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
...
...
src/vmod_constant.c
View file @
6089fd5d
...
...
@@ -61,7 +61,7 @@
#define VMOD_CONSTANT_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_CONSTANT_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define var_code(VMODPFX_, vmodpfx_, TYPE, type) \
#define var_code(
vmod_,
VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
...
...
@@ -126,5 +126,5 @@
return (!!v->defined); \
}
#define VCC_TYPE(TYPE, type) var_code(
VMOD_CONSTANT_, vmod
_constant_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(
constant_, VMOD_CONSTANT_, constant
_constant_, TYPE, type)
#include "tbl_types.h"
src/vmod_constant.rst
View file @
6089fd5d
...
...
@@ -8,9 +8,9 @@
.. _vmod_constant(3):
=============
vmod
_constant
=============
=============
====
constant
_constant
=============
====
-----------------------
Varnish constant Module
...
...
@@ -118,43 +118,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements globally (per vcl) scoped constants as objects:
All vcl subroutines have the same view on constants.
The value of a constant is the value assigned to it at construction
time, if any.
constants can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Example::
import constant;
sub vcl_init {
new xint = constant.int(42);
new xundef = constant.int();
}
sub vcl_recv {
set req.http.def = xundef.defined(); # false
set req.http.fallback = xundef.get(5); # 5
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
...
...
@@ -206,6 +170,46 @@ CONTENTS
* :ref:`func_time.get`
DESCRIPTION
===========
This module implements globally (per vcl) scoped constants as objects:
All vcl subroutines have the same view on constants.
The value of a constant is the value assigned to it at construction
time, if any.
constants can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Example::
import constant;
sub vcl_init {
new xint = constant.int(42);
new xundef = constant.int();
}
sub vcl_recv {
set req.http.def = xundef.defined(); # false
set req.http.fallback = xundef.get(5); # 5
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = constant.acl([ACL init])
...
...
src/vmod_constant.vcctpl
View file @
6089fd5d
$Module constant 3 Varnish constant Module
$Prefix constant
DESCRIPTION
===========
...
...
src/vmod_globalvar.c
View file @
6089fd5d
...
...
@@ -145,7 +145,7 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
#define VMOD_GLOBALVAR_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_GLOBALVAR_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define immediate(
VMODPFX_, vmodpfx_, TYPE, type)
\
#define immediate(
vmod_, VMODPFX_, vmodpfx_, TYPE, type)
\
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
...
...
@@ -188,7 +188,7 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
return (v->var); \
}
#define pointer(VMODPFX_, vmodpfx_, TYPE, type) \
#define pointer(
vmod_,
VMODPFX_, vmodpfx_, TYPE, type) \
struct vmodpfx_ ## type { \
uint16_t magic; \
int defined:1; \
...
...
@@ -275,8 +275,8 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
return (r); \
}
#define var_code(VMODPFX_, vmodpfx_, TYPE, type) \
KIND_ ## TYPE (
VMODPFX_, vmodpfx_, TYPE, type)
\
#define var_code(
vmod_,
VMODPFX_, vmodpfx_, TYPE, type) \
KIND_ ## TYPE (
vmod_, VMODPFX_, vmodpfx_, TYPE, type)
\
\
VCL_VOID \
vmod_ ## type ## __init(VRT_CTX, \
...
...
@@ -348,5 +348,5 @@ task_ref_var(VRT_CTX, struct vmod_globalvar_var *v, unsigned magic) {
}
#define VCC_TYPE(TYPE, type) var_code(
VMOD_GLOBALVAR_, vmod
_globalvar_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(
globalvar_, VMOD_GLOBALVAR_, globalvar
_globalvar_, TYPE, type)
#include "tbl_types.h"
src/vmod_globalvar.rst
View file @
6089fd5d
...
...
@@ -8,9 +8,9 @@
.. _vmod_globalvar(3):
==============
vmod
_globalvar
==============
==============
=====
globalvar
_globalvar
==============
=====
------------------------
Varnish globalvar Module
...
...
@@ -178,51 +178,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements globally (per vcl) scoped variables as objects:
All vcl subroutines have the same view on variables, any change comes
in effect immediately.
The value of a globalvar is the value assigned to it by any vcl
subroutine within each vcl or a default provided at construction time,
if any.
globalvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Where necessary, read access to globalvar variables is reference
counted using priv_task state, such that changed variables` storage is
not freed before the last access ceased.
Example with an initially undefined variable::
import globalvar;
sub vcl_init {
new xint = globalvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
\# in some other request, later
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
...
...
@@ -304,6 +260,54 @@ CONTENTS
* :ref:`func_time.undefine`
DESCRIPTION
===========
This module implements globally (per vcl) scoped variables as objects:
All vcl subroutines have the same view on variables, any change comes
in effect immediately.
The value of a globalvar is the value assigned to it by any vcl
subroutine within each vcl or a default provided at construction time,
if any.
globalvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
Where necessary, read access to globalvar variables is reference
counted using priv_task state, such that changed variables` storage is
not freed before the last access ceased.
Example with an initially undefined variable::
import globalvar;
sub vcl_init {
new xint = globalvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
\# in some other request, later
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = globalvar.acl([ACL init])
...
...
src/vmod_globalvar.vcctpl
View file @
6089fd5d
$Module globalvar 3 Varnish globalvar Module
$Prefix globalvar
DESCRIPTION
===========
...
...
src/vmod_taskvar.c
View file @
6089fd5d
...
...
@@ -104,5 +104,5 @@ state_l(VRT_CTX, void *v, size_t sz)
#define VMOD_TASKVAR_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_TASKVAR_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define VCC_TYPE(TYPE, type) var_code(
VMOD_TASKVAR_, vmod
_taskvar_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(
taskvar_, VMOD_TASKVAR_, taskvar
_taskvar_, TYPE, type)
#include "tbl_types.h"
src/vmod_taskvar.rst
View file @
6089fd5d
...
...
@@ -8,9 +8,9 @@
.. _vmod_taskvar(3):
============
vmod
_taskvar
============
============
===
taskvar
_taskvar
============
===
----------------------
Varnish taskvar Module
...
...
@@ -238,68 +238,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements `task` scoped variables as objects: Each client
or backend request (`task`) has their own view of taskvar variables.
The value of a taskvar is the value assigned to it within a `task` or
a default provided at construction time, if any.
taskvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
taskvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example with an initially undefined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
Example with an initially defined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int(17);
}
sub vcl_recv {
set req.http.def = xint.defined(); # true
set req.http.fallback = xint.get(5); # 17
xint.set(42);
xint.protect();
if (false) {
xint.set(3); # would fail
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
...
...
@@ -411,6 +350,71 @@ CONTENTS
* :ref:`func_time.undefine`
DESCRIPTION
===========
This module implements `task` scoped variables as objects: Each client
or backend request (`task`) has their own view of taskvar variables.
The value of a taskvar is the value assigned to it within a `task` or
a default provided at construction time, if any.
taskvars can be undefined. Attempts to ``.get`` an undefined value
will return a the ``.get`` method`s `fallback` argument, which in turn
may have a default for some cases.
taskvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example with an initially undefined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int();
}
sub vcl_recv {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
Example with an initially defined variable::
import taskvar;
sub vcl_init {
new xint = taskvar.int(17);
}
sub vcl_recv {
set req.http.def = xint.defined(); # true
set req.http.fallback = xint.get(5); # 17
xint.set(42);
xint.protect();
if (false) {
xint.set(3); # would fail
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = taskvar.acl([ACL init])
...
...
src/vmod_taskvar.vcctpl
View file @
6089fd5d
$Module taskvar 3 Varnish taskvar Module
$Prefix taskvar
DESCRIPTION
===========
...
...
src/vmod_topvar.c
View file @
6089fd5d
...
...
@@ -109,5 +109,5 @@ state_l(VRT_CTX, void *v, size_t sz)
#define VMOD_TOPVAR_STRING_MAGIC (tv_magic | OBJVAR_STRING_MAGIC)
#define VMOD_TOPVAR_TIME_MAGIC (tv_magic | OBJVAR_TIME_MAGIC)
#define VCC_TYPE(TYPE, type) var_code(
VMOD_TOPVAR_, vmod
_topvar_, TYPE, type)
#define VCC_TYPE(TYPE, type) var_code(
topvar_, VMOD_TOPVAR_, topvar
_topvar_, TYPE, type)
#include "tbl_types.h"
src/vmod_topvar.rst
View file @
6089fd5d
...
...
@@ -8,9 +8,9 @@
.. _vmod_topvar(3):
===========
vmod
_topvar
===========
===========
==
topvar
_topvar
===========
==
---------------------
Varnish topvar Module
...
...
@@ -238,51 +238,7 @@ SYNOPSIS
DESCRIPTION
===========
This module implements `top` scoped variables as objects: Each client
request including all esi include levels (`top`) has its own view of
topvar variables.
The value of a topvar is the value assigned to it within any esi
subrequest or a default provided at construction time, if any.
topvars can be undefined. Attempts to ``.get`` an undefined value will
return a the ``.get`` method`s `fallback` argument, which in turn may
have a default for some cases.
topvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example::
import topvar;
sub vcl_init {
new xint = topvar.int();
}
sub vcl_recv {
if (req.esi_level == 0) {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
} else {
set req.http.fallback = xint.get(5); #42
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
CONTENTS
========
...
...
@@ -394,6 +350,54 @@ CONTENTS
* :ref:`func_time.undefine`
DESCRIPTION
===========
This module implements `top` scoped variables as objects: Each client
request including all esi include levels (`top`) has its own view of
topvar variables.
The value of a topvar is the value assigned to it within any esi
subrequest or a default provided at construction time, if any.
topvars can be undefined. Attempts to ``.get`` an undefined value will
return a the ``.get`` method`s `fallback` argument, which in turn may
have a default for some cases.
topvar variables can be protected against write access, in which case
any attempt to set them triggers a VCL failure at runtime.
Example::
import topvar;
sub vcl_init {
new xint = topvar.int();
}
sub vcl_recv {
if (req.esi_level == 0) {
set req.http.def = xint.defined(); # false
set req.http.fallback = xint.get(5); # 5
xint.set(42);
} else {
set req.http.fallback = xint.get(5); #42
}
}
sub vcl_deliver {
set resp.http.the-answer = xint.get(); # 42
}
The implementation of the various classes of this vmod is
auto-generated, and so is the documentation. Thus, the documentation
following this generic description is identical for all types except
for the respective type names and the ``.get()`` fallback.
.. just a newline
.. _obj_acl:
new xacl = topvar.acl([ACL init])
...
...
src/vmod_topvar.vcctpl
View file @
6089fd5d
$Module topvar 3 Varnish topvar Module
$Prefix topvar
DESCRIPTION
===========
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment