Skip to content

Commit 23adda9

Browse files
committed
RSCBC-84: Add support for specifying number of vbuckets when creating bucket
Motivation ========== ns_server has added support for Magma buckets with 128 vBuckets, in addition to the existing configuration with 1024 vBuckets. We need to be able to specify the number of vBuckets that should be used in the SDK's bucket management API. Change ======= Add NumVBuckets to BucketSettings
1 parent a463ac6 commit 23adda9

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

sdk/couchbase-core/src/mgmtx/bucket_settings.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct BucketSettings {
2020
pub replica_index: Option<bool>,
2121
pub bucket_type: Option<BucketType>,
2222
pub storage_backend: Option<StorageBackend>,
23+
pub num_vbuckets: Option<u16>,
2324
}
2425

2526
impl BucketSettings {
@@ -101,6 +102,11 @@ impl BucketSettings {
101102
self.storage_backend = Some(storage_backend.into());
102103
self
103104
}
105+
106+
pub fn num_vbuckets(mut self, num_vbuckets: u16) -> Self {
107+
self.num_vbuckets = Some(num_vbuckets);
108+
self
109+
}
104110
}
105111

106112
#[derive(Debug, Clone, PartialOrd, PartialEq)]
@@ -143,6 +149,7 @@ impl From<BucketSettingsJson> for BucketDef {
143149
replica_index: settings.replica_index,
144150
bucket_type: settings.bucket_type,
145151
storage_backend: settings.storage_backend,
152+
num_vbuckets: settings.num_vbuckets,
146153
},
147154
}
148155
}
@@ -412,4 +419,7 @@ pub(crate) fn encode_bucket_settings(serializer: &mut Serializer<String>, opts:
412419
if let Some(storage_backend) = &opts.storage_backend {
413420
serializer.append_pair("storageBackend", storage_backend.to_string().as_str());
414421
}
422+
if let Some(num_vbuckets) = opts.num_vbuckets {
423+
serializer.append_pair("numVBuckets", num_vbuckets.to_string().as_str());
424+
}
415425
}

sdk/couchbase-core/src/mgmtx/bucket_settings_json.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ pub struct BucketSettingsJson {
5858
pub history_retention_bytes: Option<u64>,
5959
#[serde(default, rename = "historyRetentionSeconds")]
6060
pub history_retention_seconds: Option<u32>,
61+
#[serde(default, rename = "numVBuckets")]
62+
pub num_vbuckets: Option<u16>,
6163
}
6264

6365
#[derive(Debug, Deserialize)]

sdk/couchbase/src/management/buckets/bucket_settings.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct BucketSettings {
2020
pub replica_indexes: Option<bool>,
2121
pub bucket_type: Option<BucketType>,
2222
pub storage_backend: Option<StorageBackend>,
23+
pub num_vbuckets: Option<u16>,
2324
}
2425

2526
impl BucketSettings {
@@ -40,6 +41,7 @@ impl BucketSettings {
4041
replica_indexes: None,
4142
bucket_type: None,
4243
storage_backend: None,
44+
num_vbuckets: None,
4345
}
4446
}
4547

@@ -121,6 +123,11 @@ impl BucketSettings {
121123
self.storage_backend = Some(storage_backend.into());
122124
self
123125
}
126+
127+
pub fn num_vbuckets(mut self, num_vbuckets: u16) -> Self {
128+
self.num_vbuckets = Some(num_vbuckets);
129+
self
130+
}
124131
}
125132

126133
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
@@ -419,6 +426,7 @@ impl From<BucketDef> for BucketSettings {
419426
replica_indexes: value.bucket_settings.replica_index,
420427
bucket_type: value.bucket_settings.bucket_type.map(|v| v.into()),
421428
storage_backend: value.bucket_settings.storage_backend.map(|v| v.into()),
429+
num_vbuckets: value.bucket_settings.num_vbuckets,
422430
}
423431
}
424432
}

0 commit comments

Comments
 (0)