Repository navigation
Reduce the Go SDK to Read, Mutate and Native with functional options - #37
Merged
Merged
Conversation
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.
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.
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.
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
ReadorMutatewhose options choose where records come from and where results go.Newtakes gRPC options throughWithDialOptions, 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
WithQueryVisiblenow applies to a whole call and mixed visibility needs separate calls; gRPC targets other thanhost:port; and passing your ownStoreServiceClient. This is a breaking change for v0.24.0.weir-testsmigrates after the release, andweirat 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.