-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better tasking less locks #318
Better tasking less locks #318
Conversation
// .service( | ||
// web::scope("/thumbnail") | ||
// // Add a rate limitter to prevent flood | ||
// .wrap( | ||
// RateLimiter::builder( | ||
// InMemoryBackend::builder().build(), | ||
// SimpleInputFunctionBuilder::new(std::time::Duration::from_secs(1), 4) | ||
// .real_ip_key() | ||
// .build(), | ||
// ) | ||
// .add_headers() | ||
// .build(), | ||
// ) | ||
// .route("", web::get().to(pages::thumbnail)), | ||
// ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be reworked with care to work with only one worker...
// #[api_v2_operation] | ||
// /// Provides a thumbnail file of the given source | ||
// pub async fn thumbnail(thumbnail_file_request: web::Query<ThumbnailFileRequest>) -> HttpResponse { | ||
// Ideally, we should be using `actix_web_validator::Query` instead of `web::Query`, | ||
// but because paperclip (at least until 0.8) is using `actix-web-validator 3.x`, | ||
// and `validator 0.14`, the newest api needed to use it along #[api_v2_operation] | ||
// wasn't implemented yet, it doesn't compile. | ||
// To workaround this, we are manually calling the validator here, using actix to | ||
// automatically handle the validation error for us as it normally would. | ||
// TODO: update this function to use `actix_web_validator::Query` directly and get | ||
// rid of this workaround. | ||
// if let Err(errors) = thumbnail_file_request.validate() { | ||
// warn!("Failed validating ThumbnailFileRequest. Reason: {errors:?}"); | ||
// return actix_web::ResponseError::error_response(&actix_web_validator::Error::from(errors)); | ||
// } | ||
|
||
// let source = thumbnail_file_request.source.clone(); | ||
// let quality = thumbnail_file_request.quality.unwrap_or(70u8); | ||
// let target_height = thumbnail_file_request.target_height.map(|v| v as u32); | ||
|
||
// match stream_manager::get_jpeg_thumbnail_from_source(source, quality, target_height).await { | ||
// Some(Ok(image)) => HttpResponse::Ok().content_type("image/jpeg").body(image), | ||
// None => HttpResponse::NotFound() | ||
// .content_type("text/plain") | ||
// .body(format!( | ||
// "Thumbnail not found for source {:?}.", | ||
// thumbnail_file_request.source | ||
// )), | ||
// Some(Err(error)) => HttpResponse::ServiceUnavailable() | ||
// .reason("Thumbnail temporarily unavailable") | ||
// .insert_header((header::RETRY_AFTER, 10)) | ||
// .content_type("text/plain") | ||
// .body(format!( | ||
// "Thumbnail for source {:?} is temporarily unavailable. Try again later. Details: {error:?}", | ||
// thumbnail_file_request.source | ||
// )), | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be reworked with care to work with only one worker...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if you add the shutdown mechanism on top of this patch, your test will fail. If you have a while loop inside the drop, you need to allow more workers. |
Indeed the method does not work with this approach, I'll check if there other ways for us to investigate this. |
5d3c4fd
to
6e70998
Compare
Superposed by #377 |
merge after #303