taskflow: run extensions through one dispatcher and tell them which phase they run in
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
Start with the two call sites that run extensions, CompleteTaskStep and SaveDraft, and the stopOnError and go func() logic they each duplicate. The issue asks for an extensions.Invocation context value, an orchestrator.Dispatcher with WithDispatcher, and an internal fire that handles guard and notify phases. Work is already under way in open PR #397, so coordinate there before starting. Done means both existing phases behave as before and POST_RESUME goes through the dispatcher.
Written by the indexing model from the issue text.
Description
Current Limitation
The orchestrator runs extensions from two call sites, CompleteTaskStep and SaveDraft. Each call site deep-copies the record and payload itself, and each decides for itself whether the run blocks or is asynchronous, using a stopOnError bool and a hand-written go func(). Adding the lifecycle phases in #395 this way would copy that logic into every new call site.
It also leaves two gaps:
- An extension can't tell which phase it is running in, or recognise a repeat of an event it already handled.
POST_RESUMEalways runs in a bare goroutine. A host can't bound its concurrency, recover its panics, or run it inline in tests, which currently need aWaitGroupto wait for it.
Suggested Improvement
Route every extension run through one dispatcher, with no behaviour change for the two existing phases:
extensions.Invocation{Phase, IdempotencyKey}on the context passed toExecute, read withextensions.InvocationFrom(ctx). The key is<task id>/<step id>/<seq>/<phase>and names the run of the step, whatever seq the row has moved on to.TaskExtensionis unchanged.orchestrator.Dispatcher(with aDispatcherFuncadapter) runs notify phases, set withWithDispatcher. The default is one goroutine per dispatch, as today.- An internal
fire(phase, …)looks up the phase's policy. A guard (PRE_RESUME) runs inline and returns the first error. A notify (POST_RESUME) is handed to the dispatcher with a context that is never cancelled. Deep copies are made in one place.
Version
53b0bd3
Additional Context
This is PR 1 of the rollout in #395. Telling a draft save apart from a submission (#327) stays separate.
- Dominant language
- Go
- Stars
- 6
- Forks
- 8
- Avg merge
- 21h 36m
- Merged PRs (30d)
- 42
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from OpenNSW/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
payment: test fixtures hardcode real gateway names (govpay/lankapay) instead of generic placeholdersOpen
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
nsw-sl cleanup Type/Improvement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
remote: let the host inject a logger, and log with one consistent policyPossibly taken @mushrafmim claimed this 5 days ago. OpenType/Improvement
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 1 day
Similar issues
-
☢️ Bug v3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area/import-export area/projects concern/ux
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
go-vikunja/vikunja#4455 · 1 comment ·
Maintainers usually reply within 2 days
-
Dependabot PRs no longer merge automaticallyPossibly taken @dwisiswant0 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
projectdiscovery/urlfinder#160 ·
Maintainers usually reply within 1 day
-
database
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
chnm/legal-modernism#450 ·
Maintainers usually reply within 1 day
-
tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day