MEDIUM: stream: support use-server rules with dynamic names
authorJerome Magnin <jmagnin@haproxy.com>
Sun, 29 Mar 2020 07:37:12 +0000 (09:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 29 Mar 2020 07:55:10 +0000 (09:55 +0200)
commit824186bb087250089b80862ccb56d3971af6a2d2
tree57038787ee2435e6da10c68304a2c41524341558
parenteb421b2fe08ff2cfda1a38138591b8cca303f771
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.
doc/configuration.txt
include/types/arg.h
include/types/proxy.h
src/cfgparse-listen.c
src/cfgparse.c
src/stream.c