taskflow: run extensions through one dispatcher and tell them which phase they run in

Đang mở
#396 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mushrafmim đang làm issue này rồi.

Từ ngày 9/11/2026.

  • #397 của @mushrafmim — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Type/Improvement
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_RESUME always runs in a bare goroutine. A host can't bound its concurrency, recover its panics, or run it inline in tests, which currently need a WaitGroup to 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 to Execute, read with extensions.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. TaskExtension is unchanged.
  • orchestrator.Dispatcher (with a DispatcherFunc adapter) runs notify phases, set with WithDispatcher. 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.

Ngôn ngữ chính
Go
Star
6
Fork
8
Merge trung bình
21 giờ 36 phút
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenNSW/core

Tất cả issue của OpenNSW/core

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.