mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-01-14 09:05:18 +00:00
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 metrics for file finalization in chunk pool * Add metrics for network unbounded channel
41 lines
1.0 KiB
Rust
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)
|
|
}
|