-
Notifications
You must be signed in to change notification settings - Fork 14
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
RW: add a new function "allocate" which reserves some space for a new file #34
Conversation
I guess there's still the question how the API should look like. The use case is that one task does a HTTP download and save it to disk -- the size of the artifact is extracted from the HTTP header. While that download is in progress, the archive should not be served to a client (otherwise that would be corrupt). So, either the application itself needs to keep a set of keys not to hand out to clients, or there should be another piece of API that resembles the application to say "I'm finished with writing this artifact, it can now be used in the wild". Maybe it can be as simple as the left return value is a function |
This sounds interesting for that use case! Concerning the API, it really seems to be like |
I think Another function I think we can implement in tar would be a streaming write: type writer = (Cstruct.t -> (unit, write_error) result Lwt.t) -> unit Lwt.t
val write_stream : t -> key -> writer -> (unit, write_error) result Lwt.t
(** [write_stream t key writer] calls [writer] with a function that writes a file incrementally.
The file will be committed once [writer] returns. *) The return type of While we're adding to I think it is worth keeping in mind that we are allowed to add functions in implementations without adding them in |
While I agree that implementations can extend the interface, I find an The underlying semantics are a bit tricky, on the one hand with tar in mind, I'd like a HTTP download to directly push data to disk, on the other hand I'd like only fully checksummed data to be present on disk. This means, an allocate should write the header (but maybe use .part as filename) - and simultaneous allocate(s) are possible - but only when finished the header is for real written (i.e. with the right fileame), and reading is only then possible. If the power fails during any point, we'll be stuck with a broken / bad part on disk (that fortunately doesn't have the expected filename). Then again, inventing filenames isn't good as well, since a user may want to have both WDYT? So (a) implement Together with #37 I'd like to get this into the next major version of mirage-kv. |
Reading back the documentation I'm now not sure about the The man page for |
…last modified timestamp) for a new file. This is especially useful for append-only stores and set_partial.
I updated this PR: rebased onto the main branch, and used an Int63.t for the size. I added a second commit to use Ptime.t instead of the |
any opinion/approval of this PR? |
CHANGES: * Use ptime directly for RO.last_modified, instead of the int * int64 pair (mirage/mirage-kv#34) * Add RW.allocate to allocate a key and fill it with zero bytes (mirage/mirage-kv#34) * RO.list: return Key.t instead of string (mirage/mirage-kv#37, fixes mirage/mirage-kv#33) * Introduce a custom error for RW.rename with a source which is a prefix of destination (mirage/mirage-kv#37, fixes mirage/mirage-kv#31) * Use Optint.Int63.t for RO.size, RO.get_partial, RO.set_partial (mirage/mirage-kv#37, fixes mirage/mirage-kv#32) * Remove RW.batch (mirage/mirage-kv#37, fixes mirage/mirage-kv#29 mirage/mirage-kv#36, discussed at the MirageOS meeting in November, and on the mirageos-devel mailing list in January 2022) * Key.pp: escape the entire string, not individual fragments (mirage/mirage-kv#35)
This is especially useful for append-only stores and set_partial.
//cc @reynir @palainp