feat: add ETag to track the changed status of an object on the server #14
feat: add ETag to track the changed status of an object on the server #14thuongle2210 wants to merge 9 commits intoCogitatorTech:mainfrom
Conversation
|
hi @habedi , I implemented the Etag to track the changed status of an object on the server. It accomplishes that the synchronization between local and remote files. Could you pls help me review this PR? |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Are these libraries (added in the infera/Cargo.toml) needed as main dependencies? It seems to me they are needed for tests.
| .create(); | ||
| let url = format!("{}/ok_model.onnx", server.url()); | ||
| #[actix_web::test] | ||
| async fn test_remote_model_download_and_cache_with_etag_enabled() { |
There was a problem hiding this comment.
Can we use mockito instead of actix-web, and make all the tests blocking (no async test)? TBH I think using actix-web is a bit of over-engineering at the moment.
There was a problem hiding this comment.
Let me research this, because I want to simulate a real-world situation. That's why I chose actix-web, which supports ETag generation.
| } | ||
|
|
||
| #[actix_web::test] | ||
| async fn test_remote_model_download_and_cache_with_etag_disabled() { |
There was a problem hiding this comment.
Can we use mockito instead of actix-web, and make all the tests blocking (no async test)? TBH I think using actix-web is a bit of over-engineering at the moment.
| hex = "0.4" | ||
| filetime = "0.2" | ||
|
|
||
| tokio = { version = "1", features = ["full"] } |
There was a problem hiding this comment.
I think we don't need tokio, especially with all of its features enabled. I think, at the moment, Infera itself doesn't do anything that requires an async IO runtime.
Summary
Version:
latest version
Resolve for issues:
issues-13
Changes
Fixes the bug by adding proper ETag validation before assuming the local cache is valid.
Ensures that cached files are only reused if the server confirms no changes via ETag.
Otherwise, downloads the updated file and updates the cache accordingly.
Add test cases covering both scenarios: server-side support for ETag and lack of ETag support.
Refactor other test cases in http.rs file
Impact