mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
refactor(app): remove remaining global access in main init (#1978)
This commit is contained in:
@@ -977,6 +977,10 @@ pub async fn init_background_replication<S: StorageAPI>(storage: Arc<S>) {
|
|||||||
assert!(GLOBAL_REPLICATION_POOL.get().is_some());
|
assert!(GLOBAL_REPLICATION_POOL.get().is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_global_replication_pool() -> Option<Arc<DynReplicationPool>> {
|
||||||
|
GLOBAL_REPLICATION_POOL.get().cloned()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn schedule_replication<S: StorageAPI>(oi: ObjectInfo, o: Arc<S>, dsc: ReplicateDecision, op_type: ReplicationType) {
|
pub async fn schedule_replication<S: StorageAPI>(oi: ObjectInfo, o: Arc<S>, dsc: ReplicateDecision, op_type: ReplicationType) {
|
||||||
let tgt_statuses = replication_statuses_map(&oi.replication_status_internal.clone().unwrap_or_default());
|
let tgt_statuses = replication_statuses_map(&oi.replication_status_internal.clone().unwrap_or_default());
|
||||||
let purge_statuses = version_purge_statuses_map(&oi.version_purge_status_internal.clone().unwrap_or_default());
|
let purge_statuses = version_purge_statuses_map(&oi.version_purge_status_internal.clone().unwrap_or_default());
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ pub fn get_global_server_config() -> Option<Config> {
|
|||||||
GLOBAL_SERVER_CONFIG.get().cloned()
|
GLOBAL_SERVER_CONFIG.get().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn init_global_config_sys(api: Arc<ECStore>) -> Result<()> {
|
||||||
|
GLOBAL_CONFIG_SYS.init(api).await
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct KV {
|
pub struct KV {
|
||||||
pub key: String,
|
pub key: String,
|
||||||
|
|||||||
+6
-7
@@ -47,9 +47,8 @@ use rustfs_ecstore::store::init_lock_clients;
|
|||||||
use rustfs_ecstore::{
|
use rustfs_ecstore::{
|
||||||
StorageAPI,
|
StorageAPI,
|
||||||
bucket::metadata_sys::init_bucket_metadata_sys,
|
bucket::metadata_sys::init_bucket_metadata_sys,
|
||||||
bucket::replication::{GLOBAL_REPLICATION_POOL, init_background_replication},
|
bucket::replication::{get_global_replication_pool, init_background_replication},
|
||||||
config as ecconfig,
|
config as ecconfig,
|
||||||
config::GLOBAL_CONFIG_SYS,
|
|
||||||
endpoints::EndpointServerPools,
|
endpoints::EndpointServerPools,
|
||||||
global::{set_global_rustfs_port, shutdown_background_services},
|
global::{set_global_rustfs_port, shutdown_background_services},
|
||||||
notification_sys::new_global_notification_sys,
|
notification_sys::new_global_notification_sys,
|
||||||
@@ -278,12 +277,12 @@ async fn run(config: config::Config) -> Result<()> {
|
|||||||
|
|
||||||
// // Initialize global configuration system
|
// // Initialize global configuration system
|
||||||
let mut retry_count = 0;
|
let mut retry_count = 0;
|
||||||
while let Err(e) = GLOBAL_CONFIG_SYS.init(store.clone()).await {
|
while let Err(e) = ecconfig::init_global_config_sys(store.clone()).await {
|
||||||
error!("GLOBAL_CONFIG_SYS.init failed {:?}", e);
|
error!("ecconfig::init_global_config_sys failed {:?}", e);
|
||||||
// TODO: check error type
|
// TODO: check error type
|
||||||
retry_count += 1;
|
retry_count += 1;
|
||||||
if retry_count > 15 {
|
if retry_count > 15 {
|
||||||
return Err(Error::other("GLOBAL_CONFIG_SYS.init failed"));
|
return Err(Error::other("ecconfig::init_global_config_sys failed"));
|
||||||
}
|
}
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||||
}
|
}
|
||||||
@@ -355,8 +354,8 @@ async fn run(config: config::Config) -> Result<()> {
|
|||||||
// Collect bucket names into a vector
|
// Collect bucket names into a vector
|
||||||
let buckets: Vec<String> = buckets_list.into_iter().map(|v| v.name).collect();
|
let buckets: Vec<String> = buckets_list.into_iter().map(|v| v.name).collect();
|
||||||
|
|
||||||
if let Some(pool) = GLOBAL_REPLICATION_POOL.get() {
|
if let Some(pool) = get_global_replication_pool() {
|
||||||
pool.clone().init_resync(ctx.clone(), buckets.clone()).await?;
|
pool.init_resync(ctx.clone(), buckets.clone()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_bucket_metadata_sys(store.clone(), buckets.clone()).await;
|
init_bucket_metadata_sys(store.clone(), buckets.clone()).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user