From 46acbeb2cee2fb7f024b6ff5943bdfdb6cc53151 Mon Sep 17 00:00:00 2001 From: Ben Dean-Kawamura Date: Wed, 12 Jun 2024 15:34:30 -0400 Subject: [PATCH] Adding SuggestBuilder.remote_settings_bucket_name 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. --- CHANGELOG.md | 8 +++++++ components/suggest/src/store.rs | 37 +++++++++--------------------- components/suggest/src/suggest.udl | 3 +-- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 411f78c96b..df0c375672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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_) diff --git a/components/suggest/src/store.rs b/components/suggest/src/store.rs index b546e57cb7..caec897487 100644 --- a/components/suggest/src/store.rs +++ b/components/suggest/src/store.rs @@ -38,7 +38,7 @@ pub struct SuggestStoreBuilder(Mutex); struct SuggestStoreBuilderInner { data_path: Option, remote_settings_server: Option, - remote_settings_config: Option, + remote_settings_bucket_name: Option, } impl Default for SuggestStoreBuilder { @@ -62,13 +62,13 @@ impl SuggestStoreBuilder { self } - pub fn remote_settings_config(self: Arc, config: RemoteSettingsConfig) -> Arc { - self.0.lock().remote_settings_config = Some(config); + pub fn remote_settings_server(self: Arc, server: RemoteSettingsServer) -> Arc { + self.0.lock().remote_settings_server = Some(server); self } - pub fn remote_settings_server(self: Arc, server: RemoteSettingsServer) -> Arc { - self.0.lock().remote_settings_server = Some(server); + pub fn remote_settings_bucket_name(self: Arc, bucket_name: String) -> Arc { + self.0.lock().remote_settings_bucket_name = Some(bucket_name); self } @@ -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 { diff --git a/components/suggest/src/suggest.udl b/components/suggest/src/suggest.udl index e359c5bfc5..d890c89a1e 100644 --- a/components/suggest/src/suggest.udl +++ b/components/suggest/src/suggest.udl @@ -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();