refactor!: make the Go client more idiomatic - #14
Closed
Pijukatel wants to merge 4 commits into
Closed
Conversation
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
Collaborator
Author
|
Contaminated by other implementations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bumped0.4.7→0.5.0.Idiomatic changes (breaking)
NewClient(token)+NewClientWithOptions(opts ...Option)into a singlefunc NewClient(token string, opts ...Option) *ApifyClient(functional-options pattern); removedNewClientWithOptionsand the redundantWithTokenoption. 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.CLIENT_VERSION→ClientVersion,API_SPEC_VERSION→APISpecVersion(Go rejectsSCREAMING_SNAKE_CASE). The publish workflow's version extractor was updated to match.ActorJobStatus(8 exported constants +IsTerminal()), replacing free-form status strings onActorRun.Status,Build.Status,LastRunOptions.Status,RunListOptions.Status, andActorClient/TaskClient.LastRun. Wire values unchanged.SetStatusMessagenow takesSetStatusMessageOptions; the request-queue methods (AddRequest,UpdateRequest,BatchAddRequests,ProlongRequestLock,DeleteRequestLock) take dedicated options structs instead of a positionalforefront bool.net/http.MethodHead.Documentation
Dataset,KeyValueStore, andRequestQueuestorage metadata models, and full return-type signatures for the storage collectionList/GetOrCreatemethods.Verification
go build ./...,go vet ./...,gofmt -l .,golangci-lint— all clean, no suppressions.APIFY_TOKEN) — all pass.Patterns already idiomatic (explicit-cursor iterators,
*booltri-state optionals,X/XWithOptionsconvenience pairs) were deliberately left unchanged.