Open tdadela opened 2 weeks ago
I like what you're doing, but would prefer we rewrite it so that we compare the missing heartbeat count with HEARTBEAT_LIVENESS here: https://github.com/locustio/locust/blob/0a1a3d650f9568465e291463b5534e5277f4fd4c/locust/runners.py#L924 (instead of checking if it it below zero). Would that work? (that way we don't have to pass HEARTBEAT_LIVENESS around)
Do you think you could do that? We should probably rename the variable to .missed_heartbeats
and HEARTBEAT_LIVENESS to something like MAX_MISSED_HEARTBEATS or something...
Currently, the heartbeat_liveness parameter is used only to initialize value self.heartbeat. After receiving a heartbeat value is set to HEARTBEAT_LIVENESS:
c.heartbeat = HEARTBEAT_LIVENESS
.I guess that original motivation to add this parameter was to give possibility to adjust how many missing heartbeats WorkerNode is considered missing. To obtain this aim, value after regeneration should be equal to value passed to the constructor.
Another possible solution: complete removal of the heartbeat_liveness parameter from constructor.
Motivation behind change
self._local_worker_node = WorkerNode(id="local", heartbeat_liveness=HEARTBEAT_LIVENESS)
— default value of constructor parameter is evaluated during function creation but value HEARTBEAT_LIVENESS can change after that.