-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
The gotask API list is defined in two separate locations with similar but slightly different metadata:
1. internal/apis.go - RegisterGotaskAPIs() (lines 71-89)
- Purpose: Used by spawnerlabel checker for spawner label validation
- Called from:
analyzer.go:123 - Data structure:
registry.EntrywithAlwaysSpawnsfield - APIs registered: DoAll, DoAllSettled, DoRace, DoAllFns, DoAllFnsSettled, DoRaceFns, Task.DoAsync, CancelableTask.DoAsync
2. internal/checkers/gotask.go - GotaskChecker.entries (lines 53-65)
- Purpose: Used by gotask checker for context propagation validation
- Called from:
analyzer.go:196-200 - Data structure:
gotaskEntrywithVariadicandIsDoAsyncfields - APIs registered: Same list as above
Issues
- DRY violation: The same API set is maintained in two places
- Maintenance burden: Adding/removing gotask APIs requires changes in both locations
- Inconsistency risk: The two lists could drift apart over time
Key Differences
While both define the same API set, they have different metadata requirements:
| Aspect | RegisterGotaskAPIs | GotaskChecker.entries |
|---|---|---|
| DoAsync CallbackArgIdx | Not specified | 0 (explicit) |
| Metadata fields | AlwaysSpawns | Variadic, IsDoAsync |
| Purpose | Spawner label detection | Context propagation checking |
Proposed Solution
Create a unified gotask API registry that both checkers can consume:
- Define a single source of truth for gotask APIs (e.g.,
internal/gotask/apis.go) - Provide adapter functions to convert to checker-specific formats:
ToRegistryEntries()→ for spawnerlabel checkerToGotaskEntries()→ for gotask checker
- Update both checkers to use the unified registry
This would maintain flexibility for checker-specific metadata while eliminating duplication.
Alternative
If the metadata requirements are too divergent, document why the duplication is necessary and add validation to ensure both lists stay in sync.
Metadata
Metadata
Assignees
Labels
No labels