Skip to content

Commit

Permalink
better split tantivy
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Jul 24, 2024
1 parent 5355af4 commit 7047e29
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
4 changes: 2 additions & 2 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ flow_testing = ["windmill-worker/flow_testing"]
openidconnect = ["windmill-api/openidconnect"]
cloud = ["windmill-queue/cloud", "windmill-worker/cloud"]
jemalloc = ["windmill-common/jemalloc", "dep:tikv-jemallocator", "dep:tikv-jemalloc-sys", "dep:tikv-jemalloc-ctl"]
tantivy = ["windmill-indexer/tantivy"]
tantivy = ["dep:windmill-indexer", "windmill-api/tantivy"]

[dependencies]
anyhow.workspace = true
Expand All @@ -64,7 +64,7 @@ windmill-common = { workspace = true, default-features = false }
windmill-git-sync.workspace = true
windmill-api = { workspace = true, default-features = false }
windmill-worker.workspace = true
windmill-indexer.workspace = true
windmill-indexer = { workspace = true, optional = true }
futures.workspace = true
tracing.workspace = true
sqlx.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion backend/ee-repo-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
89e36e9e73596926e9e02ce27aa7db14d840a255
c2d059cfff5afcd4a2e87b606f899a5c752d4057
27 changes: 17 additions & 10 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,26 +367,33 @@ Windmill Community Edition {GIT_VERSION}
let should_index_jobs =
mode == Mode::Indexer || (enable_standalone_indexer && mode == Mode::Standalone);

#[cfg(not(feature = "tantivy"))]
let should_index_jobs = false;

#[cfg(feature = "tantivy")]
let (index_reader, index_writer) = if should_index_jobs {
let (r, w) = windmill_indexer::indexer_ee::init_index().await?;
(Some(r), Some(w))
} else {
(None, None)
};

let indexer_rx = killpill_rx.resubscribe();
let index_writer2 = index_writer.clone();
let indexer_f = async {
if let Some(index_writer) = index_writer2 {
windmill_indexer::indexer_ee::run_indexer(db.clone(), index_writer, indexer_rx)
.await;
#[cfg(feature = "tantivy")]
let indexer_f = {
let indexer_rx = killpill_rx.resubscribe();
let index_writer2 = index_writer.clone();
async {
if let Some(index_writer) = index_writer2 {
windmill_indexer::indexer_ee::run_indexer(db.clone(), index_writer, indexer_rx)
.await;
}
Ok(())
}
Ok(())
};

#[cfg(not(feature = "tantivy"))]
let (index_reader, index_writer) = (None, None);

#[cfg(not(feature = "tantivy"))]
let indexer_f = async { Ok(()) as anyhow::Result<()> };

let server_f = async {
if !is_agent {
windmill_api::run_server(
Expand Down
3 changes: 2 additions & 1 deletion backend/windmill-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ embedding = ["dep:tinyvector", "dep:hf-hub", "dep:tokenizers", "dep:candle-core"
parquet = ["dep:datafusion", "dep:object_store", "dep:url", "windmill-common/parquet"]
prometheus = ["windmill-common/prometheus", "windmill-queue/prometheus", "dep:prometheus"]
openidconnect = ["dep:openidconnect"]
tantivy = ["dep:windmill-indexer"]

[dependencies]
windmill-queue.workspace = true
Expand All @@ -27,7 +28,7 @@ windmill-parser.workspace = true
windmill-parser-py-imports.workspace = true
windmill-parser-ts.workspace = true
windmill-git-sync.workspace = true
windmill-indexer.workspace = true
windmill-indexer = { workspace = true, optional = true }
tokio.workspace = true
anyhow.workspace = true
argon2.workspace = true
Expand Down
15 changes: 13 additions & 2 deletions backend/windmill-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,22 @@ pub async fn add_webhook_allowed_origin(
next.run(req).await
}

#[cfg(not(feature = "tantivy"))]
type IndexReader = ();

#[cfg(not(feature = "tantivy"))]
type IndexWriter = ();

#[cfg(feature = "tantivy")]
type IndexReader = windmill_indexer::indexer_ee::IndexReader;
#[cfg(feature = "tantivy")]
type IndexWriter = windmill_indexer::indexer_ee::IndexWriter;

pub async fn run_server(
db: DB,
rsmq: Option<rsmq_async::MultiplexedRsmq>,
index_reader: Option<windmill_indexer::indexer_ee::IndexReader>,
index_writer: Option<windmill_indexer::indexer_ee::IndexWriter>,
index_reader: Option<IndexReader>,
index_writer: Option<IndexWriter>,
addr: SocketAddr,
mut rx: tokio::sync::broadcast::Receiver<()>,
port_tx: tokio::sync::oneshot::Sender<String>,
Expand Down
3 changes: 1 addition & 2 deletions backend/windmill-indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ path = "src/lib.rs"

[features]
default = []
tantivy = ["dep:tantivy"]
parquet = ["dep:object_store"]
enterprise = []

[dependencies]
windmill-common.workspace = true
tantivy = {workspace = true, optional = true}
tantivy.workspace = true
tokio.workspace = true
sqlx.workspace = true
anyhow.workspace = true
Expand Down

0 comments on commit 7047e29

Please sign in to comment.