Skip to content

refactor!: make the Go client more idiomatic - #14

Closed
Pijukatel wants to merge 4 commits into
masterfrom
claude/vibrant-meitner-nm574i
Closed

refactor!: make the Go client more idiomatic#14
Pijukatel wants to merge 4 commits into
masterfrom
claude/vibrant-meitner-nm574i

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refactors the Go client to be more idiomatic Go, per the updated orchestration consistency requirement ("Consistency with the reference implementation that would go against idiomatic use of the language is not desired") with breaking public-interface changes explicitly permitted. This is not an OpenAPI spec sync — the client remains on v2-2026-07-07T132551Z. Consistency is kept with the JS reference at the API-surface level, not with sibling clients. Version bumped 0.4.70.5.0.

Idiomatic changes (breaking)

  • Unified constructor: collapsed NewClient(token) + NewClientWithOptions(opts ...Option) into a single func NewClient(token string, opts ...Option) *ApifyClient (functional-options pattern); removed NewClientWithOptions and the redundant WithToken option. All prior options (WithBaseURL, WithPublicBaseURL, WithMaxRetries, WithMinDelayBetweenRetries, WithTimeout, WithUserAgentSuffix, WithHTTPBackend) remain configurable on the unified constructor. Mirrors the JS reference's single options-object constructor. Empty-token construction yields a valid unauthenticated client (JS-consistent), documented and tested.
  • MixedCaps constants: CLIENT_VERSIONClientVersion, API_SPEC_VERSIONAPISpecVersion (Go rejects SCREAMING_SNAKE_CASE). The publish workflow's version extractor was updated to match.
  • Named enum type ActorJobStatus (8 exported constants + IsTerminal()), replacing free-form status strings on ActorRun.Status, Build.Status, LastRunOptions.Status, RunListOptions.Status, and ActorClient/TaskClient.LastRun. Wire values unchanged.
  • Options structs replace boolean-trap positional params: SetStatusMessage now takes SetStatusMessageOptions; the request-queue methods (AddRequest, UpdateRequest, BatchAddRequests, ProlongRequestLock, DeleteRequestLock) take dedicated options structs instead of a positional forefront bool.
  • Replaced an underscore identifier with net/http.MethodHead.

Documentation

  • Added field tables for the Dataset, KeyValueStore, and RequestQueue storage metadata models, and full return-type signatures for the storage collection List/GetOrCreate methods.

Verification

  • go build ./..., go vet ./..., gofmt -l ., golangci-lint — all clean, no suppressions.
  • Unit tests, doc-snippet tests, and live integration tests (APIFY_TOKEN) — all pass.

Patterns already idiomatic (explicit-cursor iterators, *bool tri-state optionals, X/XWithOptions convenience pairs) were deliberately left unchanged.

claude and others added 4 commits July 9, 2026 10:20
Idiomatic-Go refactor (consistency target = JS reference only, not sibling
clients). Breaking public-interface changes; minor bump 0.4.7 -> 0.5.0.

- Rename SCREAMING_SNAKE public constants to MixedCaps: CLIENT_VERSION ->
  ClientVersion, API_SPEC_VERSION -> APISpecVersion (update go-publish.yml sed).
- Add named enum type ActorJobStatus with 8 constants + IsTerminal(); retype
  ActorRun.Status, Build.Status, and the status filters (LastRunOptions.Status,
  RunListOptions.Status, ActorClient/TaskClient.LastRun).
- Replace internal underscore identifier http_MethodHead with net/http.MethodHead.
- Replace boolean-trap positional params with options structs:
  SetStatusMessage -> SetStatusMessageOptions; request-queue AddRequest,
  UpdateRequest, BatchAddRequests, ProlongRequestLock, DeleteRequestLock ->
  dedicated *Options structs (matches JS options-object shape).
- Tests/docs/CHANGELOG updated; add status and SetStatusMessage unit tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvkiV9GQnM5qo4iAnX43K7
Collapse NewClient(token) and NewClientWithOptions(opts ...Option) into a
single NewClient(token string, opts ...Option) *ApifyClient, and remove the
now-redundant WithToken option. Token is the explicit first argument; all other
options remain configurable via the variadic Option parameter. Mirrors the JS
reference's single-constructor-with-optional-config shape.

Update all call sites, tests, examples, docs, and CHANGELOG. Document that
NewClient("") yields an unauthenticated client, and add a unit test asserting
the Bearer Authorization header is present with a token and absent without one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvkiV9GQnM5qo4iAnX43K7
@Pijukatel

Copy link
Copy Markdown
Collaborator Author

Contaminated by other implementations.

@Pijukatel Pijukatel closed this Jul 9, 2026
@Pijukatel
Pijukatel deleted the claude/vibrant-meitner-nm574i branch July 15, 2026 06:05
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.

3 participants