Skip to content

Reduce the Go SDK to Read, Mutate and Native with functional options - #37

Merged
liran merged 9 commits into
mainfrom
feat/option-api
Nov 5, 2026
Merged

liran merged 9 commits into
mainfrom
feat/option-api

Conversation

@liran

@liran liran commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Weir has no production users yet, so this removes the overlapping entry points while nothing depends on them. The SDK had single-record methods, batches, streams and package functions for the same work; now every read or write is one Read or Mutate whose options choose where records come from and where results go. New takes gRPC options through WithDialOptions, for stats handlers, interceptors and custom dialers. Those see gRPC streams rather than calls, so they suit stream metrics, not per-call tracing.

Some capabilities go away: per-record visibility, as WithQueryVisible now applies to a whole call and mixed visibility needs separate calls; gRPC targets other than host:port; and passing your own StoreServiceClient. This is a breaking change for v0.24.0. weir-tests migrates after the release, and weir at its next SDK bump. Unit tests pass under the race detector, and the integration tests, examples and Quick start code ran against a real Weir with MongoDB and Elasticsearch.

liran added 2 commits November 5, 2026 07:51
Read and Mutate take a context and a Store, then WithRequests, WithNext, a
consume callback and WithQueryVisible. Native takes a required request and
WithChunks, and collects the body otherwise. This replaces the single-record
methods, ReadStream, MutateStream, the package functions and Dial.
@liran liran self-assigned this Nov 4, 2026
liran added 7 commits November 5, 2026 08:22
An error or invalid item from Next canceled the records already admitted, so
requests the server may have applied came back with nil results, against what
the documentation promises. Next now only ends the input.

Errors also name a record by the 0-based index its callback receives, and the
tests that missed behavior of the option API now cover it.
Every other call returns it, and docs/connections.md promises it of all calls.
Removing Dial and the package functions left no way to add a stats handler, an
interceptor or a custom dialer. These options can replace a Client's defaults
but not its resolver, its balancer or the ban on gRPC retries, which following
servers and never resending an applied record depend on.
A stream read its server from the gRPC peer. A custom dialer's address never
resolved, so every stream drained on opening and stream sharing silently ended,
and an interceptor's wrapper could hide the peer, so a server that stopped
resolving went on receiving records.

WithDialOptions also ignores a nil option now, as gRPC panics on one, and the
tests check the stream counts that exposed this.
@liran
liran merged commit bf30fef into main Nov 5, 2026
3 checks passed
@liran
liran deleted the feat/option-api branch November 5, 2026 09:28
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.

1 participant