Skip to content

Commit

Permalink
Don't make config optional in client construction (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
timvisee authored Jun 26, 2024
1 parent b33accb commit 8a589fd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ mod tests {

#[tokio::test]
async fn test_qdrant_queries() -> anyhow::Result<()> {
let config = Qdrant::from_url("http://localhost:6334");
let client = Qdrant::new(Some(config))?;
let client = Qdrant::from_url("http://localhost:6334").build()?;

let health = client.health_check().await?;
println!("{:?}", health);
Expand Down
4 changes: 1 addition & 3 deletions src/qdrant_client/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,10 @@ mod tests {
CountPointsBuilder, CreateCollectionBuilder, PointStruct, SearchPointsBuilder,
UpsertPointsBuilder, VectorParamsBuilder,
};
use crate::qdrant_client::config::QdrantConfig;

#[tokio::test]
async fn create_collection_and_do_the_search() -> QdrantResult<()> {
let config = QdrantConfig::from_url("http://localhost:6334");
let client = Qdrant::new(Some(config))?;
let client = Qdrant::from_url("http://localhost:6334").build()?;

let collection_name = "test2";

Expand Down
2 changes: 1 addition & 1 deletion src/qdrant_client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl QdrantConfig {

/// Build the configured [`Qdrant`] client
pub fn build(self) -> Result<Qdrant, QdrantError> {
Qdrant::new(Some(self))
Qdrant::new(self)
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/qdrant_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ pub struct Qdrant {
impl Qdrant {
/// Create a new Qdrant client.
///
/// If no client client configuration is given the [default](QdrantConfig::default) is used.
pub fn new(config: Option<QdrantConfig>) -> QdrantResult<Self> {
let config = config.unwrap_or_default();

/// Constructs the client and connects based on the given [`QdrantConfig`](config::QdrantConfig).
pub fn new(config: QdrantConfig) -> QdrantResult<Self> {
let channel = ChannelPool::new(
config.uri.parse::<Uri>()?,
config.timeout,
Expand Down

0 comments on commit 8a589fd

Please sign in to comment.