Struct glean_core::upload::PingUploadManager
source · pub struct PingUploadManager { /* private fields */ }
Expand description
Manages the pending pings queue and directory.
Implementations§
source§impl PingUploadManager
impl PingUploadManager
sourcepub fn scan_pending_pings_directories(
&self,
trigger_upload: bool
) -> JoinHandle<()>
pub fn scan_pending_pings_directories( &self, trigger_upload: bool ) -> JoinHandle<()>
Spawns a new thread and processes the pending pings directories, filling up the queue with whatever pings are in there.
Returns
The JoinHandle
to the spawned thread
sourcepub fn enqueue_ping(&self, glean: &Glean, ping: PingPayload)
pub fn enqueue_ping(&self, glean: &Glean, ping: PingPayload)
Enqueue a ping for upload.
sourcepub fn set_rate_limiter(&mut self, interval: u64, max_tasks: u32)
pub fn set_rate_limiter(&mut self, interval: u64, max_tasks: u32)
Adds rate limiting capability to this upload manager.
The rate limiter will limit the amount of calls to get_upload_task
per interval.
Setting this will restart count and timer in case there was a previous rate limiter set (e.g. if we have reached the current limit and call this function, we start counting again and the caller is allowed to asks for tasks).
Arguments
interval
- the amount of seconds in each rate limiting window.max_tasks
- the maximum amount of task requests allowed per interval.
sourcepub fn enqueue_ping_from_file(&self, glean: &Glean, document_id: &str)
pub fn enqueue_ping_from_file(&self, glean: &Glean, document_id: &str)
Reads a ping file, creates a PingRequest
and adds it to the queue.
Duplicate requests won’t be added.
Arguments
glean
- The Glean object holding the database.document_id
- The UUID of the ping in question.
sourcepub fn clear_ping_queue(&self) -> RwLockWriteGuard<'_, VecDeque<PingRequest>>
pub fn clear_ping_queue(&self) -> RwLockWriteGuard<'_, VecDeque<PingRequest>>
Clears the pending pings queue, leaves the deletion-request pings.
sourcepub fn get_upload_task(&self, glean: &Glean, log_ping: bool) -> PingUploadTask
pub fn get_upload_task(&self, glean: &Glean, log_ping: bool) -> PingUploadTask
Gets the next PingUploadTask
.
Arguments
glean
- The Glean object holding the database.log_ping
- Whether to log the ping before returning.
Returns
The next PingUploadTask
.
sourcepub fn process_ping_upload_response(
&self,
glean: &Glean,
document_id: &str,
status: UploadResult
) -> UploadTaskAction
pub fn process_ping_upload_response( &self, glean: &Glean, document_id: &str, status: UploadResult ) -> UploadTaskAction
Processes the response from an attempt to upload a ping.
Based on the HTTP status of said response, the possible outcomes are:
-
200 - 299 Success Any status on the 2XX range is considered a succesful upload, which means the corresponding ping file can be deleted. Known 2XX status:
- 200 - OK. Request accepted into the pipeline.
-
400 - 499 Unrecoverable error Any status on the 4XX range means something our client did is not correct. It is unlikely that the client is going to recover from this by retrying, so in this case the corresponding ping file can also be deleted. Known 4XX status:
- 404 - not found - POST/PUT to an unknown namespace
- 405 - wrong request type (anything other than POST/PUT)
- 411 - missing content-length header
- 413 - request body too large Note that if we have badly-behaved clients that retry on 4XX, we should send back 202 on body/path too long).
- 414 - request path too long (See above)
-
Any other error For any other error, a warning is logged and the ping is re-enqueued. Known other errors:
- 500 - internal error
Note
The disk I/O performed by this function is not done off-thread, as it is expected to be called off-thread by the platform.
Arguments
glean
- The Glean object holding the database.document_id
- The UUID of the ping in question.status
- The HTTP status of the response.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for PingUploadManager
impl Send for PingUploadManager
impl Sync for PingUploadManager
impl Unpin for PingUploadManager
impl UnwindSafe for PingUploadManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Read more