mirror of
https://github.com/zhaofengli/attic.git
synced 2025-03-05 16:27:06 +00:00
make concurrency configurable
This commit is contained in:
parent
4775242756
commit
cdb0326004
2 changed files with 11 additions and 6 deletions
|
@ -50,11 +50,6 @@ use crate::database::entity::object::{self, Entity as Object, InsertExt};
|
|||
use crate::database::entity::Json as DbJson;
|
||||
use crate::database::{AtticDatabase, ChunkGuard, NarGuard};
|
||||
|
||||
/// Number of chunks to upload to the storage backend at once.
|
||||
///
|
||||
/// TODO: Make this configurable
|
||||
const CONCURRENT_CHUNK_UPLOADS: usize = 10;
|
||||
|
||||
/// The maximum size of the upload info JSON.
|
||||
///
|
||||
/// TODO: Make this configurable
|
||||
|
@ -384,7 +379,7 @@ async fn upload_path_new_chunked(
|
|||
chunking_config.max_size,
|
||||
);
|
||||
|
||||
let upload_chunk_limit = Arc::new(Semaphore::new(CONCURRENT_CHUNK_UPLOADS));
|
||||
let upload_chunk_limit = Arc::new(Semaphore::new(chunking_config.concurrent_chunk_uploads));
|
||||
let mut futures = Vec::new();
|
||||
|
||||
let mut chunk_idx = 0;
|
||||
|
|
|
@ -265,6 +265,12 @@ pub struct ChunkingConfig {
|
|||
/// The preferred maximum size of a chunk, in bytes.
|
||||
#[serde(rename = "max-size")]
|
||||
pub max_size: usize,
|
||||
|
||||
/// Number of chunks to upload to the storage backend
|
||||
/// at once. By default, this is 10.
|
||||
#[serde(rename = "concurrent-chunk-uploads")]
|
||||
#[serde(default = "default_concurrent_chunk_uploads")]
|
||||
pub concurrent_chunk_uploads: usize,
|
||||
}
|
||||
|
||||
/// Compression configuration.
|
||||
|
@ -558,6 +564,10 @@ fn default_default_retention_period() -> Duration {
|
|||
Duration::ZERO
|
||||
}
|
||||
|
||||
fn default_concurrent_chunk_uploads() -> usize {
|
||||
10
|
||||
}
|
||||
|
||||
fn load_config_from_path(path: &Path) -> Result<Config> {
|
||||
tracing::info!("Using configurations: {:?}", path);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue