Fusio Log
fusio-log is an append-only log library for Rust. Leveraging fusio, fusio-log supports various backends like disk, wasm, and S3.
For those unfamiliar with the database, the key difference between fusio-log and other "logging" crates is that fusio-log not only supports writing logs through the write and write_batch methods, but also allows reading logs via the recover method.
This crate is designed to build database components like write-ahead logging or metadata storage, fusio-log supports transactional write/read via write_batch, ensuring that logs in the same batch are recovered together.
For further more, please read https://datatechnologytoday.wordpress.com/2014/02/10/the-log-is-the-database/.
Usage
- Define data structure.
- Implement
EncodeandDecodetrait for it. - Start to use fusio-log.
async
Recover from log file:
let stream = new
.
.await
.unwrap;
while let Ok = stream.try_next.await
Use with S3
let path = from_url_path.unwrap;
let option = new.fs;
let mut logger = option..await.unwrap;
logger
.write
.await
.unwrap;
Use in Wasm
Please make sure disable default features and enable web feature.
= { = "https://github.com/tonbo-io/fusio-log", = false, = ["bytes", "web"]}
Then, use Path::from_opfs_path to replace Path::from_filesystem_path
let temp_dir = new.unwrap;
let path = from_opfs_path
.unwrap
.child;
let mut logger = new..await.unwrap;
logger.write.await.unwrap;
Build
Build in Rust
Build in Wasm
Build with wasm-pack