vmod_constant.rst 12.5 KB
Newer Older
1 2 3 4 5 6 7
..
.. NB:  This file is machine generated, DO NOT EDIT!
..
.. Edit vmod.vcc and run make instead
..


8
:tocdepth: 1
9

10
.. _vmod_constant(3):
11

Nils Goroll committed
12 13 14
=================================
VMOD constant - constants for VCL
=================================
15 16 17 18

SYNOPSIS
========

19
.. parsed-literal::
20

21
  import constant [from "path"]
22
  
Nils Goroll committed
23
  :ref:`vmod_constant.acl`
24
  
Nils Goroll committed
25
      :ref:`vmod_constant.acl.get`
26
  
Nils Goroll committed
27
      :ref:`vmod_constant.acl.defined`
28
  
Nils Goroll committed
29
  :ref:`vmod_constant.backend`
30
  
Nils Goroll committed
31
      :ref:`vmod_constant.backend.get`
32
  
Nils Goroll committed
33
      :ref:`vmod_constant.backend.defined`
34
  
Nils Goroll committed
35
  :ref:`vmod_constant.blob`
36
  
Nils Goroll committed
37
      :ref:`vmod_constant.blob.get`
38
  
Nils Goroll committed
39
      :ref:`vmod_constant.blob.defined`
40
  
Nils Goroll committed
41
  :ref:`vmod_constant.body`
42
  
Nils Goroll committed
43
      :ref:`vmod_constant.body.get`
44
  
Nils Goroll committed
45
      :ref:`vmod_constant.body.defined`
46
  
Nils Goroll committed
47
  :ref:`vmod_constant.bool`
48
  
Nils Goroll committed
49
      :ref:`vmod_constant.bool.get`
50
  
Nils Goroll committed
51
      :ref:`vmod_constant.bool.defined`
52
  
Nils Goroll committed
53
  :ref:`vmod_constant.bytes`
54
  
Nils Goroll committed
55
      :ref:`vmod_constant.bytes.get`
56
  
Nils Goroll committed
57
      :ref:`vmod_constant.bytes.defined`
58
  
Nils Goroll committed
59
  :ref:`vmod_constant.duration`
60
  
Nils Goroll committed
61
      :ref:`vmod_constant.duration.get`
62
  
Nils Goroll committed
63
      :ref:`vmod_constant.duration.defined`
64
  
Nils Goroll committed
65
  :ref:`vmod_constant.header`
66
  
Nils Goroll committed
67
      :ref:`vmod_constant.header.get`
68
  
Nils Goroll committed
69
      :ref:`vmod_constant.header.defined`
70
  
Nils Goroll committed
71
  :ref:`vmod_constant.int`
72
  
Nils Goroll committed
73
      :ref:`vmod_constant.int.get`
74
  
Nils Goroll committed
75
      :ref:`vmod_constant.int.defined`
76
  
Nils Goroll committed
77
  :ref:`vmod_constant.ip`
78
  
Nils Goroll committed
79
      :ref:`vmod_constant.ip.get`
80
  
Nils Goroll committed
81
      :ref:`vmod_constant.ip.defined`
82
  
Nils Goroll committed
83
  :ref:`vmod_constant.probe`
84
  
Nils Goroll committed
85
      :ref:`vmod_constant.probe.get`
86
  
Nils Goroll committed
87
      :ref:`vmod_constant.probe.defined`
88
  
Nils Goroll committed
89
  :ref:`vmod_constant.real`
90
  
Nils Goroll committed
91
      :ref:`vmod_constant.real.get`
92
  
Nils Goroll committed
93
      :ref:`vmod_constant.real.defined`
94
  
Nils Goroll committed
95
  :ref:`vmod_constant.stevedore`
96
  
Nils Goroll committed
97
      :ref:`vmod_constant.stevedore.get`
98
  
Nils Goroll committed
99
      :ref:`vmod_constant.stevedore.defined`
100
  
Nils Goroll committed
101
  :ref:`vmod_constant.string`
102
  
Nils Goroll committed
103
      :ref:`vmod_constant.string.get`
104
  
Nils Goroll committed
105
      :ref:`vmod_constant.string.defined`
106
  
Nils Goroll committed
107
  :ref:`vmod_constant.time`
108
  
Nils Goroll committed
109
      :ref:`vmod_constant.time.get`
110
  
Nils Goroll committed
111
      :ref:`vmod_constant.time.defined`
112
  
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
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

Nils Goroll committed
151
.. _vmod_constant.acl:
152 153 154 155 156 157 158 159

new xacl = constant.acl([ACL init])
-----------------------------------

Construct a(n) ACL constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
160
.. _vmod_constant.acl.get:
161 162 163 164 165 166 167

ACL xacl.get(ACL fallback)
--------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
168
.. _vmod_constant.acl.defined:
169 170 171 172 173 174

BOOL xacl.defined()
-------------------

Return whether the constant is defined.

Nils Goroll committed
175
.. _vmod_constant.backend:
176 177 178 179 180 181 182 183

new xbackend = constant.backend([BACKEND init])
-----------------------------------------------

Construct a(n) BACKEND constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
184
.. _vmod_constant.backend.get:
185 186 187 188 189 190 191

BACKEND xbackend.get(BACKEND fallback=0)
----------------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. The default fallback is no backend.

Nils Goroll committed
192
.. _vmod_constant.backend.defined:
193 194 195 196 197 198

BOOL xbackend.defined()
-----------------------

Return whether the constant is defined.

Nils Goroll committed
199
.. _vmod_constant.blob:
200 201 202 203 204 205 206 207

new xblob = constant.blob([BLOB init])
--------------------------------------

Construct a(n) BLOB constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
208
.. _vmod_constant.blob.get:
209 210 211 212 213 214 215

BLOB xblob.get(BLOB fallback)
-----------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
216
.. _vmod_constant.blob.defined:
217 218 219 220 221 222

BOOL xblob.defined()
--------------------

Return whether the constant is defined.

Nils Goroll committed
223
.. _vmod_constant.body:
224 225 226 227 228 229 230 231

new xbody = constant.body([BODY init])
--------------------------------------

Construct a(n) BODY constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
232
.. _vmod_constant.body.get:
233 234 235 236 237 238 239

BODY xbody.get(BODY fallback)
-----------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
240
.. _vmod_constant.body.defined:
241 242 243 244 245 246

BOOL xbody.defined()
--------------------

Return whether the constant is defined.

Nils Goroll committed
247
.. _vmod_constant.bool:
248 249 250 251 252 253 254 255

new xbool = constant.bool([BOOL init])
--------------------------------------

Construct a(n) BOOL constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
256
.. _vmod_constant.bool.get:
257 258 259 260 261 262 263

BOOL xbool.get(BOOL fallback)
-----------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
264
.. _vmod_constant.bool.defined:
265 266 267 268 269 270

BOOL xbool.defined()
--------------------

Return whether the constant is defined.

Nils Goroll committed
271
.. _vmod_constant.bytes:
272 273 274 275 276 277 278 279

new xbytes = constant.bytes([BYTES init])
-----------------------------------------

Construct a(n) BYTES constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
280
.. _vmod_constant.bytes.get:
281 282 283 284 285 286 287

BYTES xbytes.get(BYTES fallback)
--------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
288
.. _vmod_constant.bytes.defined:
289 290 291 292 293 294

BOOL xbytes.defined()
---------------------

Return whether the constant is defined.

Nils Goroll committed
295
.. _vmod_constant.duration:
296 297 298 299 300 301 302 303

new xduration = constant.duration([DURATION init])
--------------------------------------------------

Construct a(n) DURATION constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
304
.. _vmod_constant.duration.get:
305 306 307 308 309 310 311

DURATION xduration.get(DURATION fallback=0)
-------------------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. The default fallback is 0s.

Nils Goroll committed
312
.. _vmod_constant.duration.defined:
313 314 315 316 317 318

BOOL xduration.defined()
------------------------

Return whether the constant is defined.

Nils Goroll committed
319
.. _vmod_constant.header:
320 321 322 323 324 325 326 327

new xheader = constant.header([HEADER init])
--------------------------------------------

Construct a(n) HEADER constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
328
.. _vmod_constant.header.get:
329 330 331 332 333 334 335

HEADER xheader.get(HEADER fallback)
-----------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
336
.. _vmod_constant.header.defined:
337 338 339 340 341 342

BOOL xheader.defined()
----------------------

Return whether the constant is defined.

Nils Goroll committed
343
.. _vmod_constant.int:
344 345 346 347 348 349 350 351

new xint = constant.int([INT init])
-----------------------------------

Construct a(n) INT constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
352
.. _vmod_constant.int.get:
353 354 355 356 357 358 359

INT xint.get(INT fallback=0)
----------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. The default fallback is 0.

Nils Goroll committed
360
.. _vmod_constant.int.defined:
361 362 363 364 365 366

BOOL xint.defined()
-------------------

Return whether the constant is defined.

Nils Goroll committed
367
.. _vmod_constant.ip:
368 369 370 371 372 373 374 375

new xip = constant.ip([IP init])
--------------------------------

Construct a(n) IP constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
376
.. _vmod_constant.ip.get:
377 378 379 380 381 382 383

IP xip.get(IP fallback)
-----------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
384
.. _vmod_constant.ip.defined:
385 386 387 388 389 390

BOOL xip.defined()
------------------

Return whether the constant is defined.

Nils Goroll committed
391
.. _vmod_constant.probe:
392 393 394 395 396 397 398 399

new xprobe = constant.probe([PROBE init])
-----------------------------------------

Construct a(n) PROBE constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
400
.. _vmod_constant.probe.get:
401 402 403 404 405 406 407

PROBE xprobe.get(PROBE fallback)
--------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
408
.. _vmod_constant.probe.defined:
409 410 411 412 413 414

BOOL xprobe.defined()
---------------------

Return whether the constant is defined.

Nils Goroll committed
415
.. _vmod_constant.real:
416 417 418 419 420 421 422 423

new xreal = constant.real([REAL init])
--------------------------------------

Construct a(n) REAL constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
424
.. _vmod_constant.real.get:
425 426 427 428 429 430 431

REAL xreal.get(REAL fallback=0.0)
---------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. The default fallback is 0.0.

Nils Goroll committed
432
.. _vmod_constant.real.defined:
433 434 435 436 437 438

BOOL xreal.defined()
--------------------

Return whether the constant is defined.

Nils Goroll committed
439
.. _vmod_constant.stevedore:
440 441 442 443 444 445 446 447

new xstevedore = constant.stevedore([STEVEDORE init])
-----------------------------------------------------

Construct a(n) STEVEDORE constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
448
.. _vmod_constant.stevedore.get:
449 450 451 452 453 454 455

STEVEDORE xstevedore.get(STEVEDORE fallback)
--------------------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. 

Nils Goroll committed
456
.. _vmod_constant.stevedore.defined:
457 458 459 460 461 462

BOOL xstevedore.defined()
-------------------------

Return whether the constant is defined.

Nils Goroll committed
463
.. _vmod_constant.string:
464 465 466 467 468 469 470 471

new xstring = constant.string([STRING init])
--------------------------------------------

Construct a(n) STRING constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
472
.. _vmod_constant.string.get:
473 474 475 476 477 478 479

STRING xstring.get(STRING fallback=0)
-------------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. The default fallback is the empty string.

Nils Goroll committed
480
.. _vmod_constant.string.defined:
481 482 483 484 485 486

BOOL xstring.defined()
----------------------

Return whether the constant is defined.

Nils Goroll committed
487
.. _vmod_constant.time:
488 489 490 491 492 493 494 495

new xtime = constant.time([TIME init])
--------------------------------------

Construct a(n) TIME constant with the value `init`,
if provided. If no `init` value is provided, the constant
will be undefined.

Nils Goroll committed
496
.. _vmod_constant.time.get:
497 498 499 500 501 502 503

TIME xtime.get(TIME fallback=0)
-------------------------------

Return the value of the constant or the `fallback` argument
if it is undefined. The default fallback is the epoch (1970/1/1 0:00:00 GMT).

Nils Goroll committed
504
.. _vmod_constant.time.defined:
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543

BOOL xtime.defined()
--------------------

Return whether the constant is defined.

SEE ALSO
========

vcl\(7),varnishd\(1)

COPYRIGHT
=========

::

  Copyright 2018 UPLEX Nils Goroll Systemoptimierung
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  1. Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
  
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  SUCH DAMAGE.