diff --git a/src/cmd/src/metasrv.rs b/src/cmd/src/metasrv.rs index dc455dcf65..da017e71cd 100644 --- a/src/cmd/src/metasrv.rs +++ b/src/cmd/src/metasrv.rs @@ -132,7 +132,7 @@ impl SubCommand { } #[derive(Debug, Default, Parser)] -struct StartCommand { +pub struct StartCommand { /// The address to bind the gRPC server. #[clap(long, alias = "bind-addr")] rpc_bind_addr: Option, @@ -172,7 +172,7 @@ struct StartCommand { } impl StartCommand { - fn load_options(&self, global_options: &GlobalOptions) -> Result { + pub fn load_options(&self, global_options: &GlobalOptions) -> Result { let mut opts = MetasrvOptions::load_layered_options( self.config_file.as_deref(), self.env_prefix.as_ref(), @@ -261,7 +261,7 @@ impl StartCommand { Ok(()) } - async fn build(&self, opts: MetasrvOptions) -> Result { + pub async fn build(&self, opts: MetasrvOptions) -> Result { common_runtime::init_global_runtimes(&opts.runtime); let guard = common_telemetry::init_global_logging( diff --git a/src/meta-srv/src/lib.rs b/src/meta-srv/src/lib.rs index 4b61eeeae3..ebd3b7b54f 100644 --- a/src/meta-srv/src/lib.rs +++ b/src/meta-srv/src/lib.rs @@ -31,6 +31,7 @@ pub mod metasrv; pub mod metrics; #[cfg(feature = "mock")] pub mod mocks; +pub mod node_excluder; pub mod procedure; pub mod pubsub; pub mod region; diff --git a/src/meta-srv/src/node_excluder.rs b/src/meta-srv/src/node_excluder.rs new file mode 100644 index 0000000000..f9e892f092 --- /dev/null +++ b/src/meta-srv/src/node_excluder.rs @@ -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; + +/// [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; +} diff --git a/typos.toml b/typos.toml index da6570d224..57b7279d0f 100644 --- a/typos.toml +++ b/typos.toml @@ -6,6 +6,7 @@ ot = "ot" typ = "typ" typs = "typs" unqualifed = "unqualifed" +excluder = "excluder" [files] extend-exclude = [