Skip to content

Commit 2394c9e

Browse files
committedMar 26, 2025·
Move public API management functionality to a new directory
1 parent 1e030c4 commit 2394c9e

20 files changed

+103
-94
lines changed
 

‎sdk/couchbase/src/bucket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::clients::bucket_client::BucketClient;
22
use crate::clients::collections_mgmt_client::CollectionsMgmtClient;
33
use crate::collection::Collection;
4-
use crate::collection_manager::CollectionManager;
4+
use crate::management::collections::collection_manager::CollectionManager;
55
use crate::scope::Scope;
66
use std::sync::Arc;
77

‎sdk/couchbase/src/clients/bucket_mgmt_client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::bucket_settings::BucketSettings;
21
use crate::clients::agent_provider::CouchbaseAgentProvider;
32
use crate::error;
3+
use crate::management::buckets::bucket_settings::BucketSettings;
44
use crate::options::bucket_mgmt_options::{
55
CreateBucketOptions, DeleteBucketOptions, FlushBucketOptions, GetAllBucketsOptions,
66
GetBucketOptions, UpdateBucketOptions,

‎sdk/couchbase/src/clients/collections_mgmt_client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::clients::agent_provider::CouchbaseAgentProvider;
2-
use crate::collection_manager::{
2+
use crate::error;
3+
use crate::management::collections::collection_settings::{
34
CreateCollectionSettings, MaxExpiryValue, UpdateCollectionSettings,
45
};
5-
use crate::error;
66
use crate::options::collection_mgmt_options::*;
77
use crate::results::collections_mgmt_results::{CollectionSpec, ScopeSpec};
88
use couchbase_core::retry::RetryStrategy;

‎sdk/couchbase/src/cluster.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::bucket::Bucket;
2-
use crate::bucket_manager::BucketManager;
32
use crate::clients::analytics_client::AnalyticsClient;
43
use crate::clients::bucket_mgmt_client::BucketMgmtClient;
54
use crate::clients::cluster_client::ClusterClient;
65
use crate::clients::query_client::QueryClient;
76
use crate::clients::search_client::SearchClient;
87
use crate::error;
8+
use crate::management::buckets::bucket_manager::BucketManager;
99
use crate::options::analytics_options::AnalyticsOptions;
1010
use crate::options::cluster_options::ClusterOptions;
1111
use crate::options::query_options::QueryOptions;

‎sdk/couchbase/src/collection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::clients::collection_client::CollectionClient;
22
use crate::clients::core_kv_client::CoreKvClient;
33
use crate::clients::query_index_mgmt_client::QueryIndexMgmtClient;
4-
use crate::query_index_manager::CollectionQueryIndexManager;
4+
use crate::management::query::query_index_manager::CollectionQueryIndexManager;
55
use std::sync::Arc;
66

77
#[derive(Clone)]

‎sdk/couchbase/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
extern crate core;
22

33
pub mod bucket;
4-
pub mod bucket_manager;
5-
pub mod bucket_settings;
64
mod capella_ca;
75
mod clients;
86
pub mod cluster;
97
pub mod collection;
108
pub mod collection_binary_crud;
119
pub mod collection_crud;
1210
pub mod collection_ds;
13-
pub mod collection_manager;
1411
pub mod durability_level;
1512
pub mod error;
13+
pub mod management;
1614
pub mod mutation_state;
1715
pub mod options;
18-
pub mod query_index_manager;
1916
pub mod results;
2017
pub mod scope;
2118
pub mod search;

‎sdk/couchbase/src/bucket_manager.rs ‎sdk/couchbase/src/management/buckets/bucket_manager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::bucket_settings::BucketSettings;
21
use crate::clients::bucket_mgmt_client::BucketMgmtClient;
32
use crate::error;
3+
use crate::management::buckets::bucket_settings::BucketSettings;
44
use crate::options::bucket_mgmt_options::*;
55
use std::sync::Arc;
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod bucket_manager;
2+
pub mod bucket_settings;

‎sdk/couchbase/src/collection_manager.rs ‎sdk/couchbase/src/management/collections/collection_manager.rs

+3-74
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,11 @@
11
use crate::clients::collections_mgmt_client::CollectionsMgmtClient;
22
use crate::error;
3+
pub use crate::management::collections::collection_settings::{
4+
CreateCollectionSettings, UpdateCollectionSettings,
5+
};
36
use crate::options::collection_mgmt_options::*;
47
use crate::results::collections_mgmt_results::ScopeSpec;
58
use std::sync::Arc;
6-
use std::time::Duration;
7-
8-
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
9-
pub enum MaxExpiryValue {
10-
Never,
11-
InheritFromBucket,
12-
Seconds(Duration),
13-
}
14-
15-
impl From<MaxExpiryValue> for i32 {
16-
fn from(value: MaxExpiryValue) -> Self {
17-
match value {
18-
MaxExpiryValue::Never => 0,
19-
MaxExpiryValue::InheritFromBucket => -1,
20-
MaxExpiryValue::Seconds(duration) => duration.as_secs() as i32,
21-
}
22-
}
23-
}
24-
25-
impl From<i32> for MaxExpiryValue {
26-
fn from(value: i32) -> Self {
27-
match value {
28-
0 => MaxExpiryValue::Never,
29-
-1 => MaxExpiryValue::InheritFromBucket,
30-
_ => MaxExpiryValue::Seconds(Duration::from_secs(value as u64)),
31-
}
32-
}
33-
}
34-
35-
#[derive(Default, Debug, Clone)]
36-
#[non_exhaustive]
37-
pub struct CreateCollectionSettings {
38-
pub max_expiry: Option<MaxExpiryValue>,
39-
pub history: Option<bool>,
40-
}
41-
42-
impl CreateCollectionSettings {
43-
pub fn new() -> Self {
44-
Default::default()
45-
}
46-
47-
pub fn max_expiry(mut self, max_expiry: MaxExpiryValue) -> Self {
48-
self.max_expiry = Some(max_expiry);
49-
self
50-
}
51-
52-
pub fn history(mut self, history: bool) -> Self {
53-
self.history = Some(history);
54-
self
55-
}
56-
}
57-
58-
#[derive(Default, Debug, Clone)]
59-
#[non_exhaustive]
60-
pub struct UpdateCollectionSettings {
61-
pub max_expiry: Option<MaxExpiryValue>,
62-
pub history: Option<bool>,
63-
}
64-
65-
impl UpdateCollectionSettings {
66-
pub fn new() -> Self {
67-
Default::default()
68-
}
69-
70-
pub fn max_expiry(mut self, max_expiry: MaxExpiryValue) -> Self {
71-
self.max_expiry = Some(max_expiry);
72-
self
73-
}
74-
75-
pub fn history(mut self, history: bool) -> Self {
76-
self.history = Some(history);
77-
self
78-
}
79-
}
809

8110
#[derive(Clone)]
8211
pub struct CollectionManager {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
use std::time::Duration;
2+
3+
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
4+
pub enum MaxExpiryValue {
5+
Never,
6+
InheritFromBucket,
7+
Seconds(Duration),
8+
}
9+
10+
impl From<MaxExpiryValue> for i32 {
11+
fn from(value: MaxExpiryValue) -> Self {
12+
match value {
13+
MaxExpiryValue::Never => 0,
14+
MaxExpiryValue::InheritFromBucket => -1,
15+
MaxExpiryValue::Seconds(duration) => duration.as_secs() as i32,
16+
}
17+
}
18+
}
19+
20+
impl From<i32> for MaxExpiryValue {
21+
fn from(value: i32) -> Self {
22+
match value {
23+
0 => MaxExpiryValue::Never,
24+
-1 => MaxExpiryValue::InheritFromBucket,
25+
_ => MaxExpiryValue::Seconds(Duration::from_secs(value as u64)),
26+
}
27+
}
28+
}
29+
30+
#[derive(Default, Debug, Clone)]
31+
#[non_exhaustive]
32+
pub struct CreateCollectionSettings {
33+
pub max_expiry: Option<MaxExpiryValue>,
34+
pub history: Option<bool>,
35+
}
36+
37+
impl CreateCollectionSettings {
38+
pub fn new() -> Self {
39+
Default::default()
40+
}
41+
42+
pub fn max_expiry(mut self, max_expiry: MaxExpiryValue) -> Self {
43+
self.max_expiry = Some(max_expiry);
44+
self
45+
}
46+
47+
pub fn history(mut self, history: bool) -> Self {
48+
self.history = Some(history);
49+
self
50+
}
51+
}
52+
53+
#[derive(Default, Debug, Clone)]
54+
#[non_exhaustive]
55+
pub struct UpdateCollectionSettings {
56+
pub max_expiry: Option<MaxExpiryValue>,
57+
pub history: Option<bool>,
58+
}
59+
60+
impl UpdateCollectionSettings {
61+
pub fn new() -> Self {
62+
Default::default()
63+
}
64+
65+
pub fn max_expiry(mut self, max_expiry: MaxExpiryValue) -> Self {
66+
self.max_expiry = Some(max_expiry);
67+
self
68+
}
69+
70+
pub fn history(mut self, history: bool) -> Self {
71+
self.history = Some(history);
72+
self
73+
}
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod collection_manager;
2+
pub mod collection_settings;

‎sdk/couchbase/src/management/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod buckets;
2+
pub mod collections;
3+
pub mod query;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod query_index_manager;

‎sdk/couchbase/src/results/collections_mgmt_results.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::collection_manager::MaxExpiryValue;
1+
use crate::management::collections::collection_settings::MaxExpiryValue;
22

33
#[derive(Default, Debug, Clone)]
44
pub struct ScopeSpec {

‎sdk/couchbase/tests/bucket_management.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use crate::common::consistency_utils::{verify_bucket_created, verify_bucket_dele
22
use crate::common::features::TestFeatureCode;
33
use crate::common::test_config::run_test;
44
use crate::common::{generate_string_value, try_until};
5-
use couchbase::bucket_settings::{
5+
use couchbase::durability_level::DurabilityLevel;
6+
use couchbase::management::buckets::bucket_settings::{
67
BucketSettings, CompressionMode, ConflictResolutionType, EvictionPolicyType, StorageBackend,
78
};
8-
use couchbase::durability_level::DurabilityLevel;
99
use serial_test::serial;
1010
use std::time::Duration;
1111

‎sdk/couchbase/tests/collections_management.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::common::consistency_utils::{
55
use crate::common::features::TestFeatureCode;
66
use crate::common::test_config::run_test;
77
use crate::common::{generate_string_value, try_until};
8-
use couchbase::collection_manager::{
8+
use couchbase::management::collections::collection_settings::{
99
CreateCollectionSettings, MaxExpiryValue, UpdateCollectionSettings,
1010
};
1111
use std::time::Duration;

‎sdk/couchbase/tests/common/consistency_utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::common::try_until;
2-
use couchbase::bucket_manager::BucketManager;
3-
use couchbase::collection_manager::CollectionManager;
2+
use couchbase::management::buckets::bucket_manager::BucketManager;
3+
use couchbase::management::collections::collection_manager::CollectionManager;
44
use couchbase::results::collections_mgmt_results::CollectionSpec;
55
use std::time::Duration;
66

@@ -22,7 +22,7 @@ pub async fn verify_bucket_created(manager: &BucketManager, bucket_name: &str) {
2222

2323
pub async fn verify_bucket_deleted(manager: &BucketManager, bucket_name: &str) {
2424
try_until(
25-
tokio::time::Instant::now() + Duration::from_secs(30),
25+
tokio::time::Instant::now() + Duration::from_secs(60),
2626
Duration::from_millis(100),
2727
"Bucket was not deleted in time",
2828
|| async {

‎sdk/couchbase/tests/query.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::common::consistency_utils::{
33
};
44
use crate::common::test_config::run_test;
55
use crate::common::try_until;
6-
use couchbase::collection_manager::CollectionManager;
6+
use couchbase::management::collections::collection_manager::CollectionManager;
77
use couchbase::options::query_index_mgmt_options::{
88
CreatePrimaryQueryIndexOptions, CreateQueryIndexOptions,
99
};
@@ -233,7 +233,8 @@ async fn create_collection(manager: &CollectionManager) -> (String, String) {
233233
manager.create_scope(&scope_name, None).await.unwrap();
234234
verify_scope_created(manager, &scope_name).await;
235235

236-
let settings = couchbase::collection_manager::CreateCollectionSettings::new();
236+
let settings =
237+
couchbase::management::collections::collection_manager::CreateCollectionSettings::new();
237238
manager
238239
.create_collection(&scope_name, &collection_name, settings, None)
239240
.await

0 commit comments

Comments
 (0)
Please sign in to comment.