mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	Add new experimental feature
This commit is contained in:
		| @@ -86,6 +86,19 @@ impl RoFeatures { | ||||
|             .into()) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     pub fn check_network(&self, disabled_action: &'static str) -> Result<()> { | ||||
|         if self.runtime.network { | ||||
|             Ok(()) | ||||
|         } else { | ||||
|             Err(FeatureNotEnabledError { | ||||
|                 disabled_action, | ||||
|                 feature: "network", | ||||
|                 issue_link: "https://github.com/orgs/meilisearch/discussions/805", | ||||
|             } | ||||
|             .into()) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl FeatureData { | ||||
|   | ||||
| @@ -7,6 +7,7 @@ pub struct RuntimeTogglableFeatures { | ||||
|     pub logs_route: bool, | ||||
|     pub edit_documents_by_function: bool, | ||||
|     pub contains_filter: bool, | ||||
|     pub network: bool, | ||||
| } | ||||
|  | ||||
| #[derive(Default, Debug, Clone, Copy)] | ||||
|   | ||||
| @@ -196,6 +196,7 @@ struct Infos { | ||||
|     experimental_reduce_indexing_memory_usage: bool, | ||||
|     experimental_max_number_of_batched_tasks: usize, | ||||
|     experimental_limit_batched_tasks_total_size: u64, | ||||
|     experimental_network: bool, | ||||
|     gpu_enabled: bool, | ||||
|     db_path: bool, | ||||
|     import_dump: bool, | ||||
| @@ -286,6 +287,7 @@ impl Infos { | ||||
|             logs_route, | ||||
|             edit_documents_by_function, | ||||
|             contains_filter, | ||||
|             network, | ||||
|         } = features; | ||||
|  | ||||
|         // We're going to override every sensible information. | ||||
| @@ -303,6 +305,7 @@ impl Infos { | ||||
|             experimental_replication_parameters, | ||||
|             experimental_enable_logs_route: experimental_enable_logs_route | logs_route, | ||||
|             experimental_reduce_indexing_memory_usage, | ||||
|             experimental_network: network, | ||||
|             gpu_enabled: meilisearch_types::milli::vector::is_cuda_enabled(), | ||||
|             db_path: db_path != PathBuf::from("./data.ms"), | ||||
|             import_dump: import_dump.is_some(), | ||||
|   | ||||
| @@ -50,6 +50,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { | ||||
|             logs_route: Some(false), | ||||
|             edit_documents_by_function: Some(false), | ||||
|             contains_filter: Some(false), | ||||
|             network: Some(false), | ||||
|         })), | ||||
|         (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( | ||||
|             { | ||||
| @@ -88,6 +89,8 @@ pub struct RuntimeTogglableFeatures { | ||||
|     pub edit_documents_by_function: Option<bool>, | ||||
|     #[deserr(default)] | ||||
|     pub contains_filter: Option<bool>, | ||||
|     #[deserr(default)] | ||||
|     pub network: Option<bool>, | ||||
| } | ||||
|  | ||||
| impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogglableFeatures { | ||||
| @@ -97,6 +100,7 @@ impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogg | ||||
|             logs_route, | ||||
|             edit_documents_by_function, | ||||
|             contains_filter, | ||||
|             network, | ||||
|         } = value; | ||||
|  | ||||
|         Self { | ||||
| @@ -104,6 +108,7 @@ impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogg | ||||
|             logs_route: Some(logs_route), | ||||
|             edit_documents_by_function: Some(edit_documents_by_function), | ||||
|             contains_filter: Some(contains_filter), | ||||
|             network: Some(network), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -114,6 +119,7 @@ pub struct PatchExperimentalFeatureAnalytics { | ||||
|     logs_route: bool, | ||||
|     edit_documents_by_function: bool, | ||||
|     contains_filter: bool, | ||||
|     network: bool, | ||||
| } | ||||
|  | ||||
| impl Aggregate for PatchExperimentalFeatureAnalytics { | ||||
| @@ -127,6 +133,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics { | ||||
|             logs_route: new.logs_route, | ||||
|             edit_documents_by_function: new.edit_documents_by_function, | ||||
|             contains_filter: new.contains_filter, | ||||
|             network: new.network, | ||||
|         }) | ||||
|     } | ||||
|  | ||||
| @@ -149,6 +156,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics { | ||||
|             logs_route: Some(false), | ||||
|             edit_documents_by_function: Some(false), | ||||
|             contains_filter: Some(false), | ||||
|             network: Some(false), | ||||
|          })), | ||||
|         (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( | ||||
|             { | ||||
| @@ -181,6 +189,7 @@ async fn patch_features( | ||||
|             .edit_documents_by_function | ||||
|             .unwrap_or(old_features.edit_documents_by_function), | ||||
|         contains_filter: new_features.0.contains_filter.unwrap_or(old_features.contains_filter), | ||||
|         network: new_features.0.network.unwrap_or(old_features.network), | ||||
|     }; | ||||
|  | ||||
|     // explicitly destructure for analytics rather than using the `Serialize` implementation, because | ||||
| @@ -191,6 +200,7 @@ async fn patch_features( | ||||
|         logs_route, | ||||
|         edit_documents_by_function, | ||||
|         contains_filter, | ||||
|         network, | ||||
|     } = new_features; | ||||
|  | ||||
|     analytics.publish( | ||||
| @@ -199,6 +209,7 @@ async fn patch_features( | ||||
|             logs_route, | ||||
|             edit_documents_by_function, | ||||
|             contains_filter, | ||||
|             network, | ||||
|         }, | ||||
|         &req, | ||||
|     ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user