feat: node excluder (#5964)

* feat: node excluder

* fix ci

* fix ci
This commit is contained in:
LFC
2025-04-23 18:48:46 +08:00
committed by GitHub
parent 79ed7bbc44
commit 71db79c8d6
4 changed files with 31 additions and 3 deletions

View File

@@ -132,7 +132,7 @@ impl SubCommand {
} }
#[derive(Debug, Default, Parser)] #[derive(Debug, Default, Parser)]
struct StartCommand { pub struct StartCommand {
/// The address to bind the gRPC server. /// The address to bind the gRPC server.
#[clap(long, alias = "bind-addr")] #[clap(long, alias = "bind-addr")]
rpc_bind_addr: Option<String>, rpc_bind_addr: Option<String>,
@@ -172,7 +172,7 @@ struct StartCommand {
} }
impl StartCommand { impl StartCommand {
fn load_options(&self, global_options: &GlobalOptions) -> Result<MetasrvOptions> { pub fn load_options(&self, global_options: &GlobalOptions) -> Result<MetasrvOptions> {
let mut opts = MetasrvOptions::load_layered_options( let mut opts = MetasrvOptions::load_layered_options(
self.config_file.as_deref(), self.config_file.as_deref(),
self.env_prefix.as_ref(), self.env_prefix.as_ref(),
@@ -261,7 +261,7 @@ impl StartCommand {
Ok(()) Ok(())
} }
async fn build(&self, opts: MetasrvOptions) -> Result<Instance> { pub async fn build(&self, opts: MetasrvOptions) -> Result<Instance> {
common_runtime::init_global_runtimes(&opts.runtime); common_runtime::init_global_runtimes(&opts.runtime);
let guard = common_telemetry::init_global_logging( let guard = common_telemetry::init_global_logging(

View File

@@ -31,6 +31,7 @@ pub mod metasrv;
pub mod metrics; pub mod metrics;
#[cfg(feature = "mock")] #[cfg(feature = "mock")]
pub mod mocks; pub mod mocks;
pub mod node_excluder;
pub mod procedure; pub mod procedure;
pub mod pubsub; pub mod pubsub;
pub mod region; pub mod region;

View File

@@ -0,0 +1,26 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use std::sync::Arc;
use common_meta::DatanodeId;
pub type NodeExcluderRef = Arc<dyn NodeExcluder>;
/// [NodeExcluder] is used to help decide whether some nodes should be excluded (out of consideration)
/// in certain situations. For example, in some node selectors.
pub trait NodeExcluder: Send + Sync {
/// Returns the excluded datanode ids.
fn excluded_datanode_ids(&self) -> &Vec<DatanodeId>;
}

View File

@@ -6,6 +6,7 @@ ot = "ot"
typ = "typ" typ = "typ"
typs = "typs" typs = "typs"
unqualifed = "unqualifed" unqualifed = "unqualifed"
excluder = "excluder"
[files] [files]
extend-exclude = [ extend-exclude = [