Use $Restrict

parent a0138368
...@@ -314,13 +314,6 @@ vmod_cluster__fini(struct vmod_cluster_cluster **vcp) ...@@ -314,13 +314,6 @@ vmod_cluster__fini(struct vmod_cluster_cluster **vcp)
} }
#define cluster_methods (VCL_MET_INIT | VCL_MET_BACKEND_FETCH) #define cluster_methods (VCL_MET_INIT | VCL_MET_BACKEND_FETCH)
#define cluster_check(ctx, name, ret) do { \
if ((ctx->method & cluster_methods) == 0) { \
VRT_fail(ctx, \
"cluster." #name " can not be called here"); \
return ret; \
} \
} while(0)
VCL_VOID VCL_VOID
vmod_cluster_deny(VRT_CTX, vmod_cluster_deny(VRT_CTX,
...@@ -329,7 +322,7 @@ vmod_cluster_deny(VRT_CTX, ...@@ -329,7 +322,7 @@ vmod_cluster_deny(VRT_CTX,
const struct vmod_cluster_cluster_param *pr; const struct vmod_cluster_cluster_param *pr;
struct vmod_cluster_cluster_param *pl; struct vmod_cluster_cluster_param *pl;
cluster_check(ctx, deny, ); AN(ctx->method & cluster_methods);
CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC);
...@@ -348,7 +341,7 @@ vmod_cluster_allow(VRT_CTX, ...@@ -348,7 +341,7 @@ vmod_cluster_allow(VRT_CTX,
const struct vmod_cluster_cluster_param *pr; const struct vmod_cluster_cluster_param *pr;
struct vmod_cluster_cluster_param *pl; struct vmod_cluster_cluster_param *pl;
cluster_check(ctx, allow, ); AN(ctx->method & cluster_methods);
CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC);
...@@ -366,7 +359,7 @@ vmod_cluster_is_denied(VRT_CTX, ...@@ -366,7 +359,7 @@ vmod_cluster_is_denied(VRT_CTX,
{ {
const struct vmod_cluster_cluster_param *pr; const struct vmod_cluster_cluster_param *pr;
cluster_check(ctx, is_denied, 0); AN(ctx->method & cluster_methods);
CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC);
pr = cluster_task_param_r(ctx, vc); pr = cluster_task_param_r(ctx, vc);
...@@ -391,7 +384,7 @@ vmod_cluster_get_cluster(VRT_CTX, struct vmod_cluster_cluster *vc) ...@@ -391,7 +384,7 @@ vmod_cluster_get_cluster(VRT_CTX, struct vmod_cluster_cluster *vc)
const struct vmod_cluster_cluster_param *pr; \ const struct vmod_cluster_cluster_param *pr; \
struct vmod_cluster_cluster_param *pl; \ struct vmod_cluster_cluster_param *pl; \
\ \
cluster_check(ctx, set_ ## att, ); \ AN(ctx->method & cluster_methods); \
\ \
CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); \ CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); \
\ \
...@@ -408,7 +401,7 @@ vmod_cluster_get_cluster(VRT_CTX, struct vmod_cluster_cluster *vc) ...@@ -408,7 +401,7 @@ vmod_cluster_get_cluster(VRT_CTX, struct vmod_cluster_cluster *vc)
#define CLUSTER_R(ctx, vc, att, ret) \ #define CLUSTER_R(ctx, vc, att, ret) \
const struct vmod_cluster_cluster_param *pr; \ const struct vmod_cluster_cluster_param *pr; \
\ \
cluster_check(ctx, get_ ## att, ret); \ AN(ctx->method & cluster_methods); \
\ \
CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); \ CHECK_OBJ_NOTNULL(vc, VMOD_CLUSTER_CLUSTER_MAGIC); \
\ \
......
...@@ -104,6 +104,8 @@ The :ref:`obj_cluster` object methods other than ...@@ -104,6 +104,8 @@ The :ref:`obj_cluster` object methods other than
:ref:`func_cluster.backend` behave differently depending on the :ref:`func_cluster.backend` behave differently depending on the
context they are being called from: context they are being called from:
* Use is restricted to ``vcl_init{}`` and ``vcl_backend_fetch{}``.
* When used in ``vcl_init{}``, they change or return the director's * When used in ``vcl_init{}``, they change or return the director's
default. default.
...@@ -115,9 +117,6 @@ context they are being called from: ...@@ -115,9 +117,6 @@ context they are being called from:
irrespecitve of being called before or after the irrespecitve of being called before or after the
:ref:`func_cluster.backend` method. :ref:`func_cluster.backend` method.
* Use in vcl subs other than ``vcl_init{}`` and
``vcl_backend_fetch{}`` is invalid and will trigger a VCL error.
:ref:`func_cluster.backend` has slightly different, specifically :ref:`func_cluster.backend` has slightly different, specifically
documented limitations. documented limitations.
...@@ -145,6 +144,8 @@ $Method VOID .deny(BACKEND) ...@@ -145,6 +144,8 @@ $Method VOID .deny(BACKEND)
Add a backend to the list of backends for which the cluster director Add a backend to the list of backends for which the cluster director
will resolve to a `real` backend (the blacklist). will resolve to a `real` backend (the blacklist).
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method VOID .allow(BACKEND) $Method VOID .allow(BACKEND)
...@@ -152,6 +153,8 @@ $Method VOID .allow(BACKEND) ...@@ -152,6 +153,8 @@ $Method VOID .allow(BACKEND)
Remove a backend to the list of backends for which the cluster Remove a backend to the list of backends for which the cluster
director will resolve to a `real` backend (the blacklist). director will resolve to a `real` backend (the blacklist).
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method BOOL .is_denied(BACKEND) $Method BOOL .is_denied(BACKEND)
...@@ -159,12 +162,16 @@ $Method BOOL .is_denied(BACKEND) ...@@ -159,12 +162,16 @@ $Method BOOL .is_denied(BACKEND)
Return true if the argument is on list of backends for which the Return true if the argument is on list of backends for which the
cluster director will resolve to a `real` backend (the blacklist). cluster director will resolve to a `real` backend (the blacklist).
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method VOID .set_real(BACKEND) $Method VOID .set_real(BACKEND)
Change the real backend. Change the real backend.
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method BACKEND .get_cluster() $Method BACKEND .get_cluster()
...@@ -175,6 +182,8 @@ $Method BACKEND .get_real() ...@@ -175,6 +182,8 @@ $Method BACKEND .get_real()
Return the currently configured real backend. Return the currently configured real backend.
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method VOID .set_uncacheable_direct(BOOL) $Method VOID .set_uncacheable_direct(BOOL)
...@@ -184,12 +193,16 @@ for uncacheable backend requests (e.g. passes or cache lookups hitting ...@@ -184,12 +193,16 @@ for uncacheable backend requests (e.g. passes or cache lookups hitting
hit-for-pass). For a ``false`` argument, no difference is made with hit-for-pass). For a ``false`` argument, no difference is made with
regard to the cacheability of the backend request. regard to the cacheability of the backend request.
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method BOOL .get_uncacheable_direct() $Method BOOL .get_uncacheable_direct()
Return the currently configured behaviour. Return the currently configured behaviour.
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method VOID .set_direct(BOOL) $Method VOID .set_direct(BOOL)
...@@ -199,11 +212,14 @@ always. ...@@ -199,11 +212,14 @@ always.
A ``false`` argument restores the original behavior. A ``false`` argument restores the original behavior.
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
$Method BOOL .get_direct() $Method BOOL .get_direct()
Return the current `direct` value as set with :ref:`func_cluster.get_direct`. Return the current `direct` value as set with :ref:`func_cluster.get_direct`.
$Restrict vcl_init vcl_backend_fetch
See :ref:`meth_ctx` for limitations. See :ref:`meth_ctx` for limitations.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment