Commit ce59124f authored by Nils Goroll's avatar Nils Goroll

shard: replace magic defaults with optional arguments

parent ee25c1b5
...@@ -656,8 +656,7 @@ shardcfg_get_rampup(const struct sharddir *shardd, int host) ...@@ -656,8 +656,7 @@ shardcfg_get_rampup(const struct sharddir *shardd, int host)
// assert sharddir_rdlock_held(shardd); // assert sharddir_rdlock_held(shardd);
assert (host < shardd->n_backend); assert (host < shardd->n_backend);
// magic value for default if (isnan(shardd->backend[host].rampup))
if (shardd->backend[host].rampup == 973279260)
r = shardd->rampup_duration; r = shardd->rampup_duration;
else else
r = shardd->backend[host].rampup; r = shardd->backend[host].rampup;
......
...@@ -368,7 +368,7 @@ The association can be changed per backend request using the `param` ...@@ -368,7 +368,7 @@ The association can be changed per backend request using the `param`
argument of `func_shard.backend`_. argument of `func_shard.backend`_.
$Method BOOL .add_backend(PRIV_TASK, BACKEND backend, $Method BOOL .add_backend(PRIV_TASK, BACKEND backend,
STRING ident=0, DURATION rampup=973279260) [STRING ident], [DURATION rampup])
Add a backend `backend` to the director. Add a backend `backend` to the director.
...@@ -380,13 +380,13 @@ backend name. ...@@ -380,13 +380,13 @@ backend name.
`ident` allows to add multiple instances of the same backend. `ident` allows to add multiple instances of the same backend.
`rampup`: Optionally specify a specific rampup time for this `rampup`: Optionally specify a specific rampup time for this
backend. The magic default value of `973279260s` instructs the shard backend. Otherwise, the per-director rampup time is used (see
director to use the default rampup time (see :ref:`func_shard.set_rampup`). :ref:`func_shard.set_rampup`).
NOTE: Backend changes need to be finalized with `shard.reconfigure()` NOTE: Backend changes need to be finalized with `shard.reconfigure()`
and are only supported on one shard director at a time. and are only supported on one shard director at a time.
$Method BOOL .remove_backend(PRIV_TASK, BACKEND backend=0, STRING ident=0) $Method BOOL .remove_backend(PRIV_TASK, [BACKEND backend=0], [STRING ident=0])
Remove backend(s) from the director. Either `backend` or `ident` must Remove backend(s) from the director. Either `backend` or `ident` must
be specified. `ident` removes a specific instance. If `backend` is be specified. `ident` removes a specific instance. If `backend` is
......
...@@ -297,26 +297,29 @@ vmod_shard_associate(VRT_CTX, ...@@ -297,26 +297,29 @@ vmod_shard_associate(VRT_CTX,
VCL_BOOL v_matchproto_(td_directors_shard_add_backend) VCL_BOOL v_matchproto_(td_directors_shard_add_backend)
vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard, vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard,
struct vmod_priv *priv, struct vmod_shard_add_backend_arg *args)
VCL_BACKEND be, VCL_STRING ident, VCL_DURATION rampup)
{ {
CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC); CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC);
if (be == NULL) { if (args->backend == NULL) {
shard_err0(ctx, vshard->shardd, shard_err0(ctx, vshard->shardd,
".backend_add() NULL backend given"); ".backend_add() NULL backend given");
return 0; return (0);
} }
return shardcfg_add_backend(ctx, priv, vshard->shardd, return shardcfg_add_backend(ctx, args->arg1,
be, ident, rampup); vshard->shardd, args->backend,
args->valid_ident ? args->ident : NULL,
args->valid_rampup ? args->rampup : nan(""));
} }
VCL_BOOL v_matchproto_(td_directors_shard_remove_backend) VCL_BOOL v_matchproto_(td_directors_shard_remove_backend)
vmod_shard_remove_backend(VRT_CTX, struct vmod_directors_shard *vshard, vmod_shard_remove_backend(VRT_CTX, struct vmod_directors_shard *vshard,
struct vmod_priv *priv, struct vmod_shard_remove_backend_arg *args)
VCL_BACKEND be, VCL_STRING ident)
{ {
VCL_BACKEND be = args->valid_backend ? args->backend : NULL;
VCL_STRING ident = args->ident ? args->ident : NULL;
CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC); CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC);
if (be == NULL && ident == NULL) { if (be == NULL && ident == NULL) {
...@@ -326,7 +329,7 @@ vmod_shard_remove_backend(VRT_CTX, struct vmod_directors_shard *vshard, ...@@ -326,7 +329,7 @@ vmod_shard_remove_backend(VRT_CTX, struct vmod_directors_shard *vshard,
return 0; return 0;
} }
return shardcfg_remove_backend(ctx, priv, vshard->shardd, return shardcfg_remove_backend(ctx, args->arg1, vshard->shardd,
be, ident); be, ident);
} }
......
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