Fix: evaluate trigger condition on registration
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 23 Nov 2017 02:16:38 +0000 (21:16 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 26 Nov 2017 12:06:56 +0000 (13:06 +0100)
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>

No differences found
This page took 0.026772 seconds and 5 git commands to generate.