2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 19:31:35 +00:00

Add timeout, metrics to external validation request

This commit is contained in:
asonix 2023-09-20 19:29:19 -05:00
parent 0690041684
commit 7df6f3906e

View file

@ -1,10 +1,11 @@
use std::sync::Arc; use std::{sync::Arc, time::Duration};
use crate::{ use crate::{
bytes_stream::BytesStream, bytes_stream::BytesStream,
either::Either, either::Either,
error::{Error, UploadError}, error::{Error, UploadError},
formats::{InternalFormat, Validations}, formats::{InternalFormat, Validations},
future::WithMetrics,
repo::{Alias, ArcRepo, DeleteToken, Hash}, repo::{Alias, ArcRepo, DeleteToken, Hash},
store::Store, store::Store,
}; };
@ -122,10 +123,12 @@ where
let response = client let response = client
.post(endpoint.as_str()) .post(endpoint.as_str())
.timeout(Duration::from_secs(media.external_validation_timeout))
.header("Content-Type", input_type.media_type().as_ref()) .header("Content-Type", input_type.media_type().as_ref())
.body(Body::wrap_stream(crate::stream::make_send(stream))) .body(Body::wrap_stream(crate::stream::make_send(stream)))
.send() .send()
.instrument(tracing::info_span!("external-validation")) .instrument(tracing::info_span!("external-validation"))
.with_metrics("pict-rs.ingest.external-validation")
.await?; .await?;
if !response.status().is_success() { if !response.status().is_success() {