db abstraction

This commit is contained in:
hinto.janai 2024-09-03 19:36:10 -04:00
parent 86017f3291
commit 20f54e34d8
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
31 changed files with 70 additions and 24 deletions

View file

@ -14,4 +14,4 @@ renderer = ["html"]
default-theme = "ayu"
preferred-dark-theme = "ayu"
git-repository-url = "https://github.com/Cuprate/architecture-book"
additional-css = ["last-changed.css"]
additional-css = ["last-changed.css"]

View file

@ -28,8 +28,8 @@
---
- [🟢 Storage](storage/intro.md)
- [🟢 Database abstraction](storage/db/intro.md)
- [🟢 Backends](storage/db/backends/intro.md)
- [🟢 Database abstraction](storage/db/database-abstraction.md)
- [🟢 Backends](storage/db/backends.md)
- [🟢 Layers](storage/db/layers/intro.md)
- [🟢 Backend](storage/db/layers/backend.md)
- [🟢 ConcreteEnv](storage/db/layers/concrete_env.md)
@ -37,25 +37,26 @@
- [🟢 Syncing](storage/db/syncing.md)
- [🟢 Resizing](storage/db/resizing.md)
- [🟢 (De)serialization](storage/db/serde.md)
- [🟢 Schema](storage/db/schema/intro.md)
- [🟢 Tables](storage/db/schema/tables.md)
- [🟢 Multimap tables](storage/db/schema/multimap.md)
- [🟢 Known issues and tradeoffs](storage/db/issues/intro.md)
- [🟢 Traits abstracting backends](storage/db/issues/traits.md)
- [🟢 Hot-swappable backends](storage/db/issues/hot-swap.md)
- [🟢 Copying unaligned bytes](storage/db/issues/copy.md)
- [🟢 Abstracting backends](storage/db/issues/traits.md)
- [🟢 Hot-swap](storage/db/issues/hot-swap.md)
- [🟢 Unaligned bytes](storage/db/issues/unaligned.md)
- [🟢 Endianness](storage/db/issues/endian.md)
- [🟢 Extra table data](storage/db/issues/extra-table-data.md)
- [🟢 The layers](storage/db/layers/intro.md)
- [🟢 `ops`](storage/db/layers/ops.md)
- [🟢 `tower::Service`](storage/db/service/intro.md)
- [🟢 Initialization](storage/db/service/initialization.md)
- [🟢 Requests](storage/db/service/requests.md)
- [🟢 Responses](storage/db/service/responses.md)
- [🟢 Thread model](storage/db/service/thread-model.md)
- [🟢 Shutdown](storage/db/service/shutdown.md)
- [⚪️ Blockchain](storage/blockchain.md)
- [⚪️ Transaction pool](storage/transaction-pool.md)
- [🟢 Extra table data](storage/db/issues/extra.md)
- [🟢 Common behavior](storage/common/intro.md)
- [🟢 Types](storage/common/types.md)
- [🟢 `ops`](storage/common/ops.md)
- [🟢 `tower::Service`](storage/common/intro.md)
- [🟢 Initialization](storage/common/initialization.md)
- [🟢 Requests](storage/common/requests.md)
- [🟢 Responses](storage/common/responses.md)
- [🟢 Thread model](storage/common/thread-model.md)
- [🟢 Shutdown](storage/common/shutdown.md)
- [⚪️ Blockchain](storage/blockchain/intro.md)
- [🟢 Schema](storage/blockchain/schema/intro.md)
- [🟢 Tables](storage/blockchain/schema/tables.md)
- [🟢 Multimap tables](storage/blockchain/schema/multimap.md)
- [⚪️ Transaction pool](storage/txpool/intro.md)
- [⚪️ Pruning](storage/pruning.md)
---

View file

@ -0,0 +1 @@
# 🟢 Schema

View file

@ -0,0 +1 @@
# 🟢 Multimap tables

View file

@ -0,0 +1 @@
# 🟢 Tables

View file

@ -0,0 +1 @@
# 🟢 Types

View file

@ -0,0 +1 @@
# 🟢 Initialization

View file

@ -0,0 +1 @@
# 🟢 Common behavior

View file

@ -0,0 +1 @@
# 🟢 ops

View file

@ -0,0 +1 @@
# 🟢 Requests

View file

@ -0,0 +1 @@
# 🟢 Responses

View file

@ -0,0 +1 @@
# 🟢 Shutdown

View file

@ -0,0 +1 @@
# 🟢 Thread model

View file

@ -0,0 +1 @@
# 🟢 Types

View file

@ -1 +0,0 @@
# ⚪️ Database abstraction

View file

@ -0,0 +1 @@
# 🟢 Backends

View file

@ -0,0 +1 @@
# 🟢 Initialization

View file

@ -0,0 +1 @@
# 🟢 Common behavior

View file

@ -0,0 +1 @@
# 🟢 ops

View file

@ -0,0 +1 @@
# 🟢 Requests

View file

@ -0,0 +1 @@
# 🟢 Responses

View file

@ -0,0 +1 @@
# 🟢 Shutdown

View file

@ -0,0 +1 @@
# 🟢 Thread model

View file

@ -0,0 +1 @@
# 🟢 Types

View file

@ -0,0 +1,21 @@
# Database abstraction
[`cuprate_database`](https://doc.cuprate.org/cuprate_database) is Cuprates database abstraction.
This crate abstracts various database backends with `trait`s.
All backends have the following attributes:
- [Embedded](https://en.wikipedia.org/wiki/Embedded_database)
- [Multiversion concurrency control](https://en.wikipedia.org/wiki/Multiversion_concurrency_control)
- [ACID](https://en.wikipedia.org/wiki/ACID)
- Are `(key, value)` oriented and have the expected API (`get()`, `insert()`, `delete()`)
- Are table oriented (`"table_name" -> (key, value)`)
- Allows concurrent readers
The currently implemented backends are:
- [`heed`](https://github.com/meilisearch/heed) (LMDB)
- [`redb`](https://github.com/cberner/redb)
Said precicely, `cuprate_database` is the embedded database other Cuprate
crates interact with instead of using any particular backend implementation.
This allows the backend to be swapped and/or future backends to be implemented.

View file

@ -0,0 +1 @@
# 🟢 Extra table data

View file

@ -0,0 +1 @@
# 🟢 Unaligned bytes

View file

@ -0,0 +1 @@
# 🟢 Types

View file

@ -1,5 +1,5 @@
# Storage
This section covers all things related to the long-term on-disk storage of data within Cuprate.
This section covers all things related to the on-disk storage of data within Cuprate.
## Overview
The quick overview is that Cuprate has a [database abstraction crate](./database-abstraction.md)
@ -12,9 +12,9 @@ This database abstraction crate is then used by all crates that need on-disk sto
## Service
The interface provided by all crates building on-top of the
database abstraction is a [`tower::Service`](https://docs.rs/tower), i.e.
database requests are sent, and database responses are received asynchronously.
database requests/responses are sent/received asynchronously.
As the interface details are similar across databases (threadpool, read operations, write operations),
As the interface details are similar across crates (threadpool, read operations, write operations),
the interface itself is abstracted in the [`cuprate_database_service`](./db/layers/intro.md) crate,
which is then used by the crates.

View file

@ -0,0 +1 @@
# ⚪️ Transaction pool