vmod_constant(3)
π vmod_constant β constants for VCL π
okay bestie, gather round, because today we're talking about vmod_constant(3), a manual page from the Library Functions Manual, and honestly? it's giving "set it once, use it everywhere" and I'm obsessed. π
β¨ SYNOPSIS β¨
import constant [as name] [from "path"]
new xacl = constant.acl([ACL init])
ACL xacl.get([ACL fallback])
BOOL xacl.defined()
new xbackend = constant.backend([BACKEND init])
BACKEND xbackend.get([BACKEND fallback])
BOOL xbackend.defined()
new xblob = constant.blob([BLOB init])
BLOB xblob.get([BLOB fallback])
BOOL xblob.defined()
new xbody = constant.body([BODY init])
BODY xbody.get([BODY fallback])
BOOL xbody.defined()
new xbool = constant.bool([BOOL init])
BOOL xbool.get([BOOL fallback])
BOOL xbool.defined()
new xbytes = constant.bytes([BYTES init])
BYTES xbytes.get([BYTES fallback])
BOOL xbytes.defined()
new xduration = constant.duration([DURATION init])
DURATION xduration.get([DURATION fallback])
BOOL xduration.defined()
new xheader = constant.header([HEADER init])
HEADER xheader.get([HEADER fallback])
BOOL xheader.defined()
new xint = constant.int([INT init])
INT xint.get([INT fallback])
BOOL xint.defined()
new xip = constant.ip([IP init])
IP xip.get([IP fallback])
BOOL xip.defined()
new xprobe = constant.probe([PROBE init])
PROBE xprobe.get([PROBE fallback])
BOOL xprobe.defined()
new xreal = constant.real([REAL init])
REAL xreal.get([REAL fallback])
BOOL xreal.defined()
new xstevedore = constant.stevedore([STEVEDORE init])
STEVEDORE xstevedore.get([STEVEDORE fallback])
BOOL xstevedore.defined()
new xstring = constant.string([STRING init])
STRING xstring.get([STRING fallback])
BOOL xstring.defined()
new xtime = constant.time([TIME init])
TIME xtime.get([TIME fallback])
BOOL xtime.defined()
π DESCRIPTION π
so this module implements globally (per vcl) scoped constants as objects, meaning likeβ¦ all vcl subroutines have the same view on constants. everyone sees the same thing. no cap. π
the value of a constant is the value assigned to it at construction time, if any.
constants are undefined if no value is assigned in the constructor. it's giving "you didn't show up with a value so you get nothing".
attempts to .get() an undefined value will return the .get() method's fallback argument. for most types there's a default fallback; and if there isn't one? using .get() on an undefined value triggers a VCL failure at runtime. so like, don't. π
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
}
lowkey iconic. π
heads up bestie: the implementation of the various classes of this vmod is auto-generated, and so is the documentation. so everything below this generic description is literally identical for all types except for the respective type names and the .get() fallback. don't come for me, I'm just the messenger. π
π¦ 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.
π¦ ACL xacl.get([ACL fallback])
return the value of the constant, or the fallback argument if it is undefined. using .get() on an undefined value without a fallback triggers a VCL error. no default fallback here, so bring your own or perish. π
π¦ BOOL xacl.defined()
return whether the constant is defined. simple as.
π 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.
π BACKEND xbackend.get([BACKEND fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is the None backend.
π BOOL xbackend.defined()
return whether the constant is defined.
π§ 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.
π§ BLOB xblob.get([BLOB fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is the null blob.
π§ BOOL xblob.defined()
return whether the constant is defined.
πΈ 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.
πΈ BODY xbody.get([BODY fallback])
return the value of the constant, or the fallback argument if it is undefined. using .get() on an undefined value without a fallback triggers a VCL error. yeah, no default. watch yourself. π
πΈ BOOL xbody.defined()
return whether the constant is defined.
β 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.
β BOOL xbool.get([BOOL fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is false
β BOOL xbool.defined()
return whether the constant is defined.
π 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.
π BYTES xbytes.get([BYTES fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is 0 bytes.
π BOOL xbytes.defined()
return whether the constant is defined.
π 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.
π DURATION xduration.get([DURATION fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is 0s.
π BOOL xduration.defined()
return whether the constant is defined.
π«Ά 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.
π«Ά HEADER xheader.get([HEADER fallback])
return the value of the constant, or the fallback argument if it is undefined. using .get() on an undefined value without a fallback triggers a VCL error. again β no default. the audacity, right? π
π«Ά BOOL xheader.defined()
return whether the constant is defined.
π₯ 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.
π₯ INT xint.get([INT fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is 0.
π₯ BOOL xint.defined()
return whether the constant is defined.
π 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.
π IP xip.get([IP fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is IPv4 0.0.0.0.
π BOOL xip.defined()
return whether the constant is defined.
π¦ 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.
π¦ PROBE xprobe.get([PROBE fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is no backend.
π¦ BOOL xprobe.defined()
return whether the constant is defined.
π 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.
π REAL xreal.get([REAL fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is 0.0.
π BOOL xreal.defined()
return whether the constant is defined.
π§ 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.
π§ STEVEDORE xstevedore.get([STEVEDORE fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is the default storage.
π§ BOOL xstevedore.defined()
return whether the constant is defined.
πΈ 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.
πΈ STRING xstring.get([STRING fallback])
return the value of the constant, or the fallback argument if it is undefined. the default fallback is the empty string.
πΈ BOOL xstring.defined()
return whether the constant is defined.
β 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.
β TIME xtime.get([TIME fallback])
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). throwback fr fr. π°οΈ
β BOOL xtime.defined()
return whether the constant is defined.
π SEE ALSO π
π COPYRIGHT π
Copyright 2018-2022 UPLEX Nils Goroll Systemoptimierung
redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 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 COPYRIGHT HOLDERS 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 THE COPYRIGHT HOLDER 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.
and that's the whole page bestie, vmod_constant(3) from the Library Functions Manual, copyright 2018-2022 UPLEX Nils Goroll Systemoptimierung β go forth and be the main character of your own VCL π
β¨π«Ά
π¦ where this page comes from
- ubuntu stonking: libvmod-objvar 0.0~git20260330-3 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms