Repository navigation
Add typed MongoDB and search packages so applications stop wrapping the SDK - #41
Merged
Merged
Conversation
…ent writers - MutationErr, ReadResult.Err and NativeResult.Err return a *weir.Error; CodeOf reads its FailureCode from any error chain. - ErrInterrupted marks a request an outage cut short after it may have begun, including a lost connection, which keeps its gRPC status. - ErrNotFound is the shared error for a missing record. - A mutation NOT_APPLIED with CONFLICT took no effect, so the Client now sends it again within the existing resend attempts and budget.
Typed, stateless helpers over the backend-neutral weir package: - mongodb.Collection[K, T]: Get, GetMany, Create, Put, Replace, Delete, Update, Transform, Find and Count, with string, integer and ObjectID keys; mongodb.DB: Command and Cursor. - search.Index[T]: the same record methods, Search and Do; search.Cluster: Do. Both packages use only weir's public API and share single-record calls through internal/record.
- Mark lost connections on shared and multi-record streams ErrInterrupted, not only on Native and single-stream calls. - Resend a Native request whose stream a server refused, as a refusal. - Give conflict resends a budget of their own, so a hot record never uses up the resends of records a draining server refused. - Add Error.Completion and state when a write certainly took no effect; ErrInterrupted only marks an outage. - Send $db with getMore and killCursors, so cursors work for a DB without a Name. - Keep a confirmed mutation or complete Native result when an RPC error follows it. - Take a zero _id as unset, send []byte search input as raw JSON, and point to Do for search totals and aggregations. - Correct comments and guides that said only refusals are resent.
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.
Every application on Weir ended up writing the same layer over the raw client: building record paths, putting
_idfirst in BSON, turning outcomes into errors, draining cursors and resending conflicts. The newmongodbandsearchpackages provide it once, as small stateless values (Collection[K, T],DB,Index[T],Cluster) built only on theweirpackage's public API, which stays backend-neutral. The core gainsMutationErr,ReadResult.Err,NativeResult.Err,CodeOf,ErrNotFoundandErrInterrupted. It also resends mutations that ended NOT_APPLIED/CONFLICT, since they took no effect, from a budget separate from refusals so contention never starves drain resends.This is the API proposal; the quick start stays on v0.24.1 until a release. Unit tests use a fake Weir, and the new integration tests passed against Weir main with MongoDB 8.0 and OpenSearch 2.17. With 1024 concurrent transforms of one record, CONFLICT failures fell from 256 to 28–156 on MongoDB and from 384 to 150–297 on OpenSearch across runs; the rest remain because the conflict budget caps resends at one per ten first sends plus a burst of 100. Batch writes are left out for now: concurrent single-record calls already share the Client's streams.