Skip to content

refactor: extract shared polling loop into pollJob helper#45

Merged
claude[bot] merged 1 commit intomainfrom
claude/issue-41-20260227-0442
Feb 27, 2026
Merged

refactor: extract shared polling loop into pollJob helper#45
claude[bot] merged 1 commit intomainfrom
claude/issue-41-20260227-0442

Conversation

@claude
Copy link
Contributor

@claude claude bot commented Feb 27, 2026

Summary

  • Extracted buildMultipartBody to eliminate the duplicated multipart body construction in GetGraph and GetCircularDependencies
  • Extracted pollJob method containing all shared async polling logic: deadline/attempt checks, HTTP request dispatch, status-code handling, JobStatus envelope parsing, and retry sleep
  • GetGraph and GetCircularDependencies are now thin wrappers (~15 lines each) that build the request body and pass an onComplete callback to pollJob
  • The 404/405 case (previously only in GetCircularDependencies) is now handled uniformly via a notFound func() error callback, so any future endpoint naturally inherits the correct behaviour

Before: ~270 lines across two near-identical methods
After: ~100-line pollJob + ~30 lines of wrapper code — net reduction of 72 lines

Closes #41

Generated with Claude Code

Extract buildMultipartBody and pollJob from the duplicated logic in
GetGraph and GetCircularDependencies. Both public methods are now thin
wrappers: they build the request body, then delegate all polling,
HTTP status handling, and job-status branching to pollJob via callbacks.

The 404/405 case (previously only in GetCircularDependencies) is now
handled uniformly via a notFound callback, so future endpoints inherit
correct behaviour automatically.

Co-Authored-By: Grey Newell <greyshipscode@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude claude bot merged commit 74aa27f into main Feb 27, 2026
1 check passed
@claude claude bot deleted the claude/issue-41-20260227-0442 branch February 27, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract shared polling loop from GetGraph and GetCircularDependencies in api/client.go

0 participants