-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: qdrant resource example * update qdrant example - `shuttle_qdrant::Qdrant` now returns a `QdrantClient` - pass in `cloud_url` and `api_key`, read from `Secrets.toml` * update versions * fix: filenames * fix: correct shuttle version * docs: add qdrant to readme --------- Co-authored-by: jonaro00 <54029719+jonaro00@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "shuttle-axum-qdrant" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
axum = "0.7.3" | ||
qdrant-client = "1.7.0" | ||
shuttle-axum = "0.36.0" | ||
shuttle-qdrant = "0.36.0" | ||
shuttle-runtime = "0.36.0" | ||
tokio = "1.26.0" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Note that we use gRPC (port 6334) to talk to Qdrant. | ||
CLOUD_URL = 'https://xyz-example.eu-central.aws.cloud.qdrant.io:6334' | ||
API_KEY = 'your_api_key' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use axum::{extract::State, routing::get, Router}; | ||
use qdrant_client::prelude::*; | ||
use std::sync::Arc; | ||
|
||
struct AppState { | ||
qdrant: QdrantClient, | ||
} | ||
|
||
async fn list_collections(State(state): State<Arc<AppState>>) -> String { | ||
format!("{:?}\n", state.qdrant.list_collections().await) | ||
} | ||
|
||
#[shuttle_runtime::main] | ||
async fn axum( | ||
#[shuttle_qdrant::Qdrant(cloud_url = "{secrets.CLOUD_URL}", api_key = "{secrets.API_KEY}")] | ||
qdrant: QdrantClient, | ||
) -> shuttle_axum::ShuttleAxum { | ||
let state = Arc::new(AppState { qdrant }); | ||
|
||
let router = Router::new() | ||
.route("/", get(list_collections)) | ||
.with_state(state); | ||
|
||
Ok(router.into()) | ||
} |