MEDIUM: stream: support use-server rules with dynamic names
With server-template was introduced the possibility to scale the
number of servers in a backend without needing a configuration change
and associated reload. On the other hand it became impractical to
write use-server rules for these servers as they would only accept
existing server labels as argument. This patch allows the use of
log-format notation to describe targets of a use-server rules, such
as in the example below:
listen test
bind *:1234
use-server %[hdr(srv)] if { hdr(srv) -m found }
use-server s1 if { path / }
server s1 127.0.0.1:18080
server s2 127.0.0.1:18081
If a use-server rule is applied because it was conditionned by an
ACL returning true, but the target of the use-server rule cannot be
resolved, no other use-server rule is evaluated and we fall back to
load balancing.
This feature was requested on the ML, and bumped with issue #563.
diff --git a/include/types/arg.h b/include/types/arg.h
index a9778f2..80e0b0a 100644
--- a/include/types/arg.h
+++ b/include/types/arg.h
@@ -81,6 +81,7 @@
ARGC_SRV, /* server line */
ARGC_SPOE, /* spoe message args */
ARGC_UBK, /* use_backend message */
+ ARGC_USRV, /* use-server message */
};
/* flags used when compiling and executing regex */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index a3da428..84ac8d0 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -509,10 +509,14 @@
struct server_rule {
struct list list; /* list linked to from the proxy */
struct acl_cond *cond; /* acl condition to meet */
+ int dynamic;
union {
struct server *ptr; /* target server */
char *name; /* target server name during config parsing */
} srv;
+ struct list expr; /* logformat expression to use for dynamic rules */
+ char *file;
+ int line;
};
struct persist_rule {