-
SummaryHi, I have:
---
title: The world's best technical spec
---
flowchart LR
db["htmlDB: HTML Axum store"]
pages["viewCalculator: calculate latest HTML"]
ui["UI: pesky users and their pesky browsers"]
ui-- "pollMultipleTimesPerSecond(userId) /GET" -->db
pages-- "pushOnExternalChanges(userId, html) /POST" -->db
I'd really like to get some caching going using
My question for 2. is about data races - what prevents the file being updated externally/by htmlDB/POST between ServeDir reading the file's meta data and then reading the contents? Does ServeDir allow locking the file first? I should also say the contents of any files will be encrypted (in memory first) and writes can be fairly atomic using the "write to file/rename" idiom. What are your thoughts? Thanks! axum versionHEAD |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I would recommend you to copy the parts of Though if you do want to write temporary files to disk, I can recommend the |
Beta Was this translation helpful? Give feedback.
I would recommend you to copy the parts of
tower-http
'sServeDir
that make sense for your use case. It sounds like you wouldn't otherwise need to write files to disk, so it seems weird to do that only to be able to useServeDir
.Though if you do want to write temporary files to disk, I can recommend the
atomic-write-file
crate as a way to achieve that, it pulls some neat and useful tricks beyond what you'd find in a home-grown write-with-temporary-name-then-rename implementation.