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
10 changes: 10 additions & 0 deletions rust/cocoindex/src/ops/factory_bases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ pub trait BatchedFunctionExecutor: Send + Sync + Sized + 'static {
None
}

fn timeout(&self) -> Option<std::time::Duration> {
None
}

fn into_fn_executor(self) -> impl SimpleFunctionExecutor {
BatchedFunctionExecutorWrapper::new(self)
}
Expand All @@ -403,16 +407,19 @@ struct BatchedFunctionExecutorWrapper<E: BatchedFunctionExecutor> {
batcher: batching::Batcher<BatchedFunctionExecutorRunner<E>>,
enable_cache: bool,
behavior_version: Option<u32>,
timeout: Option<std::time::Duration>,
}

impl<E: BatchedFunctionExecutor> BatchedFunctionExecutorWrapper<E> {
fn new(executor: E) -> Self {
let batching_options = executor.batching_options();
let enable_cache = executor.enable_cache();
let behavior_version = executor.behavior_version();
let timeout = executor.timeout();
Self {
enable_cache,
behavior_version,
timeout,
batcher: batching::Batcher::new(
BatchedFunctionExecutorRunner(executor),
batching_options,
Expand All @@ -433,6 +440,9 @@ impl<E: BatchedFunctionExecutor> SimpleFunctionExecutor for BatchedFunctionExecu
fn behavior_version(&self) -> Option<u32> {
self.behavior_version
}
fn timeout(&self) -> Option<std::time::Duration> {
self.timeout
}
}

////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions rust/cocoindex/src/ops/py_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ impl BatchedFunctionExecutor for PyBatchedFunctionExecutor {
fn behavior_version(&self) -> Option<u32> {
self.behavior_version
}
fn timeout(&self) -> Option<std::time::Duration> {
self.timeout
}
fn batching_options(&self) -> batching::BatchingOptions {
self.batching_options.clone()
}
Expand Down
Loading