Skip to content

Commit 2dfcb53

Browse files
generalltimvisee
authored andcommitted
make .initial_state usable (#253)
* make .initial_state usable * fmt
1 parent 9243e90 commit 2dfcb53

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/builders/create_shard_key_builder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ impl CreateShardKeyBuilder {
5151
///
5252
/// Use with caution! Setting arbirray replica states here may break your Qdrant cluster.
5353
#[allow(unused_mut)]
54-
pub fn initial_state(self, value: i32) -> Self {
54+
pub fn initial_state(self, value: ReplicaState) -> Self {
5555
let mut new = self;
56-
new.initial_state = Option::Some(Option::Some(value));
56+
new.initial_state = Option::Some(Option::Some(value as i32));
5757
new
5858
}
59+
5960
fn build_inner(self) -> Result<CreateShardKey, std::convert::Infallible> {
6061
Ok(CreateShardKey {
6162
shard_key: self.shard_key.unwrap_or_default(),

tests/snippet_tests/test_create_shard_key.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ async fn test_create_shard_key() {
66
// Please, modify the snippet in the `../snippets/create_shard_key.rs` file
77
use qdrant_client::qdrant::shard_key::Key;
88
use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder};
9+
use qdrant_client::qdrant::ReplicaState;
910
use qdrant_client::Qdrant;
1011

1112
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -14,7 +15,8 @@ async fn test_create_shard_key() {
1415
.create_shard_key(
1516
CreateShardKeyRequestBuilder::new("{collection_name}").request(
1617
CreateShardKeyBuilder::default()
17-
.shard_key(Key::Keyword("{shard_key}".to_string())),
18+
.shard_key(Key::Keyword("{shard_key}".to_string()))
19+
.initial_state(ReplicaState::Active),
1820
),
1921
)
2022
.await?;

tests/snippets/create_shard_key.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use qdrant_client::qdrant::shard_key::Key;
22
use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder};
3+
use qdrant_client::qdrant::ReplicaState;
34
use qdrant_client::Qdrant;
45

56
let client = Qdrant::from_url("http://localhost:6334").build()?;
@@ -8,7 +9,8 @@ client
89
.create_shard_key(
910
CreateShardKeyRequestBuilder::new("{collection_name}").request(
1011
CreateShardKeyBuilder::default()
11-
.shard_key(Key::Keyword("{shard_key}".to_string())),
12+
.shard_key(Key::Keyword("{shard_key}".to_string()))
13+
.initial_state(ReplicaState::Active),
1214
),
1315
)
1416
.await?;

0 commit comments

Comments
 (0)