fix: remove trailing whitespace and formatting cleanup
- Remove trailing whitespace from multiple files - Minor formatting fixes across crates - Net reduction of 69 lines of whitespace Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
1f894b4dc2
commit
0033ad754f
30 changed files with 101 additions and 170 deletions
|
|
@ -99,7 +99,13 @@ fn bench_preflight_phase(c: &mut Criterion) {
|
|||
|
||||
for shard_count in [3, 5, 10, 20].iter() {
|
||||
let topo = make_test_topology(*shard_count, 2, 2);
|
||||
let plan = rt.block_on(plan_search_scatter(&topo, 0, 2, *shard_count, None::<&ReplicaSelector>));
|
||||
let plan = rt.block_on(plan_search_scatter(
|
||||
&topo,
|
||||
0,
|
||||
2,
|
||||
*shard_count,
|
||||
None::<&ReplicaSelector>,
|
||||
));
|
||||
|
||||
// Create mock client with preflight responses
|
||||
let mut client = MockNodeClient::default();
|
||||
|
|
@ -146,7 +152,13 @@ fn bench_preflight_phase(c: &mut Criterion) {
|
|||
fn bench_dfs_vs_standard_scatter(c: &mut Criterion) {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let topo = make_test_topology(64, 2, 2);
|
||||
let plan = rt.block_on(plan_search_scatter(&topo, 0, 2, 64, None::<&ReplicaSelector>));
|
||||
let plan = rt.block_on(plan_search_scatter(
|
||||
&topo,
|
||||
0,
|
||||
2,
|
||||
64,
|
||||
None::<&ReplicaSelector>,
|
||||
));
|
||||
|
||||
// Create mock client with search responses
|
||||
let mut client = MockNodeClient::default();
|
||||
|
|
|
|||
|
|
@ -167,9 +167,7 @@ fn bench_varying_node_count(c: &mut Criterion) {
|
|||
|
||||
/// Benchmark: Varying replication factors.
|
||||
fn bench_varying_rf(c: &mut Criterion) {
|
||||
let nodes: Vec<NodeId> = (0..10)
|
||||
.map(|i| NodeId::new(format!("node-{i}")))
|
||||
.collect();
|
||||
let nodes: Vec<NodeId> = (0..10).map(|i| NodeId::new(format!("node-{i}"))).collect();
|
||||
|
||||
let mut group = c.benchmark_group("varying_rf");
|
||||
for rf in [1, 2, 3, 5].iter() {
|
||||
|
|
|
|||
|
|
@ -254,9 +254,7 @@ impl CanaryRunner {
|
|||
|
||||
// Parse assertions
|
||||
let assertions: Vec<CanaryAssertion> = serde_json::from_str(&canary.assertions_json)
|
||||
.map_err(|e| {
|
||||
MiroirError::InvalidRequest(format!("Invalid canary assertions: {e}"))
|
||||
})?;
|
||||
.map_err(|e| MiroirError::InvalidRequest(format!("Invalid canary assertions: {e}")))?;
|
||||
|
||||
// Execute the search query against the index
|
||||
// Note: This would need to be wired to the actual search client
|
||||
|
|
@ -497,9 +495,8 @@ pub fn create_canary(
|
|||
name,
|
||||
index_uid,
|
||||
interval_s,
|
||||
query_json: serde_json::to_string(&query).map_err(|e| {
|
||||
MiroirError::InvalidRequest(format!("Failed to serialize query: {e}"))
|
||||
})?,
|
||||
query_json: serde_json::to_string(&query)
|
||||
.map_err(|e| MiroirError::InvalidRequest(format!("Failed to serialize query: {e}")))?,
|
||||
assertions_json: serde_json::to_string(&assertions).map_err(|e| {
|
||||
MiroirError::InvalidRequest(format!("Failed to serialize assertions: {e}"))
|
||||
})?,
|
||||
|
|
|
|||
|
|
@ -335,9 +335,7 @@ impl DriftReconciler {
|
|||
)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
MiroirError::Task(format!("failed to fetch settings for repair: {e}"))
|
||||
})?;
|
||||
.map_err(|e| MiroirError::Task(format!("failed to fetch settings for repair: {e}")))?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
return Err(MiroirError::Task(format!(
|
||||
|
|
@ -346,9 +344,10 @@ impl DriftReconciler {
|
|||
)));
|
||||
}
|
||||
|
||||
let correct_settings: Value = response.json().await.map_err(|e| {
|
||||
MiroirError::Task(format!("failed to parse settings for repair: {e}"))
|
||||
})?;
|
||||
let correct_settings: Value = response
|
||||
.json()
|
||||
.await
|
||||
.map_err(|e| MiroirError::Task(format!("failed to parse settings for repair: {e}")))?;
|
||||
|
||||
// PATCH the drifted node with correct settings
|
||||
let patch_url = format!(
|
||||
|
|
|
|||
|
|
@ -174,14 +174,12 @@ struct NodeIndexStats {
|
|||
pub stats: Option<NodeStatsDetail>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
struct NodeStatsDetail {
|
||||
#[serde(rename = "databaseSize", default)]
|
||||
pub database_size: u64,
|
||||
}
|
||||
|
||||
|
||||
/// Aggregated index stats across all nodes.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct IndexStats {
|
||||
|
|
@ -629,10 +627,8 @@ impl IlmWorker {
|
|||
Err(e) => {
|
||||
error!("ILM: rollover failed for policy '{}': {}", policy.name, e);
|
||||
// Mark the rollover as failed in the coordinator
|
||||
let _ = self
|
||||
.coordinator
|
||||
.fail(format!("rollover failed: {e}"))
|
||||
.await;
|
||||
let _ =
|
||||
self.coordinator.fail(format!("rollover failed: {e}")).await;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -690,9 +686,7 @@ impl IlmWorker {
|
|||
|
||||
let mut fired_triggers = Vec::new();
|
||||
if age_triggered {
|
||||
fired_triggers.push(format!(
|
||||
"max_age ({age_seconds}s >= {max_age_seconds}s)"
|
||||
));
|
||||
fired_triggers.push(format!("max_age ({age_seconds}s >= {max_age_seconds}s)"));
|
||||
}
|
||||
if docs_triggered {
|
||||
fired_triggers.push(format!(
|
||||
|
|
@ -905,9 +899,7 @@ impl IlmWorker {
|
|||
.json(&body)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
IlmError::RolloverFailed(format!("request to {url} failed: {e}"))
|
||||
})?;
|
||||
.map_err(|e| IlmError::RolloverFailed(format!("request to {url} failed: {e}")))?;
|
||||
|
||||
let status = response.status();
|
||||
let body_text = response
|
||||
|
|
|
|||
|
|
@ -128,8 +128,7 @@ impl JobType {
|
|||
}
|
||||
|
||||
/// Job progress tracking.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct JobProgress {
|
||||
/// Bytes processed so far (for dump import).
|
||||
pub bytes_processed: u64,
|
||||
|
|
@ -141,7 +140,6 @@ pub struct JobProgress {
|
|||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
/// Chunk specification for a job.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct JobChunk {
|
||||
|
|
|
|||
|
|
@ -201,8 +201,7 @@ impl QueryPlanner {
|
|||
));
|
||||
}
|
||||
|
||||
if filter.contains(&format!("{pk_field} != "))
|
||||
|| filter.contains(&format!("{pk_field}<>"))
|
||||
if filter.contains(&format!("{pk_field} != ")) || filter.contains(&format!("{pk_field}<>"))
|
||||
{
|
||||
return Err(MiroirError::InvalidState(
|
||||
"PK negation is not narrowable".to_string(),
|
||||
|
|
|
|||
|
|
@ -2312,9 +2312,7 @@ impl MigrationExecutor for HttpMigrationExecutor {
|
|||
.get("results")
|
||||
.and_then(|v| v.as_array())
|
||||
.ok_or_else(|| {
|
||||
format!(
|
||||
"Invalid response from {source_address}: missing 'results' field"
|
||||
)
|
||||
format!("Invalid response from {source_address}: missing 'results' field")
|
||||
})?;
|
||||
|
||||
let total = json_body.get("total").and_then(|v| v.as_u64()).unwrap_or(0);
|
||||
|
|
|
|||
|
|
@ -1648,9 +1648,7 @@ async fn two_phase_broadcast_settings(
|
|||
match result {
|
||||
Ok((address, hash)) => {
|
||||
if hash != expected_fingerprint {
|
||||
return Err(format!(
|
||||
"Phase 2 verify failed: hash mismatch on {address}"
|
||||
));
|
||||
return Err(format!("Phase 2 verify failed: hash mismatch on {address}"));
|
||||
}
|
||||
node_hashes.insert(address, hash);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,11 +314,9 @@ impl<C: NodeClient> ReshardExecutor<C> {
|
|||
|
||||
// Get a healthy node from topology for verification
|
||||
let topology = self.topology.read().await;
|
||||
let node = topology
|
||||
.nodes().find(|n| n.is_healthy())
|
||||
.ok_or_else(|| {
|
||||
MiroirError::Topology("No healthy nodes available for verification".to_string())
|
||||
})?;
|
||||
let node = topology.nodes().find(|n| n.is_healthy()).ok_or_else(|| {
|
||||
MiroirError::Topology("No healthy nodes available for verification".to_string())
|
||||
})?;
|
||||
let node_id = node.id.clone();
|
||||
let address = node.address.clone();
|
||||
drop(topology);
|
||||
|
|
|
|||
|
|
@ -697,9 +697,7 @@ impl TaskStore for RedisTaskStore {
|
|||
let key_prefix = self.key_prefix.clone();
|
||||
let index_uid = index_uid.to_string();
|
||||
let node_id = node_id.to_string();
|
||||
let key = format!(
|
||||
"{key_prefix}:node_settings_version:{index_uid}:{node_id}"
|
||||
);
|
||||
let key = format!("{key_prefix}:node_settings_version:{index_uid}:{node_id}");
|
||||
let index_key = format!("{key_prefix}:node_settings_version:_index");
|
||||
|
||||
self.block_on(async move {
|
||||
|
|
@ -732,9 +730,7 @@ impl TaskStore for RedisTaskStore {
|
|||
let key_prefix = self.key_prefix.clone();
|
||||
let index_uid = index_uid.to_string();
|
||||
let node_id = node_id.to_string();
|
||||
let key = format!(
|
||||
"{key_prefix}:node_settings_version:{index_uid}:{node_id}"
|
||||
);
|
||||
let key = format!("{key_prefix}:node_settings_version:{index_uid}:{node_id}");
|
||||
|
||||
self.block_on(async move {
|
||||
let mut conn = manager.lock().await;
|
||||
|
|
@ -3005,9 +3001,7 @@ impl RedisTaskStore {
|
|||
let key_prefix = self.key_prefix.clone();
|
||||
let pod_id = pod_id.to_string();
|
||||
let index_uid = index_uid.to_string();
|
||||
let key = format!(
|
||||
"{key_prefix}:search_ui_scoped_key_observed:{pod_id}:{index_uid}"
|
||||
);
|
||||
let key = format!("{key_prefix}:search_ui_scoped_key_observed:{pod_id}:{index_uid}");
|
||||
|
||||
self.block_on(async move {
|
||||
let mut pipe = pipe();
|
||||
|
|
@ -3037,9 +3031,8 @@ impl RedisTaskStore {
|
|||
let mut conn = manager.lock().await;
|
||||
|
||||
for pod_id in &live_pods {
|
||||
let key = format!(
|
||||
"{key_prefix}:search_ui_scoped_key_observed:{pod_id}:{index_uid}"
|
||||
);
|
||||
let key =
|
||||
format!("{key_prefix}:search_ui_scoped_key_observed:{pod_id}:{index_uid}");
|
||||
let fields: HashMap<String, Value> = conn
|
||||
.hgetall(&key)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ fn print_actual_hash_values() {
|
|||
for (key, shard_count) in fixtures {
|
||||
let hash = hash_for_key(key);
|
||||
let shard = shard_for_key(key, shard_count);
|
||||
println!(
|
||||
"(\"{key}\", {shard_count}, {shard}), // hash={hash}"
|
||||
);
|
||||
println!("(\"{key}\", {shard_count}, {shard}), // hash={hash}");
|
||||
}
|
||||
println!("========================\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,11 @@ async fn facet_aggregation() -> Result<(), Box<dyn std::error::Error>> {
|
|||
// Facet counts must sum to 100
|
||||
use meilisearch_sdk::search::Selectors;
|
||||
let facets = ["color"];
|
||||
let results: SearchResults<Value> = index.search().with_facets(Selectors::Some(&facets[..])).execute().await?;
|
||||
let results: SearchResults<Value> = index
|
||||
.search()
|
||||
.with_facets(Selectors::Some(&facets[..]))
|
||||
.execute()
|
||||
.await?;
|
||||
let facet_dist = results
|
||||
.facet_distribution
|
||||
.as_ref()
|
||||
|
|
@ -317,7 +321,11 @@ async fn offset_limit_paging() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let single_ids: HashSet<String> = single_page
|
||||
.hits
|
||||
.iter()
|
||||
.filter_map(|v| v.result.get("id").and_then(|id| id.as_str().map(|s| s.to_string())))
|
||||
.filter_map(|v| {
|
||||
v.result
|
||||
.get("id")
|
||||
.and_then(|id| id.as_str().map(|s| s.to_string()))
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Get 5 pages of 10
|
||||
|
|
@ -352,7 +360,11 @@ async fn offset_limit_paging() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let single_order: Vec<String> = single_page
|
||||
.hits
|
||||
.iter()
|
||||
.filter_map(|v| v.result.get("id").and_then(|id| id.as_str().map(|s| s.to_string())))
|
||||
.filter_map(|v| {
|
||||
v.result
|
||||
.get("id")
|
||||
.and_then(|id| id.as_str().map(|s| s.to_string()))
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut paged_order = Vec::new();
|
||||
|
|
@ -430,7 +442,10 @@ async fn settings_broadcast() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.with_query("bluetooth headphones")
|
||||
.execute()
|
||||
.await?;
|
||||
assert!(results.hits.len() >= 1, "Synonym search returned no results");
|
||||
assert!(
|
||||
results.hits.len() >= 1,
|
||||
"Synonym search returned no results"
|
||||
);
|
||||
|
||||
delete_index(&client, index_name).await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ async fn ac3_assertion_failure_includes_actual_value() {
|
|||
assert_eq!(failure["actual"], 2);
|
||||
|
||||
// Test multiple assertion types
|
||||
let failures = [serde_json::json!({
|
||||
let failures = [
|
||||
serde_json::json!({
|
||||
"assertion_type": "top_hit_id",
|
||||
"expected": "product-123",
|
||||
"actual": "product-456",
|
||||
|
|
@ -157,7 +158,8 @@ async fn ac3_assertion_failure_includes_actual_value() {
|
|||
"expected": 200,
|
||||
"actual": 350,
|
||||
"message": "Latency exceeded threshold"
|
||||
})];
|
||||
}),
|
||||
];
|
||||
|
||||
assert_eq!(failures.len(), 2);
|
||||
assert_eq!(failures[0]["assertion_type"], "top_hit_id");
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ struct DelayedMockNodeClient {
|
|||
delays: HashMap<NodeId, Duration>,
|
||||
}
|
||||
|
||||
|
||||
impl NodeClient for DelayedMockNodeClient {
|
||||
async fn search_node(
|
||||
&self,
|
||||
|
|
@ -439,9 +438,7 @@ async fn run_searches_with_latency(
|
|||
latencies.push(elapsed);
|
||||
}
|
||||
|
||||
println!(
|
||||
"Total hedges issued: {total_hedges} out of {count} queries"
|
||||
);
|
||||
println!("Total hedges issued: {total_hedges} out of {count} queries");
|
||||
|
||||
latencies
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,9 +229,7 @@ async fn p5_3_a3_exploration_samples_degraded_node() {
|
|||
let count1 = *dist.get("node-1").unwrap_or(&0);
|
||||
let count2 = *dist.get("node-2").unwrap_or(&0);
|
||||
|
||||
println!(
|
||||
"Distribution: node-0={count0}, node-1={count1}, node-2={count2}"
|
||||
);
|
||||
println!("Distribution: node-0={count0}, node-1={count1}, node-2={count2}");
|
||||
|
||||
// Node-2 is severely degraded but should still get some traffic via exploration
|
||||
// With 5% epsilon and random exploration across 3 nodes:
|
||||
|
|
|
|||
|
|
@ -332,10 +332,7 @@ mod regression_tests {
|
|||
|
||||
for (key, shard_count, expected) in cases {
|
||||
let actual = shard_for_key(key, shard_count);
|
||||
assert_eq!(
|
||||
actual, expected,
|
||||
"shard_for_key({key:?}, {shard_count})"
|
||||
);
|
||||
assert_eq!(actual, expected, "shard_for_key({key:?}, {shard_count})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1072,7 +1072,6 @@ fn epoch_seconds() -> u64 {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
||||
fn test_key() -> SealKey {
|
||||
SealKey::from_bytes([42u8; 32])
|
||||
|
|
|
|||
|
|
@ -214,9 +214,8 @@ impl NodeClient for HttpClient {
|
|||
}
|
||||
|
||||
// Parse successful response
|
||||
let json: Value = serde_json::from_str(&body_text).map_err(|e| {
|
||||
NodeError::NetworkError(format!("Failed to parse JSON response: {e}"))
|
||||
})?;
|
||||
let json: Value = serde_json::from_str(&body_text)
|
||||
.map_err(|e| NodeError::NetworkError(format!("Failed to parse JSON response: {e}")))?;
|
||||
|
||||
let duration_ms = start.elapsed().as_millis() as u64;
|
||||
tracing::debug!(
|
||||
|
|
@ -309,9 +308,8 @@ impl NodeClient for HttpClient {
|
|||
}
|
||||
|
||||
// Parse successful response
|
||||
let json: Value = serde_json::from_str(&body_text).map_err(|e| {
|
||||
NodeError::NetworkError(format!("Failed to parse JSON response: {e}"))
|
||||
})?;
|
||||
let json: Value = serde_json::from_str(&body_text)
|
||||
.map_err(|e| NodeError::NetworkError(format!("Failed to parse JSON response: {e}")))?;
|
||||
|
||||
Ok(DeleteResponse {
|
||||
success: true,
|
||||
|
|
@ -397,9 +395,8 @@ impl NodeClient for HttpClient {
|
|||
}
|
||||
|
||||
// Parse successful response
|
||||
let json: Value = serde_json::from_str(&body_text).map_err(|e| {
|
||||
NodeError::NetworkError(format!("Failed to parse JSON response: {e}"))
|
||||
})?;
|
||||
let json: Value = serde_json::from_str(&body_text)
|
||||
.map_err(|e| NodeError::NetworkError(format!("Failed to parse JSON response: {e}")))?;
|
||||
|
||||
Ok(DeleteResponse {
|
||||
success: true,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ use axum::{
|
|||
http::{HeaderMap, HeaderValue},
|
||||
middleware::Next,
|
||||
response::Response,
|
||||
routing::get, Router,
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
|
||||
use miroir_core::config::MiroirConfig;
|
||||
|
|
@ -70,11 +71,9 @@ impl RequestId {
|
|||
///
|
||||
/// Extracted from the `X-Miroir-Session` header and stored in request extensions.
|
||||
/// Handlers can access it via `Request.extensions().get::<SessionId>()`.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Default)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
|
||||
pub struct SessionId(pub String);
|
||||
|
||||
|
||||
impl SessionId {
|
||||
/// Get the inner session ID string.
|
||||
pub fn as_str(&self) -> &str {
|
||||
|
|
@ -1532,9 +1531,8 @@ impl Metrics {
|
|||
let metric_families = self.registry.gather();
|
||||
let mut buffer = Vec::new();
|
||||
encoder.encode(&metric_families, &mut buffer)?;
|
||||
String::from_utf8(buffer).map_err(|e| {
|
||||
prometheus::Error::Msg(format!("failed to convert metrics to UTF-8: {e}"))
|
||||
})
|
||||
String::from_utf8(buffer)
|
||||
.map_err(|e| prometheus::Error::Msg(format!("failed to convert metrics to UTF-8: {e}")))
|
||||
}
|
||||
|
||||
pub fn admin_session_key_generated(&self) -> Gauge {
|
||||
|
|
@ -2880,7 +2878,6 @@ mod tests {
|
|||
fn test_json_log_format_is_valid() {
|
||||
// Verify that tracing-subscriber's JSON layer produces valid JSON
|
||||
// This test ensures the log format matches plan §10 requirements
|
||||
|
||||
|
||||
// Build a JSON subscriber like the one in main.rs
|
||||
let subscriber = tracing_subscriber::fmt()
|
||||
|
|
|
|||
|
|
@ -1584,9 +1584,7 @@ where
|
|||
StatusCode::OK,
|
||||
[(
|
||||
"Set-Cookie",
|
||||
format!(
|
||||
"{COOKIE_NAME}=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0"
|
||||
),
|
||||
format!("{COOKIE_NAME}=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0"),
|
||||
)],
|
||||
Json(AdminLogoutResponse {
|
||||
success: true,
|
||||
|
|
@ -1633,9 +1631,7 @@ where
|
|||
StatusCode::OK,
|
||||
[(
|
||||
"Set-Cookie",
|
||||
format!(
|
||||
"{COOKIE_NAME}=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0"
|
||||
),
|
||||
format!("{COOKIE_NAME}=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0"),
|
||||
)],
|
||||
Json(AdminLogoutResponse {
|
||||
success: true,
|
||||
|
|
@ -1712,10 +1708,7 @@ where
|
|||
// Check if node already exists
|
||||
let node_id = NodeId::new(id.clone());
|
||||
if topo.node(&node_id).is_some() {
|
||||
return Err((
|
||||
StatusCode::BAD_REQUEST,
|
||||
format!("Node {id} already exists"),
|
||||
));
|
||||
return Err((StatusCode::BAD_REQUEST, format!("Node {id} already exists")));
|
||||
}
|
||||
// Check if replica group exists
|
||||
let group_count = topo.groups().count() as u32;
|
||||
|
|
@ -2555,9 +2548,7 @@ where
|
|||
.ok_or_else(|| {
|
||||
(
|
||||
StatusCode::PRECONDITION_FAILED,
|
||||
format!(
|
||||
"Group {group_id} is not ready for activation (sync not complete)"
|
||||
),
|
||||
format!("Group {group_id} is not ready for activation (sync not complete)"),
|
||||
)
|
||||
})?;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ use axum::{
|
|||
http::StatusCode,
|
||||
Json,
|
||||
};
|
||||
use miroir_core::{
|
||||
alias::AliasKind,
|
||||
config::MiroirConfig,
|
||||
task_store::TaskStore,
|
||||
};
|
||||
use miroir_core::{alias::AliasKind, config::MiroirConfig, task_store::TaskStore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -512,9 +508,6 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_create_alias_request_single() {
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_changes_query_params_default_limit() {
|
||||
|
|
|
|||
|
|
@ -401,8 +401,7 @@ async fn write_documents_impl(
|
|||
};
|
||||
|
||||
// 1. Extract primary key from first document if not provided
|
||||
let primary_key =
|
||||
primary_key.or_else(|| documents.first().and_then(extract_primary_key));
|
||||
let primary_key = primary_key.or_else(|| documents.first().and_then(extract_primary_key));
|
||||
|
||||
let primary_key = primary_key.ok_or_else(|| {
|
||||
MeilisearchError::new(
|
||||
|
|
@ -450,9 +449,7 @@ async fn write_documents_impl(
|
|||
if doc.get(&primary_key).is_none() {
|
||||
return Err(MeilisearchError::new(
|
||||
MiroirCode::PrimaryKeyRequired,
|
||||
format!(
|
||||
"document at index {i} missing primary key field `{primary_key}`"
|
||||
),
|
||||
format!("document at index {i} missing primary key field `{primary_key}`"),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -1215,10 +1212,7 @@ fn build_response_with_degraded_header(
|
|||
|
||||
// Add X-Miroir-Degraded header if any groups were degraded
|
||||
if degraded_groups > 0 {
|
||||
builder = builder.header(
|
||||
HEADER_MIROIR_DEGRADED,
|
||||
format!("groups={degraded_groups}"),
|
||||
);
|
||||
builder = builder.header(HEADER_MIROIR_DEGRADED, format!("groups={degraded_groups}"));
|
||||
}
|
||||
|
||||
builder.body(axum::body::Body::from(body)).map_err(|e| {
|
||||
|
|
@ -1320,9 +1314,7 @@ mod tests {
|
|||
let field = "_miroir_expires_at";
|
||||
let err = MeilisearchError::new(
|
||||
MiroirCode::ReservedField,
|
||||
format!(
|
||||
"document contains reserved field `{field}` (reserved when ttl.enabled: true)"
|
||||
),
|
||||
format!("document contains reserved field `{field}` (reserved when ttl.enabled: true)"),
|
||||
);
|
||||
assert_eq!(err.code, "miroir_reserved_field");
|
||||
assert_eq!(err.http_status(), 400);
|
||||
|
|
|
|||
|
|
@ -167,10 +167,7 @@ where
|
|||
);
|
||||
|
||||
let status = manager.get_status(&id).await.ok_or_else(|| {
|
||||
MeilisearchError::new(
|
||||
MiroirCode::NotFound,
|
||||
format!("import task not found: {id}"),
|
||||
)
|
||||
MeilisearchError::new(MiroirCode::NotFound, format!("import task not found: {id}"))
|
||||
})?;
|
||||
|
||||
// Record metrics from status
|
||||
|
|
|
|||
|
|
@ -306,9 +306,7 @@ async fn check_unfilterable_attributes(
|
|||
if !filterable_attrs.contains(&attr) {
|
||||
warnings.push(Warning::UnfilterableAttribute {
|
||||
attribute: attr.clone(),
|
||||
suggestion: format!(
|
||||
"add '{attr}' to filterableAttributes or remove from filter"
|
||||
),
|
||||
suggestion: format!("add '{attr}' to filterableAttributes or remove from filter"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -333,9 +331,7 @@ fn extract_attributes_from_filter(filter: &str) -> Vec<String> {
|
|||
let known_attrs = vec!["id", "sku", "category", "price", "status", "tenant"];
|
||||
|
||||
for attr in known_attrs {
|
||||
if filter_lower.contains(&attr.to_string())
|
||||
|| filter_lower.contains(&attr.to_string())
|
||||
{
|
||||
if filter_lower.contains(&attr.to_string()) || filter_lower.contains(&attr.to_string()) {
|
||||
attrs.push(attr.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,9 +359,8 @@ async fn create_index_handler(
|
|||
Ok((status, text)) => {
|
||||
// Rollback: delete index on all previously created nodes
|
||||
rollback_delete_index(&client, uid, &created_on).await;
|
||||
let msg = format!(
|
||||
"index creation failed on node {address}: HTTP {status} — {text}"
|
||||
);
|
||||
let msg =
|
||||
format!("index creation failed on node {address}: HTTP {status} — {text}");
|
||||
return Err(forward_or_miroir(status, &text, &msg));
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -566,9 +565,7 @@ async fn update_index_handler(
|
|||
}
|
||||
Ok((status, text)) => {
|
||||
rollback_index_update(&client, &path, &snapshots, &applied).await;
|
||||
let msg = format!(
|
||||
"index update failed on {address}: HTTP {status} — {text}"
|
||||
);
|
||||
let msg = format!("index update failed on {address}: HTTP {status} — {text}");
|
||||
return Err(forward_or_miroir(status, &text, &msg));
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -746,10 +743,7 @@ pub async fn global_stats_handler(
|
|||
.get_raw(first_address, "/indexes")
|
||||
.await
|
||||
.map_err(|e| {
|
||||
MeilisearchError::new(
|
||||
MiroirCode::NoQuorum,
|
||||
format!("failed to list indexes: {e}"),
|
||||
)
|
||||
MeilisearchError::new(MiroirCode::NoQuorum, format!("failed to list indexes: {e}"))
|
||||
})?;
|
||||
|
||||
if !(200..300).contains(&status) {
|
||||
|
|
@ -776,12 +770,10 @@ pub async fn global_stats_handler(
|
|||
if let Some(n) = stats.get("numberOfDocuments").and_then(|v| v.as_u64()) {
|
||||
total_docs += n;
|
||||
}
|
||||
if let Some(fd) = stats.get("fieldDistribution").and_then(|v| v.as_object())
|
||||
{
|
||||
if let Some(fd) = stats.get("fieldDistribution").and_then(|v| v.as_object()) {
|
||||
for (field, count) in fd {
|
||||
if let Some(c) = count.as_u64() {
|
||||
*total_field_distribution.entry(field.clone()).or_insert(0) +=
|
||||
c;
|
||||
*total_field_distribution.entry(field.clone()).or_insert(0) += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1173,9 +1165,7 @@ async fn update_settings_broadcast_legacy(
|
|||
return Err(forward_or_miroir(
|
||||
status,
|
||||
&text,
|
||||
&format!(
|
||||
"failed to snapshot settings on {address}: HTTP {status}"
|
||||
),
|
||||
&format!("failed to snapshot settings on {address}: HTTP {status}"),
|
||||
));
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -1202,9 +1192,7 @@ async fn update_settings_broadcast_legacy(
|
|||
Ok((status, text)) => {
|
||||
// Rollback all previously applied nodes
|
||||
rollback_settings(&client, &full_path, &snapshots, &applied).await;
|
||||
let msg = format!(
|
||||
"settings update failed on {address}: HTTP {status} — {text}"
|
||||
);
|
||||
let msg = format!("settings update failed on {address}: HTTP {status} — {text}");
|
||||
return Err(forward_or_miroir(status, &text, &msg));
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ async fn create_key_handler(
|
|||
Ok((status, text)) => {
|
||||
// Rollback: delete key on all previously created nodes
|
||||
rollback_delete_key(&client, &body, &created_on).await;
|
||||
let msg = format!(
|
||||
"key creation failed on {address}: HTTP {status} — {text}"
|
||||
);
|
||||
let msg = format!("key creation failed on {address}: HTTP {status} — {text}");
|
||||
return Err(forward_or_miroir(status, &text, &msg));
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -167,9 +165,7 @@ async fn update_key_handler(
|
|||
}
|
||||
Ok((status, text)) => {
|
||||
rollback_key_update(&client, &path, &snapshots, &applied).await;
|
||||
let msg = format!(
|
||||
"key update failed on {address}: HTTP {status} — {text}"
|
||||
);
|
||||
let msg = format!("key update failed on {address}: HTTP {status} — {text}");
|
||||
return Err(forward_or_miroir(status, &text, &msg));
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use std::time::Instant;
|
|||
use tokio::sync::RwLock;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
|
||||
/// Multi-search state.
|
||||
#[derive(Clone)]
|
||||
pub struct MultiSearchState {
|
||||
|
|
|
|||
|
|
@ -412,9 +412,7 @@ where
|
|||
StatusCode::OK,
|
||||
[(
|
||||
"Set-Cookie",
|
||||
format!(
|
||||
"{COOKIE_NAME}=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0"
|
||||
),
|
||||
format!("{COOKIE_NAME}=; HttpOnly; Secure; SameSite=Strict; Path=/; Max-Age=0"),
|
||||
)],
|
||||
Json(serde_json::json!({
|
||||
"success": true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue