Auto flush
provide.foundation.file.operations.detectors.auto_flush
¶
Auto-flush handler for streaming file operation detection.
Handles automatic flushing of pending events after a time window, with temp file filtering and operation emission callbacks.
Classes¶
AutoFlushHandler
¶
AutoFlushHandler(
time_window_ms: float,
on_operation_complete: Any = None,
analyze_func: Any = None,
)
Handles automatic flushing of pending events with temp file filtering.
Thread-safe: Uses internal locking to protect shared state from concurrent access. Multiple threads can safely call add_event() simultaneously.
Initialize auto-flush handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_window_ms
|
float
|
Time window in milliseconds for event grouping |
required |
on_operation_complete
|
Any
|
Callback function(operation: FileOperation) |
None
|
analyze_func
|
Any
|
Function to analyze event groups and detect operations |
None
|
Source code in provide/foundation/file/operations/detectors/auto_flush.py
Attributes¶
failed_operations_count
property
¶
Get count of failed operations awaiting retry.
Thread-safe: Uses internal locking.
pending_events
property
¶
Get pending events (read-only access).
Thread-safe: Returns a copy to prevent external modification.
Functions¶
add_event
¶
Add event and schedule auto-flush.
Thread-safe: Uses internal locking for concurrent add_event() calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
FileEvent
|
File event to buffer for processing |
required |
Source code in provide/foundation/file/operations/detectors/auto_flush.py
clear
¶
Clear pending events and cancel timer.
Thread-safe: Uses internal locking.
Source code in provide/foundation/file/operations/detectors/auto_flush.py
clear_failed_operations
¶
Clear all failed operations (data loss - use carefully).
Thread-safe: Uses internal locking.
Returns:
| Type | Description |
|---|---|
int
|
Number of operations that were cleared |
Source code in provide/foundation/file/operations/detectors/auto_flush.py
get_failed_operations
¶
Get copy of failed operations list for inspection.
Thread-safe: Returns a copy.
retry_failed_operations
¶
Retry failed operations.
Thread-safe: Uses internal locking.
Returns:
| Type | Description |
|---|---|
int
|
Number of operations successfully retried |
Source code in provide/foundation/file/operations/detectors/auto_flush.py
schedule_flush
¶
Schedule auto-flush timer (public interface).
Thread-safe: Uses internal locking.