Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

style: cargo fmt the RC4 stream-D fix sites (es_compat keep-alive caps, engine)

xerj-orgade762aef437
diff --git a/engine/crates/xerj-api/src/es_compat.rs b/engine/crates/xerj-api/src/es_compat.rs
index b650fc25b..9e4e21235 100644
--- a/engine/crates/xerj-api/src/es_compat.rs
+++ b/engine/crates/xerj-api/src/es_compat.rs
@@ -13230,8 +13230,7 @@ pub async fn next_scroll(
.or(params.scroll.as_deref())
.and_then(parse_keep_alive_to_secs)
{
- let capped =
- ka_secs.min(state.config.search_context.scroll_max_keep_alive_secs);
+ let capped = ka_secs.min(state.config.search_context.scroll_max_keep_alive_secs);
ctx.keep_alive = std::time::Duration::from_secs(capped);
}
ctx.expires_at = now + ctx.keep_alive;
@@ -22739,8 +22738,7 @@ pub async fn async_search_get(
.as_deref()
.and_then(parse_keep_alive_to_secs)
{
- let capped =
- ka_secs.min(state.config.search_context.async_max_keep_alive_secs);
+ let capped = ka_secs.min(state.config.search_context.async_max_keep_alive_secs);
entry["expiration_time_in_millis"] = json!(now_ms + (capped as i64) * 1000);
}
Json(entry.clone()).into_response()
diff --git a/engine/crates/xerj-engine/src/engine.rs b/engine/crates/xerj-engine/src/engine.rs
index 6dd36b0b6..61bed7f36 100644
--- a/engine/crates/xerj-engine/src/engine.rs
+++ b/engine/crates/xerj-engine/src/engine.rs
@@ -447,22 +447,23 @@ impl Engine {
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| "unknown".to_string());
- Err(EngineError::Common(xerj_common::XerjError::config(format!(
- "data dir '{}' is already in use by another running xerj process \
+ Err(EngineError::Common(xerj_common::XerjError::config(
+ format!(
+ "data dir '{}' is already in use by another running xerj process \
(pid {holder}, lock file '{}') — refusing to start. Two processes \
serving one data dir would replay each other's WAL and corrupt \
segments; stop the other process or point this one at its own \
server.data_dir.",
- data_dir.display(),
- lock_path.display(),
- ))))
+ data_dir.display(),
+ lock_path.display(),
+ ),
+ )))
+ }
+ Err(std::fs::TryLockError::Error(e)) => {
+ Err(EngineError::Common(xerj_common::XerjError::config(
+ format!("failed to acquire node lock '{}': {e}", lock_path.display()),
+ )))
}
- Err(std::fs::TryLockError::Error(e)) => Err(EngineError::Common(
- xerj_common::XerjError::config(format!(
- "failed to acquire node lock '{}': {e}",
- lock_path.display()
- )),
- )),
}
}
@@ -572,9 +573,8 @@ impl Engine {
fn spawn_search_context_sweeper(&self) {
let scrolls = Arc::clone(&self.scrolls);
let async_searches = Arc::clone(&self.async_searches);
- let interval = std::time::Duration::from_secs(
- self.config.search_context.sweep_interval_secs.max(1),
- );
+ let interval =
+ std::time::Duration::from_secs(self.config.search_context.sweep_interval_secs.max(1));
tokio::spawn(async move {
let mut tick = tokio::time::interval(interval);
// Skip the immediate first tick — Engine::new just ran, so