Replies: 1 comment 3 replies
-
I'm pretty sure I'm missing something, but couldn't you:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have defined two disjoint pools of server: the
default
pool and thestateful
pool.I redirect part of the incoming DNS traffic to the
stateful
pull (e.g. based on client source IP) usingaddAction(NetmaskGroupRule(...), PoolAction('stateful'))
.I am now trying to build a custom Lua server policy, as follows:
stateful
pool, use a hash of the client source IP to select an up-and-running server in thestateful
pool;default
pool or there is no up-and-running server in thestateful
pool, use theleastOutstanding
policy on thedefault
pool.I can create a list of up-and-running servers in the
stateful
pool and select a server based on client source IP (using thedjb2
hash:However, it is really complex to determine whether the traffic is intended for the
stateful
or thedefault
pool.As only the list of servers is passed to
ServerPolicy.policy()
, this would imply to:ServerPolicy.policy()
As Lua doesn't seem to have a proper array comparison function, we are already down to three nested loops (high order of computational complexity).
Hence my suggestion to pass a reference to the pool (instead of the servers list) for the current incoming query to ServerPolicy.policy(). This would allow to solve the aforementioned elegantly, and the getting the list of servers could also be available using
getPoolServers()
.To maintain backward compatibility, maybe this could require a new
ServerPolicy.policyFromPool()
method, along with newsetServerPolicyFromPool*
functions.I am also interested in any other solution that may make this suggestion irrelevant while still fulfilling my objective ;-)
Beta Was this translation helpful? Give feedback.
All reactions