-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
GetGraph (lines 265–397) and GetCircularDependencies (lines 399–534) in internal/api/client.go each contain ~130 lines of near-identical async polling logic. Both methods:
- Build a multipart request body
- Generate an idempotency key
- Poll in a loop, checking
ctx.Done(), a deadline, andmaxPollAttempts - Handle HTTP status codes identically (401, 402, 429, 404/405, 200/202, default)
- Parse a
JobStatusenvelope and branch oncompleted/failed/pending/processing - Sleep for
retryAfterseconds between attempts
Only the endpoint URL and the result-parsing step differ.
Impact
Any change to retry behavior, backoff, or error handling must be made in two places. This has already diverged subtly (e.g. 404/405 is only handled in GetCircularDependencies).
Proposed Fix
Extract a pollJob helper that accepts endpoint URL, the pre-built multipart body/content-type, and a parseResult func(*json.RawMessage) error callback. Both public methods become thin wrappers:
func (c *Client) pollJob(
ctx context.Context,
endpoint string,
bodyBytes []byte,
contentType string,
idempotencyKey string,
onComplete func(*json.RawMessage) error,
notFound func() error,
) errorFiles
internal/api/client.golines 265–534
@claude please implement this
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request