rustfs_common/
globals.rs

1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::collections::HashMap;
16
17use lazy_static::lazy_static;
18use tokio::sync::RwLock;
19use tonic::transport::Channel;
20
21lazy_static! {
22    pub static ref GLOBAL_Local_Node_Name: RwLock<String> = RwLock::new("".to_string());
23    pub static ref GLOBAL_Rustfs_Host: RwLock<String> = RwLock::new("".to_string());
24    pub static ref GLOBAL_Rustfs_Port: RwLock<String> = RwLock::new("9000".to_string());
25    pub static ref GLOBAL_Rustfs_Addr: RwLock<String> = RwLock::new("".to_string());
26    pub static ref GLOBAL_Conn_Map: RwLock<HashMap<String, Channel>> = RwLock::new(HashMap::new());
27}
28
29pub async fn set_global_addr(addr: &str) {
30    *GLOBAL_Rustfs_Addr.write().await = addr.to_string();
31}