0g-storage-node/node/chunk_pool/src/lib.rs
Bo QIU 1de7afec14
Some checks are pending
abi-consistent-check / build-and-compare (push) Waiting to run
code-coverage / unittest-cov (push) Waiting to run
rust / check (push) Waiting to run
rust / test (push) Waiting to run
rust / lints (push) Waiting to run
functional-test / test (push) Waiting to run
Add more metrics for network unbounded channel (#264)
* Add metrics for file finalization in chunk pool

* Add metrics for network unbounded channel
2024-11-12 17:25:49 +08:00

41 lines
1.0 KiB
Rust

#[macro_use]
extern crate tracing;
mod handler;
mod mem_pool;
pub use handler::{ChunkPoolHandler, ChunkPoolMessage};
pub use mem_pool::{FileID, MemoryChunkPool, SegmentInfo};
use std::sync::Arc;
use std::time::Duration;
use storage_async::ShardConfig;
#[derive(Clone, Copy, Debug)]
pub struct Config {
pub write_window_size: usize,
pub max_cached_chunks_all: usize,
pub max_writings: usize,
pub expiration_time_secs: u64,
pub shard_config: ShardConfig,
}
impl Config {
pub fn expiration_time(&self) -> Duration {
Duration::from_secs(self.expiration_time_secs)
}
}
pub fn unbounded(
config: Config,
log_store: Arc<storage_async::Store>,
network_send: network::NetworkSender,
) -> (Arc<MemoryChunkPool>, ChunkPoolHandler) {
let (sender, receiver) = tokio::sync::mpsc::unbounded_channel();
let mem_pool = Arc::new(MemoryChunkPool::new(config, log_store.clone(), sender));
let handler = ChunkPoolHandler::new(receiver, mem_pool.clone(), log_store, network_send);
(mem_pool, handler)
}