Can we call heartbeat like this
activity.RecordHeartbeat(ctx)
so that only lastHeartbeatTime is updated and the details of any previous heartbeat remains unchanged?
Can we call heartbeat like this
activity.RecordHeartbeat(ctx)
so that only lastHeartbeatTime is updated and the details of any previous heartbeat remains unchanged?
Heartbeat is throttled by the SDK to avoid excessive load on the service. It emits calls every 4/5 of workflow heartbeat timeout. So make sure to set the heartbeat timeout to an appropriate value when calling the RecordHeartbeat API.
Thanks Maxim. So if I call
beenHere := true
activity.RecordHeartbeat(ctx, beenHere)
activity.RecordHeartbeat(ctx) // does this clear the heartbeat details or not?
And then fail that activity, on the next retry attempt will heartbeat details always be true?
It depends. It can be that the first RecordHeartbeat is sent to the service and the second one is throttled waiting for the next RecordHeartbeat call. If it never comes and the activity fails before the 4/5 of the heartbeat timeout then the second call might never reach the service.
Thanks Maxim. Based on that response then it seems like an activity based on the example here could repeat some work.
And then the heartbeat shouldn’t be used to guard against doing some bit or work twice. Is this understanding correct?
There is no bullet proof way to prohibit activity from doing the same work twice in the heartbeating scenario. Even if every activity state change is recorded through heartbeat. For example, an activity can execute a state change and then crash before a heartbeat is recorded.