Skip to content

Commit

Permalink
Adding SuggestBuilder.remote_settings_bucket_name
Browse files Browse the repository at this point in the history
I just realized that the JS consumer wants to set the bucket name.  They
currently use the `remote_settings_config` method to do this, but it's
deprecated so we need to give them an alternative.
  • Loading branch information
bendk committed Jun 13, 2024
1 parent 5982870 commit 46acbeb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# v129.0 (In progress)

## ⚠️ Breaking Changes ⚠️

### Suggest
- Removed the deprecated `remote_settings_config` method. No consumers were using this.

## ✨ What's New ✨

### Suggest
- Added the `SuggestStoreBuilder.remote_settings_bucket_name` as a way to specify the bucket name.

[Full Changelog](In progress)

# v128.0 (_2024-06-10_)
Expand Down
37 changes: 11 additions & 26 deletions components/suggest/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct SuggestStoreBuilder(Mutex<SuggestStoreBuilderInner>);
struct SuggestStoreBuilderInner {
data_path: Option<String>,
remote_settings_server: Option<RemoteSettingsServer>,
remote_settings_config: Option<RemoteSettingsConfig>,
remote_settings_bucket_name: Option<String>,
}

impl Default for SuggestStoreBuilder {
Expand All @@ -62,13 +62,13 @@ impl SuggestStoreBuilder {
self
}

pub fn remote_settings_config(self: Arc<Self>, config: RemoteSettingsConfig) -> Arc<Self> {
self.0.lock().remote_settings_config = Some(config);
pub fn remote_settings_server(self: Arc<Self>, server: RemoteSettingsServer) -> Arc<Self> {
self.0.lock().remote_settings_server = Some(server);
self
}

pub fn remote_settings_server(self: Arc<Self>, server: RemoteSettingsServer) -> Arc<Self> {
self.0.lock().remote_settings_server = Some(server);
pub fn remote_settings_bucket_name(self: Arc<Self>, bucket_name: String) -> Arc<Self> {
self.0.lock().remote_settings_bucket_name = Some(bucket_name);
self
}

Expand All @@ -79,27 +79,12 @@ impl SuggestStoreBuilder {
.data_path
.clone()
.ok_or_else(|| Error::SuggestStoreBuilder("data_path not specified".to_owned()))?;
let remote_settings_config = match (
inner.remote_settings_server.as_ref(),
inner.remote_settings_config.as_ref(),
) {
(Some(server), None) => RemoteSettingsConfig {
server: Some(server.clone()),
server_url: None,
bucket_name: None,
collection_name: REMOTE_SETTINGS_COLLECTION.into(),
},
(None, Some(remote_settings_config)) => remote_settings_config.clone(),
(None, None) => RemoteSettingsConfig {
server: None,
server_url: None,
bucket_name: None,
collection_name: REMOTE_SETTINGS_COLLECTION.into(),
},
(Some(_), Some(_)) => Err(Error::SuggestStoreBuilder(
"can't specify both `remote_settings_server` and `remote_settings_config`"
.to_owned(),
))?,

let remote_settings_config = RemoteSettingsConfig {
server: inner.remote_settings_server.clone(),
bucket_name: inner.remote_settings_bucket_name.clone(),
server_url: None,
collection_name: REMOTE_SETTINGS_COLLECTION.into(),
};
let settings_client = remote_settings::Client::new(remote_settings_config)?;
Ok(Arc::new(SuggestStore {
Expand Down
3 changes: 1 addition & 2 deletions components/suggest/src/suggest.udl
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ interface SuggestStoreBuilder {
[Self=ByArc]
SuggestStoreBuilder remote_settings_server(RemoteSettingsServer server);

// Deprecated: Use `remote_settings_server()` instead.
[Self=ByArc]
SuggestStoreBuilder remote_settings_config(RemoteSettingsConfig config);
SuggestStoreBuilder remote_settings_bucket_name(string bucket_name);

[Throws=SuggestApiError]
SuggestStore build();
Expand Down

0 comments on commit 46acbeb

Please sign in to comment.