Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ parking_lot = "0.12.4"

[dev-dependencies]
tonic-build = { version = "0.12.3", features = ["prost"] }
serde_json = "1.0.128"

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

serde_json is already an optional normal dependency (enabled by the serde feature). Adding it again as an unconditional root dev-dependency is redundant and makes it harder to reason about feature-gating (e.g., dev builds will have serde_json even if the serde feature is off). Consider removing the dev-dependency unless there’s a specific need for serde_json when serde is disabled.

Suggested change
serde_json = "1.0.128"

Copilot uses AI. Check for mistakes.

[workspace]
members = [
".",
"examples/web-integrations",
]
Comment on lines +35 to +38

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

Adding a workspace with examples/web-integrations as a member will cause existing CI commands like cargo clippy --workspace --all-targets --all-features and cargo test --all (see .github/workflows/lint.yml and tests/integration-tests.sh) to compile these new Actix/Axum/Rocket binaries. That can significantly increase CI time and can introduce new system dependency requirements. Consider keeping these examples out of the workspace (or adjusting CI commands / moving them under a non-workspace directory) so they don’t become part of the default lint/test surface.

Copilot uses AI. Check for mistakes.
Comment on lines 32 to +38

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description mentions adding frameworks to root [dev-dependencies] and adding new [[example]] sections with required-features, but the implementation instead adds a new workspace member crate with [[bin]] targets. Please align the description with the actual approach, or refactor to match the described [[example]] + required-features pattern (whichever is intended).

Copilot uses AI. Check for mistakes.

[features]
default = ["download_snapshots", "serde", "generate-snippets"]
Expand Down
25 changes: 25 additions & 0 deletions examples/web-integrations/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "web-integrations-examples"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
qdrant-client = { path = "../../", features = ["serde"] }
actix-web = "4.12.1"
axum = "0.8.7"
rocket = { version = "0.5.1", features = ["json"] }
serde_json = "1.0.128"
tokio = { version = "1.40.0", features = ["rt-multi-thread", "macros", "net"] }

[[bin]]
name = "actix_web"
path = "src/actix_web.rs"

[[bin]]
name = "axum"
path = "src/axum.rs"

[[bin]]
name = "rocket"
path = "src/rocket.rs"
53 changes: 53 additions & 0 deletions examples/web-integrations/src/actix_web.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::sync::Arc;

use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use qdrant_client::Qdrant;
use serde_json::json;

struct AppState {
client: Arc<Qdrant>,
}

async fn list_collections(data: web::Data<AppState>) -> impl Responder {
match data.client.list_collections().await {
Ok(collections) => {
let names: Vec<String> = collections
.collections
.into_iter()
.map(|c| c.name)
.collect();
HttpResponse::Ok().json(json!({ "collections": names }))
}
Err(e) => HttpResponse::InternalServerError().body(e.to_string()),
}
}

async fn health_check(data: web::Data<AppState>) -> impl Responder {
match data.client.health_check().await {
Ok(resp) => HttpResponse::Ok().json(json!({ "result": format!("{:?}", resp) })),
Err(e) => HttpResponse::InternalServerError().body(e.to_string()),

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

The success path returns JSON, but the error path returns a plain-text body. Since these examples are meant to demonstrate a JSON bridge for non-Serialize types, consider returning a JSON error payload here as well (and optionally include an error code/status consistently).

Suggested change
Err(e) => HttpResponse::InternalServerError().body(e.to_string()),
}
}
async fn health_check(data: web::Data<AppState>) -> impl Responder {
match data.client.health_check().await {
Ok(resp) => HttpResponse::Ok().json(json!({ "result": format!("{:?}", resp) })),
Err(e) => HttpResponse::InternalServerError().body(e.to_string()),
Err(e) => HttpResponse::InternalServerError()
.json(json!({ "error": e.to_string(), "code": "internal_server_error" })),
}
}
async fn health_check(data: web::Data<AppState>) -> impl Responder {
match data.client.health_check().await {
Ok(resp) => HttpResponse::Ok().json(json!({ "result": format!("{:?}", resp) })),
Err(e) => HttpResponse::InternalServerError()
.json(json!({ "error": e.to_string(), "code": "internal_server_error" })),

Copilot uses AI. Check for mistakes.
}
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
let client = Qdrant::from_url("http://localhost:6334")
.build()
.expect("Failed to create Qdrant client");

let state = web::Data::new(AppState {
client: Arc::new(client),
});

println!("Starting Actix server on http://localhost:8080");

HttpServer::new(move || {
App::new()
.app_data(state.clone())
.route("/collections", web::get().to(list_collections))
.route("/health", web::get().to(health_check))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
39 changes: 39 additions & 0 deletions examples/web-integrations/src/axum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::sync::Arc;

use axum::routing::get;
use axum::{Json, Router};
use qdrant_client::Qdrant;
use serde_json::{json, Value};

async fn list_collections(
axum::extract::State(client): axum::extract::State<Arc<Qdrant>>,
) -> Json<Value> {
match client.list_collections().await {
Ok(collections) => {
let names: Vec<String> = collections
.collections
.into_iter()
.map(|c| c.name)
.collect();
Json(json!({ "collections": names }))
}
Err(e) => Json(json!({"error": e.to_string()})),
}
Comment on lines +12 to +25

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

In the error branch this returns Json(...) without setting an HTTP error status, so failures will look like 200 OK to callers. Consider returning a (StatusCode, Json<Value>) (or an axum::response::IntoResponse) so errors map to 5xx/4xx status codes appropriately.

Copilot uses AI. Check for mistakes.
}

#[tokio::main]
async fn main() {
let client = Qdrant::from_url("http://localhost:6334")
.build()
.expect("Failed to create Qdrant client");

let app = Router::new()
.route("/collections", get(list_collections))
.with_state(Arc::new(client));

let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
println!("Starting Axum server on http://localhost:3000");
axum::serve(listener, app).await.unwrap();
}
32 changes: 32 additions & 0 deletions examples/web-integrations/src/rocket.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#[macro_use]
extern crate rocket;
use qdrant_client::Qdrant;
use rocket::serde::json::Json;
use rocket::State;
use serde_json::{json, Value};

#[get("/collections")]
async fn list_collections(client: &State<Qdrant>) -> Json<Value> {
match client.list_collections().await {
Ok(collections) => {
let names: Vec<String> = collections
.collections
.into_iter()
.map(|c| c.name)
.collect();
Json(json!({ "collections": names }))
}
Err(e) => Json(json!({"error": e.to_string()})),
}

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

The error branch returns JSON but does not set a non-2xx status code, so Qdrant failures will be reported as 200 OK. Consider returning a status::Custom<Json<Value>> (or similar) with an appropriate Rocket Status for error cases.

Copilot uses AI. Check for mistakes.
}

#[launch]
async fn rocket() -> _ {
let client = Qdrant::from_url("http://localhost:6334")
.build()
.expect("Failed to create Qdrant client");

rocket::build()
.manage(client)
.mount("/", routes![list_collections])
}
Loading