2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-10 06:25:00 +00:00

Instrument upload store methods

This commit is contained in:
asonix 2022-09-25 18:46:50 -05:00
parent 51d8621015
commit 21e3e63ac3

View file

@ -281,11 +281,13 @@ impl CachedRepo for SledRepo {
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl UploadRepo for SledRepo { impl UploadRepo for SledRepo {
#[tracing::instrument(skip(self))]
async fn create(&self, upload_id: UploadId) -> Result<(), Error> { async fn create(&self, upload_id: UploadId) -> Result<(), Error> {
b!(self.uploads, uploads.insert(upload_id.as_bytes(), b"1")); b!(self.uploads, uploads.insert(upload_id.as_bytes(), b"1"));
Ok(()) Ok(())
} }
#[tracing::instrument(skip(self))]
async fn wait(&self, upload_id: UploadId) -> Result<UploadResult, Error> { async fn wait(&self, upload_id: UploadId) -> Result<UploadResult, Error> {
let mut subscriber = self.uploads.watch_prefix(upload_id.as_bytes()); let mut subscriber = self.uploads.watch_prefix(upload_id.as_bytes());
@ -318,11 +320,13 @@ impl UploadRepo for SledRepo {
Err(UploadError::Canceled.into()) Err(UploadError::Canceled.into())
} }
#[tracing::instrument(skip(self))]
async fn claim(&self, upload_id: UploadId) -> Result<(), Error> { async fn claim(&self, upload_id: UploadId) -> Result<(), Error> {
b!(self.uploads, uploads.remove(upload_id.as_bytes())); b!(self.uploads, uploads.remove(upload_id.as_bytes()));
Ok(()) Ok(())
} }
#[tracing::instrument(skip(self, result))]
async fn complete(&self, upload_id: UploadId, result: UploadResult) -> Result<(), Error> { async fn complete(&self, upload_id: UploadId, result: UploadResult) -> Result<(), Error> {
let result: InnerUploadResult = result.into(); let result: InnerUploadResult = result.into();
let result = serde_json::to_vec(&result)?; let result = serde_json::to_vec(&result)?;