temporalio / temporalio/temporal
Worker heartbeat
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.2k
- Forks
- 1.9k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 228
Description
Is your feature request related to a problem? Please describe.
An issue that has come up a few times in the community slack is auto-activity heartbeats.
A lot of the time heartbeats are used just to verify that the activity is still running on a Worker or there might not be a simple way to heartbeat from the activity logic in a timely manner so heartbeats are implemented "externally" as follows:
async function autoheartbeat(fn) {
async function heartbeat() {
const cx = activity.Context.current();
for (;;) {
await cx.sleep(cx.info.heartbeatTimeout / 2);
cx.heartbeat();
}
}
return (...args) => Promise.race([heartbeat(), fn(...args)]);
}
export const myActivity = autoheartbeat(async (arg1, arg2) => {
// activity logic
});
Describe the solution you'd like
Add support for Worker heartbeat so activities automatically failover to a new Worker if the current executing Worker goes down.
Describe alternatives you've considered
A trivial alternative is to ask users to wrap their activity function in an "autoheartbeat" wrapper as shown above or add SDK support for auto activity heartbeat.
Per-activity heartbeat is noisier than Worker heartbeat so it'd be better if we supported Worker heartbeats.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Worker heartbeat proposal and the existing per-activity heartbeat behavior described in the issue. Trace how a Worker currently reports activity liveness and how failover is triggered. Done means activities can fail over when their executing Worker goes down without requiring users to add an autoheartbeat wrapper.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100