Fix: evaluate trigger condition on registration
Since there is nothing preventing clients from subscribing to a
condition before the corresponding trigger is registered, we have
to evaluate this new condition right away.
The current implementation is waiting for the next "evaluation" of
conditions (e.g. on reception of a channel sample) to evaluate this
newly registered trigger conditions, but this is broken.
The reason it is broken is that waiting for the next sample
does not allow us to properly handle transitions for edge-triggered
conditions.
Consider this example: when we handle a new channel sample, we
evaluate each conditions twice: once with the previous state, and
again with the newest state. We then use those two results to
determine whether a state change happened: a condition was false and
became true. If a state change happened, we have to notify clients.
Now, if a client subscribes to a given notification and registers
a trigger *after* that subscription, we have to make sure the
condition is evaluated at this point while considering only the
current state. Otherwise, the next evaluation cycle may only see
that the evaluations remain the same (true for samples n-1 and n) and
the client will never know that the condition has been met.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.02615 seconds and 4 git commands to generate.