cuprate_blockchain/service/mod.rs
1//! [`tower::Service`] integration + thread-pool.
2//!
3//! ## `service`
4//! The `service` module implements the [`tower`] integration,
5//! along with the reader/writer thread-pool system.
6//!
7//! The thread-pool allows outside crates to communicate with it by
8//! sending database requests and receiving responses `async`hronously -
9//! without having to actually worry and handle the database themselves.
10//!
11//! The system is managed by this crate, and only requires initialisation by the user.
12//!
13// needed for docs
14use tower as _;
15
16use cuprate_types::blockchain::BlockchainResponse;
17
18use crate::error::DbResult;
19
20mod free;
21mod read;
22mod write;
23
24pub use free::init_with_pool;
25pub use read::BlockchainReadHandle;
26pub use write::{init_write_service, BlockchainWriteHandle};
27
28//---------------------------------------------------------------------------------------------------- Types
29/// The actual type of the response.
30///
31/// Either our [`BlockchainResponse`], or a database error occurred.
32pub(super) type ResponseResult = DbResult<BlockchainResponse>;