Skip to content

Commit

Permalink
feat(fs-index): push watch API dependencies behind a feature flag
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Sep 16, 2024
1 parent 1fe0731 commit 94bcd25
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ark-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lazy_static = "1.4.0"
canonical-path = "2.0.2"


fs-index = { path = "../fs-index" }
fs-index = { path = "../fs-index", features = ["watch"] }
fs-atomic-versions = { path = "../fs-atomic-versions" }
fs-metadata = { path = "../fs-metadata" }
fs-properties = { path = "../fs-properties" }
Expand Down
14 changes: 9 additions & 5 deletions fs-index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ anyhow = "1.0.58"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
# For the watch API
notify = "6.1"
notify-debouncer-full = "0.3"
futures = "0.3"
async-stream = "0.3"
tokio = { version = "1.40", features = ["full"] }
notify = { version = "6.1", optional = true }
notify-debouncer-full = { version = "0.3", optional = true }
futures = { version = "0.3", optional = true }
async-stream = { version = "0.3", optional = true }
tokio = { version = "1.40", features = ["full"], optional = true }


fs-storage = { path = "../fs-storage" }

data-error = { path = "../data-error" }
data-resource = { path = "../data-resource" }


[features]
watch = ["notify", "notify-debouncer-full", "futures", "async-stream", "tokio"]

[dev-dependencies]
uuid = { version = "1.6.1", features = ["v4"] }
# benchmarking
Expand Down
2 changes: 1 addition & 1 deletion fs-index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The most important struct in this crate is `ResourceIndex` which comes with:
- `get_resource_by_path`: Query a resource from the index by its path.
- **Selective API**
- `update_one`: Method to manually update a specific resource by selectively rescanning a single file.
- **Watch API**
- **Watch API** (Enable with `watch` feature)
- `watch`: Method to watch a directory for changes and update the index accordingly.

> **Note:** To see the watch API in action, run the `index_watch` example or check `ark-cli watch` command.
Expand Down
2 changes: 2 additions & 0 deletions fs-index/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod index;
mod serde;
mod utils;
#[cfg(feature = "watch")]
mod watch;

pub use index::{IndexUpdate, ResourceIndex};
pub use utils::load_or_build_index;
#[cfg(feature = "watch")]
pub use watch::{watch_index, WatchEvent};

#[cfg(test)]
Expand Down

0 comments on commit 94bcd25

Please sign in to comment.