Skip to content

Remove in the next version non-exitant experimental feature #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1649,8 +1649,8 @@ get_experimental_features_1: |-
.unwrap();
update_experimental_features_1: |-
let client = Client::new("http://localhost:7700", Some("apiKey"));
let mut features = ExperimentalFeatures::new(&client);
features.set_vector_store(true);
let features = ExperimentalFeatures::new(&client);
// update the feature you want here
let res = features
.update()
.await
Expand Down
45 changes: 10 additions & 35 deletions src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use serde::{Deserialize, Serialize};
/// Struct representing the experimental features result from the API.
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExperimentalFeaturesResult {
pub vector_store: bool,
}
pub struct ExperimentalFeaturesResult {}

/// Struct representing the experimental features request.
///
Expand All @@ -24,29 +22,18 @@ pub struct ExperimentalFeaturesResult {
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
/// let mut features = ExperimentalFeatures::new(&client);
/// features.set_vector_store(true);
/// ```
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ExperimentalFeatures<'a, Http: HttpClient> {
#[serde(skip_serializing)]
client: &'a Client<Http>,
#[serde(skip_serializing_if = "Option::is_none")]
pub vector_store: Option<bool>,
}

impl<'a, Http: HttpClient> ExperimentalFeatures<'a, Http> {
#[must_use]
pub fn new(client: &'a Client<Http>) -> Self {
ExperimentalFeatures {
client,
vector_store: None,
}
}

pub fn set_vector_store(&mut self, vector_store: bool) -> &mut Self {
self.vector_store = Some(vector_store);
self
ExperimentalFeatures { client }
}

/// Get all the experimental features
Expand Down Expand Up @@ -83,11 +70,10 @@ impl<'a, Http: HttpClient> ExperimentalFeatures<'a, Http> {
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
/// tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
/// let mut features = ExperimentalFeatures::new(&client);
/// features.set_vector_store(true);
/// features.update().await.unwrap();
/// });
/// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
/// let features = ExperimentalFeatures::new(&client);
/// features.update().await.unwrap();
/// # });
/// ```
pub async fn update(&self) -> Result<ExperimentalFeaturesResult, Error> {
self.client
Expand All @@ -111,22 +97,11 @@ mod tests {

#[meilisearch_test]
async fn test_experimental_features_get(client: Client) {
let mut features = ExperimentalFeatures::new(&client);
features.set_vector_store(false);
let features = ExperimentalFeatures::new(&client);
// set feature here, once some exist again
let _ = features.update().await.unwrap();

let res = features.get().await.unwrap();

assert!(!res.vector_store);
}

#[meilisearch_test]
async fn test_experimental_features_enable_vector_store(client: Client) {
let mut features = ExperimentalFeatures::new(&client);
features.set_vector_store(true);

let res = features.update().await.unwrap();

assert!(res.vector_store);
let _res = features.get().await.unwrap();
// assert that the feature has been set once they exist again
}
}
2 changes: 1 addition & 1 deletion src/tenant_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn generate_tenant_token(
return Err(Error::InvalidUuid4Version);
}

if expires_at.map_or(false, |expires_at| OffsetDateTime::now_utc() > expires_at) {
if expires_at.is_some_and(|expires_at| OffsetDateTime::now_utc() > expires_at) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

return Err(Error::TenantTokensExpiredSignature);
}

Expand Down