Skip to main content

Module queue_manager

Module queue_manager 

Source
Expand description

Manages upload queue orchestration, retry persistence, and sync-index updates.

A configurable pool of async workers drains the upload queue in parallel. Failed tasks are moved to a retry queue with exponential back-off. The queue pauses automatically when environment policies (metered network, battery power, quiet hours) are active, and resumes when conditions clear.

Structsยง

BatchNotifyState ๐Ÿ”’
EnvironmentPolicy
FileTask
Represents a unit of work for the upload queue.
QueueManager

Functionsยง

activate_batch_if_needed ๐Ÿ”’
add_to_album_with_retry ๐Ÿ”’
apply_active_state ๐Ÿ”’
apply_idle_state ๐Ÿ”’
batch_is_ready_to_notify ๐Ÿ”’
batch_notification_summary ๐Ÿ”’
check_batch_notification ๐Ÿ”’
clear_stale_batch_schedule ๐Ÿ”’
current_attempt_count ๐Ÿ”’
Get current sync attempt count for a path based on recent events history.
finalize_upload_progress ๐Ÿ”’
Finalize upload progress: update counters, detect queue idle, return batch ID if a summary notification should be scheduled.
handle_upload ๐Ÿ”’
Upload or reassociate a file, then ensure the resulting asset is present in the target album.
infer_album_name ๐Ÿ”’
Infer target album name from directory structure segment.
is_quiet_hour ๐Ÿ”’
Returns true if the current local clock hour falls inside the configured quiet window.
load_retries ๐Ÿ”’
Load historical list of failed tasks from retries cache.
record_upload_failure ๐Ÿ”’
Record state updates after a failed upload.
record_upload_success ๐Ÿ”’
Activate a batch tracking window if none is currently active. Record state updates after a successful upload.
resolve_album_id ๐Ÿ”’
Resolve the album ID from either an explicit task ID or by name lookup.
resolve_final_asset_id ๐Ÿ”’
save_retries ๐Ÿ”’
Persist current list of failed items to retries cache.
schedule_batch_notification ๐Ÿ”’
Spawn a debounced batch-notification task.
track_consecutive_failures ๐Ÿ”’
Track consecutive failures and fire a connectivity-lost notification after 3+.
unix_timestamp_now ๐Ÿ”’
Return current epoch timestamp in seconds.
upload_progress_callback ๐Ÿ”’
Helper to generate progress callback callbacks that update global transfer metrics.
wait_until_allowed ๐Ÿ”’
Pause worker processing loops until environment checks and manual pauses permit resume.