add atlas stream processing commands#3045
Draft
nickpoindexter wants to merge 1 commit into
Draft
Conversation
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
Adds first-class driver support for Atlas Stream Processing (ASP), implementing the ASP driver spec. Users currently have to drop down to
Mongo::Client#database('admin').command(...)against a workspace endpoint; this PR adds a dedicated client / handles layer matching what's already shipped for PHP and Rust.What's new
Public API (
lib/mongo/stream_processing/)Mongo::StreamProcessing::Client— workspace-scoped client distinct fromMongo::Client. Validates the workspace URI (atlas-stream-*.<region>.a.query.mongodb.netand the.mongodb-<env>.netstaging variants), enforcesTLS, defaults
auth_sourceto'admin'. StaticClient.workspace_uri?(uri)exposed for callers that want to gate before connecting.Mongo::StreamProcessing::Processors—#create(name, pipeline, **opts),#get(name),#get_info(name)for managing processors in a workspace.Mongo::StreamProcessing::Processor—#start(**opts),#stop,#drop,#stats(**opts),#samples(**opts)for a named processor.Mongo::StreamProcessing::ProcessorInfo— typed accessor over thegetStreamProcessorresponse. Fields the spec marks as Optional (e.g.id,pipeline_version) are nullable.Mongo::StreamProcessing::SamplesResult— result of#samples, exposescursor_id,documents,exhausted?.Wire commands
All 8 ASP commands routed through
Database#commandagainst theadmindatabase:createStreamProcessor,startStreamProcessor,stopStreamProcessor,dropStreamProcessor,getStreamProcessor,getStreamProcessorStats,startSampleStreamProcessor,getMoreSampleStreamProcessor.Notable spec / server alignment
startAfter(inProcessor#startoptions) is intentionally not serialized — the spec marks it RESERVED for future use and explicitly forbids drivers from sending it.Processors#get_infounwraps a top-levelresultwrapper when the server returns{ ok: 1, result: { … } }.Processor#samplesaccepts bothnextBatch(spec) andmessages(current dev server).ProcessorInfo#idand#pipeline_versionreturnnilwhen the server omits them.#samplesis a single-command dispatch: absent / zero:cursor_id→startSampleStreamProcessor(returnsSamplesResultwith cursor id, empty docs); non-zero →getMoreSampleStreamProcessor. Callers stop whencursor_id == 0(or use the#exhausted?predicate).tenantID,projectId,processorId) are not surfaced in the public API.Test plan
bundle exec rubocop lib/mongo/stream_processing*.rb spec/mongo/stream_processing/*.rb spec/integration/stream_processing_spec.rb examples/stream_processing.rb— cleanbundle exec rspec spec/mongo/stream_processing/— 29/29 unit examples pass (URI detection for prod / staging / creds-and-port / case-insensitivity / non-string / four reject cases; constructor rejection paths; fullProcessorInfogetter coverage incl. defaults and error fields;SamplesResultpredicates)bundle exec rspec spec/integration/stream_processing_spec.rb— self-skips cleanly withoutMONGODB_STREAM_PROCESSING_URI(1 pending, 0 failures)MONGODB_STREAM_PROCESSING_URI=… bundle exec rspec spec/integration/stream_processing_spec.rb— full lifecycle test against a real workspace endpoint. Needs an Evergreen variant configured with workspace credentialsbefore it actually exercises in CI.