Skip to content

feat: drop faraday and use Net::HTTP - #37

Merged
andreibondarev merged 9 commits into
patterns-ai-core:mainfrom
shetty-tejas:drop_faraday
Aug 12, 2026
Merged

feat: drop faraday and use Net::HTTP#37
andreibondarev merged 9 commits into
patterns-ai-core:mainfrom
shetty-tejas:drop_faraday

Conversation

@shetty-tejas

@shetty-tejas shetty-tejas commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Inspired from #16

Replace Faraday with Net::HTTP

Purpose

Removes the faraday runtime dependency from qdrant-ruby and replaces the HTTP transport with Ruby's stdlib Net::HTTP, preserving the existing client constructor, endpoint method signatures, request/response behavior, and the public client.connection call shape. The gem now ships with one runtime dependency (logger).

What changed

Client

  • A Qdrant::Client::Connection facade keeps the Faraday-shaped verb/block/response surface (get/post/put/patch/delete(path) { |req| req.params/req.body }), so none of the six endpoint classes (aliases, clusters, collections, points, service, snapshots) needed a source change.
  • Internally decomposed into RequestBuilder (URI + query-param building), Request (Net::HTTP request construction/execution), and ResponseBuilder (content-type-gated JSON parsing) for testability.
  • Scheme-less configured URLs (e.g. localhost:6333) are normalized to http://; base paths are preserved.
  • Endpoint query strings merge with req.params via URI.encode_www_form, preserving insertion order and encoding booleans as true/false (ordering=weak&wait=false).
  • JSON request bodies are serialized with Content-Type/Accept: application/json; the api-key header is set only when configured.
  • Responses: JSON bodies (including application/json; charset=utf-8) are parsed to hashes; text/plain, binary (snapshot downloads), and empty bodies pass through untouched.
  • raise_error: true uses Net::HTTP's native response.value, raising Net::HTTPClientException/Net::HTTPFatalError; the default raise_error: false returns the response for 4xx/5xx.
  • Logging mirrors the old Faraday logger middleware (method/URL, headers, body, status, errors), with the api-key header redacted.
  • TLS is enabled for https:// URLs (verified — Net::HTTP.new does not yield, so SSL is set explicitly).
  • Readers url/api_key/adapter/raise_error/logger and the keyword constructor are unchanged; adapter: is retained for compatibility but ignored when dispatching. The connection is memoized.

Specs

  • Migrated all endpoint doubles from allow_any_instance_of(Faraday::Connection) to allow_any_instance_of(Qdrant::Client::Connection), preserving verb/path expectations and fixtures.
  • Added spec/qdrant/connection_spec.rb: wire-level tests against a local stdlib TCP server covering query params + JSON body/headers + JSON parsing, text/binary passthrough, query ordering/false values + existing-query merge, both raise_error modes, and the client configuration surface.
  • Replaced OpenStruct test doubles with Qdrant::Client::Response so the spec suite no longer depends on ostruct.

Packaging / toolchain

  • Removed faraday (and transitive faraday-net_http) from the gemspec; Gemfile.lock regenerated with no Faraday anywhere in the resolution.
  • required_ruby_version bumped from >= 2.6.0 to >= 3.3.
  • CI matrix widened to ["3.3", "3.4", "4.0"]; standard upgraded 1.28.5 → 1.56.0 (old rubocop couldn't run on Ruby ≥3.4). base64/ostruct are not needed in the Gemfile with the upgraded rubocop and are not used by the gem or specs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces the Faraday-based HTTP transport in qdrant-ruby with a custom Net::HTTP implementation, updating the client internals and test suite accordingly, and removing the Faraday runtime dependency.

Changes:

  • Introduce Qdrant::Client::Connection, RequestBuilder/Request, and ResponseBuilder/Response to perform and parse Net::HTTP requests.
  • Update specs to stub Qdrant::Client::Connection and add a transport-level connection_spec using a local TCP server.
  • Remove faraday from runtime deps and update Ruby/CI/tooling versions.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/spec_helper.rb Removes Faraday/OpenStruct requirements now that Faraday is no longer used in specs.
spec/qdrant/snapshots_spec.rb Switches stubbing from Faraday::Connection to Qdrant::Client::Connection and uses Qdrant::Client::Response.
spec/qdrant/service_spec.rb Same: replaces Faraday/OpenStruct usage with new Response/Connection types.
spec/qdrant/points_spec.rb Same: updates response doubles and connection stubs to match new transport.
spec/qdrant/connection_spec.rb Adds end-to-end request/response behavior tests for the new Net::HTTP transport.
spec/qdrant/collections_spec.rb Migrates collection specs off Faraday/OpenStruct to the new Response/Connection types.
spec/qdrant/clusters_spec.rb Migrates cluster specs off Faraday/OpenStruct.
spec/qdrant/aliases_spec.rb Migrates alias specs off Faraday/OpenStruct.
qdrant.gemspec Removes Faraday dependency and raises required Ruby version.
lib/qdrant/points.rb Minor formatting cleanup in method signature area.
lib/qdrant/client/response.rb Adds Response struct + ResponseBuilder for parsing JSON vs returning raw bodies.
lib/qdrant/client/request.rb Adds RequestBuilder/Request to build URIs, set headers/body, perform Net::HTTP call, and log.
lib/qdrant/client/connection.rb Adds Connection wrapper exposing get/post/put/patch/delete and returning Qdrant::Client::Response.
lib/qdrant/client.rb Removes Faraday wiring; constructs and memoizes the new Connection; adds URL normalization.
Gemfile.lock Updates lockfile to remove Faraday and refresh dev tooling dependencies.
Gemfile Updates standard version.
.github/workflows/ci.yml Updates CI Ruby matrix and minor whitespace cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/qdrant/client/request.rb
Comment thread lib/qdrant/client.rb Outdated
Comment thread qdrant.gemspec
@andreibondarev

Copy link
Copy Markdown
Collaborator

@shetty-tejas Lmk when it's ready, or if you're still making changes.

@shetty-tejas

Copy link
Copy Markdown
Contributor Author

@andreibondarev Could you help me determine the appropriate version bump for this? I'm not sure whether it should be a patch or minor release.

The implementation is ready for review. I only need to resolve the remaining CI failure.

@andreibondarev

Copy link
Copy Markdown
Collaborator

@andreibondarev Could you help me determine the appropriate version bump for this? I'm not sure whether it should be a patch or minor release.

The implementation is ready for review. I only need to resolve the remaining CI failure.

Yep, once it's merged I'll cut and push a new version.

@shetty-tejas

Copy link
Copy Markdown
Contributor Author

@andreibondarev CI should be green now. I had to add logger as a dependency for Ruby 4.0 compatibility.

@shetty-tejas

Copy link
Copy Markdown
Contributor Author

@andreibondarev I also recommend running an end-to-end test against the Qdrant APIs before cutting a new release. I can do this by tomorrow if needed, or you can run it sooner if you already have a test bench available.

@andreibondarev

Copy link
Copy Markdown
Collaborator

@andreibondarev I also recommend running an end-to-end test against the Qdrant APIs before cutting a new release. I can do this by tomorrow if needed, or you can run it sooner if you already have a test bench available.

I don't. If you're available to do that -- that'd be phenomenal.

@shetty-tejas

Copy link
Copy Markdown
Contributor Author

@andreibondarev sounds good, I'll run the end-to-end tests and report back here by tomorrow 😄

@shetty-tejas

Copy link
Copy Markdown
Contributor Author

@andreibondarev I've added an E2E test script. Set QDRANT_URL and QDRANT_API_KEY, then run bundle exec rake e2e.

It passes against a hosted Qdrant cluster:
image

Please run it against your Qdrant cluster as well. The implementation is ready for review 😄

@shetty-tejas shetty-tejas changed the title feat: drop faraday feat: drop faraday and use Net::HTTP Aug 12, 2026
@andreibondarev
andreibondarev merged commit db2a8be into patterns-ai-core:main Aug 12, 2026
3 checks passed
@andreibondarev

Copy link
Copy Markdown
Collaborator

@shetty-tejas Pushed up 0.10.0. Thanks again! 🥇

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.

3 participants