Generic purpose append only log implementation.
[
][Github-url]
[
][CI-url]
[
][codecov-url]
[
][doc-url]
[
][crates-url]
[
][crates-url]
English | [简体中文][zh-cn-url]
## Introducation
When developing infrastructure softwares, write-ahead log or append-only log plays an important role, and people re-implement same
funcationalities multiple times, but actually, the core for append-only log is just atomic `append`, `append_batch`, `replay`, and `rewrite`.
This crate provides generic purpose append-only log implementation based on `std::fs::File`.
- `aol::fs::AppendLog`:
Generic purpose append-only log implementation based on `std::fs::File`.
- It is good for:
- The encoded entry size is smaller than `64` bytes.
- Manifest file.
- Write is not too frequently.
- Pros:
- It is growable, do not require pre-allocated.
- Support automatically rewrite.
- No holes in the file.
### File Structure
```text
+----------------------+--------------------------+-----------------------+
| magic text (4 bytes) | external magic (2 bytes) | magic (2 bytes) |
+----------------------+--------------------------+-----------------------+-----------------------+-----------------------+
| op (1 bit) | custom flag (7 bits) | len (4 bytes) | data (N bytes) | checksum (8 bytes) |
+----------------------+--------------------------+-----------------------+-----------------------+-----------------------+
| op (1 bit) | custom flag (7 bits) | len (4 bytes) | data (N bytes) | checksum (8 bytes) |
+----------------------+--------------------------+-----------------------+-----------------------+-----------------------+
| ... | ... | ... | ... | ... |
+----------------------+--------------------------+-----------------------+-----------------------+-----------------------+
```
## Installation
```toml
[dependencies]
aol = "0.3"
```
## Example
- [Manifest file for bitcask database](./examples/bitcask_manifest.rs)
#### License
`aol` is under the terms of both the MIT license and the
Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT) for details.
Copyright (c) 2024 Al Liu.
[Github-url]: https://github.com/al8n/aol/
[CI-url]: https://github.com/al8n/aol/actions/workflows/ci.yml
[doc-url]: https://docs.rs/aol
[crates-url]: https://crates.io/crates/aol
[codecov-url]: https://app.codecov.io/gh/al8n/aol/
[zh-cn-url]: https://github.com/al8n/aol/tree/main/README-zh_CN.md