refactor: extract method to build `compactor` from CLI configuration

pull/24376/head
Jake Goulding 2022-08-05 11:11:51 -04:00 committed by Carol (Nichols || Goulding)
parent ce908c8678
commit e9140df476
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
1 changed files with 26 additions and 7 deletions

View File

@ -136,6 +136,29 @@ pub async fn create_compactor_server_type(
time_provider: Arc<dyn TimeProvider>,
compactor_config: CompactorConfig,
) -> Result<Arc<dyn ServerType>> {
let compactor = build_compactor_from_config(
compactor_config,
catalog,
object_store,
exec,
time_provider,
Arc::clone(&metric_registry),
)
.await?;
let compactor_handler = Arc::new(CompactorHandlerImpl::new_with_compactor(compactor));
let compactor = CompactorServer::new(metric_registry, compactor_handler);
Ok(Arc::new(CompactorServerType::new(compactor, common_state)))
}
pub async fn build_compactor_from_config(
compactor_config: CompactorConfig,
catalog: Arc<dyn Catalog>,
object_store: Arc<DynObjectStore>,
exec: Arc<Executor>,
time_provider: Arc<dyn TimeProvider>,
metric_registry: Arc<Registry>,
) -> Result<compactor::compact::Compactor, Error> {
if compactor_config.write_buffer_partition_range_start
> compactor_config.write_buffer_partition_range_end
{
@ -177,7 +200,7 @@ pub async fn create_compactor_server_type(
compactor_config.hot_multiple,
);
let compactor = compactor::compact::Compactor::new(
Ok(compactor::compact::Compactor::new(
sequencers,
catalog,
parquet_store,
@ -185,10 +208,6 @@ pub async fn create_compactor_server_type(
time_provider,
backoff::BackoffConfig::default(),
compactor_config,
Arc::clone(&metric_registry),
);
let compactor_handler = Arc::new(CompactorHandlerImpl::new_with_compactor(compactor));
let compactor = CompactorServer::new(metric_registry, compactor_handler);
Ok(Arc::new(CompactorServerType::new(compactor, common_state)))
metric_registry,
))
}