Commit Graph

14 Commits

Author SHA1 Message Date
C J Silverio e34dcfdc25
feature(async): Add tokio as an executor option (#36)
This PR is based on the work @alexschrod did in PR #29. All
I did was carry it over the finish line.

This PR adds a feature to the crate named `tokio-runtime`. If
you disable default features and enable this new one, cacache
uses tokio as its async executor. This makes integrating cacache
with tokio-using projects easier, because the file types leak out
if you use anything more than the top-level convenience functions.

The PR implements the feature using shims in a new submodule named
`async_lib`. This module conditionally uses either async-std
or tokio based on feature selection, and hides some differences with
convenience functions.

This change should not be a breaking change, because the default is
still async-std.

There are a few other small changes in this PR worth noting.

- The README shows how to switch runtimes.
- There's a justfile to run common tasks, including those in makefile.toml.
  The default shell is `sh`, so this might not work out of the box for
  Windows users.
- The tests can now run under either runtime. The justfile has a recipe
  that runs them both.
- The benchmarks can also run under either runtime. The justfile has two
  recipe for this, one using bench and the other using criterion's runner.
- The dependencies now pull in async-attributes by default along with
  async-std. This made it easier to swap runtimes in the tests.
- All dependency versions have been bumped.

Co-authored-by: @alexschrod
2023-01-28 13:01:59 -08:00
C J Silverio 6d84ff0aed
fix(write): set tmpfile length in async writer (#35)
Fixes: https://github.com/zkat/cacache-rs/issues/34

The async `poll_write()` implementation was creating a tempfile as
a backing for its inner mmap, but it was failing to set the length
on the file to match the incoming data. Compare with the sync
implementation!

This bug was exposed when the `memmap2` crate was swapped in
for `memmap`. The older crate was likely more lax about this.

Wrote a pair of new tests for `cacache::write_hash_sync` and
`cacache::write_hash`. The async test fails without this change, as
does any benchmarks run. Everything passes with it.

BREAKING CHANGE: This commit also bumps the MSRV for cacache to 1.66.1.
2023-01-23 17:37:34 -08:00
Kat Marchán 9c3cf994ec
misc: cargo fmt 2021-09-15 20:32:18 -07:00
Kat Marchán 8d08e45298
fix(clippy): appease the paperclip 2021-09-15 19:57:58 -07:00
Kat Marchán 803d0c3ede
feat(write): Use mmap for small writes (#26)
BREAKING CHANGE: This bumps the minimum Rust version from 1.39 to 1.43. Thanks, remove_dir_all! >:(
2020-07-18 10:43:38 -07:00
Kat Marchán 743476b274
feat(api): rewrite entire API to be like std::fs (#21)
Fixes: #13

BREAKING CHANGE: The entire API surface has been rewritten and overhauled. Instead of breaking up the package into get/put/rm/ls modules, everything is now available mostly through the toplevel module, following the same conventions as std:fs for its operations. Associated structs and other types have also been renamed. Please refer to the documentation for the new API, and I hope you find it more ergonomic!
2019-10-23 21:17:57 -07:00
Kat Marchán aec50e9b23
bench: add benchmarks for multiple reads 2019-10-18 00:33:48 -04:00
Kat Marchán 398773547b
benchmarks: add baseline comparison benchmarks for regular i/o 2019-10-17 22:24:24 -04:00
Kat Marchán 662aea9b5a feat(async): reorganize async APIs to be the primary APIs
BREAKING CHANGE: the async_* namespaces are gone, and all the previously-sync APIs (get::data, put::data, etc), are all suffixed with _sync now. You'll need to adjust your usage accordingly.
2019-10-17 18:25:20 -04:00
Kat Marchán b02f41e07f feat(api): get::read -> get::data
This should improve the ergonomics a bit by being more symmetrical with put

BREAKING CHANGE: The `get` API now uses "data" instead of "read" as the "verb". You will need to change anything that used get::read/hash/etc to use "data" now.
2019-10-17 18:25:20 -04:00
Kat Marchán 18190bfc35
feat(async): add extra async versions of APIs (#6) 2019-10-13 20:06:20 -04:00
Kat Marchán 473473e6b2
feat(license): relicense under MPL-2.0 (#8)
BREAKING CHANGE: The license terms have changed. Please refer to LICENSE in the root of this repository for details. Future use of this library may require release of source code for any changes applied to it.
2019-09-06 21:39:36 -07:00
Kat Marchán bc56a1b3fe
fix(fmt): cargo fmt 2019-06-26 21:41:44 -07:00
Kat Marchán 5a57d46b3f
test: added basic benchmark test 2019-06-07 01:32:39 -07:00