Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion rust/cocoindex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ default = ["legacy-states-v0"]
legacy-states-v0 = []

[dependencies]
cocoindex_utils = { path = "../utils" }
cocoindex_utils = { path = "../utils", features = [
"bytes_decode",
"reqwest",
"openai",
"neo4rs",
"sqlx",
"yaml",
] }
cocoindex_py_utils = { path = "../py_utils" }

pyo3 = { workspace = true }
Expand Down
23 changes: 16 additions & 7 deletions rust/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@ tokio = { workspace = true }
tokio-util = { workspace = true }
futures = { workspace = true }
blake2 = { workspace = true }
reqwest = { workspace = true }
async-openai = { workspace = true }
neo4rs = { workspace = true }
sqlx = { workspace = true }
encoding_rs = { workspace = true }
regex = { workspace = true }
itertools = { workspace = true }
indexmap = { workspace = true }
hex = { workspace = true }
serde_path_to_error = { workspace = true }
rand = { workspace = true }
yaml-rust2 = { workspace = true }
indenter = { workspace = true }

encoding_rs = { workspace = true, optional = true }
reqwest = { workspace = true, optional = true }
async-openai = { workspace = true, optional = true }
neo4rs = { workspace = true, optional = true }
sqlx = { workspace = true, optional = true }
yaml-rust2 = { workspace = true, optional = true }

[features]
default = []
reqwest = ["dep:reqwest"]
openai = ["dep:async-openai", "reqwest"]
neo4rs = ["dep:neo4rs"]
sqlx = ["dep:sqlx"]
yaml = ["dep:yaml-rust2"]
bytes_decode = ["dep:encoding_rs"]
9 changes: 7 additions & 2 deletions rust/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
pub mod batching;
pub mod bytes_decode;
pub mod concur_control;
pub mod db;
pub mod deser;
pub mod error;
pub mod fingerprint;
pub mod http;
pub mod immutable;
pub mod retryable;

#[cfg(feature = "bytes_decode")]
pub mod bytes_decode;
#[cfg(feature = "reqwest")]
pub mod http;
#[cfg(feature = "sqlx")]
pub mod str_sanitize;
#[cfg(feature = "yaml")]
pub mod yaml_ser;
3 changes: 3 additions & 0 deletions rust/utils/src/retryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ impl IsRetryable for Error {
}
}

#[cfg(feature = "reqwest")]
impl IsRetryable for reqwest::Error {
fn is_retryable(&self) -> bool {
self.status() == Some(reqwest::StatusCode::TOO_MANY_REQUESTS)
}
}

// OpenAI errors - retryable if the underlying reqwest error is retryable
#[cfg(feature = "openai")]
impl IsRetryable for async_openai::error::OpenAIError {
fn is_retryable(&self) -> bool {
match self {
Expand All @@ -50,6 +52,7 @@ impl IsRetryable for async_openai::error::OpenAIError {
}

// Neo4j errors - retryable on connection errors and transient errors
#[cfg(feature = "neo4rs")]
impl IsRetryable for neo4rs::Error {
fn is_retryable(&self) -> bool {
match self {
Expand Down
Loading