refactor: Restructure project layout and clean up dependencies (#30)

This commit introduces a significant reorganization of the project structure to improve maintainability and clarity.

Key changes include:
- Adjusted the directory layout for a more logical module organization.
- Removed unused crate dependencies, reducing the overall project size and potentially speeding up build times.
- Updated import paths and configuration files to reflect the structural changes.
This commit is contained in:
houseme
2025-07-02 19:33:12 +08:00
committed by GitHub
parent 0be4264eb1
commit 5826396cd0
322 changed files with 977 additions and 1542 deletions
@@ -0,0 +1,15 @@
// Copyright 2024 RustFS 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.
pub mod models;
@@ -0,0 +1,138 @@
// Copyright 2024 RustFS 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.
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
use core::cmp::Ordering;
use core::mem;
extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};
#[allow(unused_imports, dead_code)]
pub mod models {
use core::cmp::Ordering;
use core::mem;
extern crate flatbuffers;
use self::flatbuffers::{EndianScalar, Follow};
pub enum PingBodyOffset {}
#[derive(Copy, Clone, PartialEq)]
pub struct PingBody<'a> {
pub _tab: flatbuffers::Table<'a>,
}
impl<'a> flatbuffers::Follow<'a> for PingBody<'a> {
type Inner = PingBody<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
impl<'a> PingBody<'a> {
pub const VT_PAYLOAD: flatbuffers::VOffsetT = 4;
pub const fn get_fully_qualified_name() -> &'static str {
"models.PingBody"
}
#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
PingBody { _tab: table }
}
#[allow(unused_mut)]
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
args: &'args PingBodyArgs<'args>,
) -> flatbuffers::WIPOffset<PingBody<'bldr>> {
let mut builder = PingBodyBuilder::new(_fbb);
if let Some(x) = args.payload {
builder.add_payload(x);
}
builder.finish()
}
#[inline]
pub fn payload(&self) -> Option<flatbuffers::Vector<'a, u8>> {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe {
self._tab
.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(PingBody::VT_PAYLOAD, None)
}
}
}
impl flatbuffers::Verifiable for PingBody<'_> {
#[inline]
fn run_verifier(v: &mut flatbuffers::Verifier, pos: usize) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use self::flatbuffers::Verifiable;
v.visit_table(pos)?
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("payload", Self::VT_PAYLOAD, false)?
.finish();
Ok(())
}
}
pub struct PingBodyArgs<'a> {
pub payload: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
}
impl<'a> Default for PingBodyArgs<'a> {
#[inline]
fn default() -> Self {
PingBodyArgs { payload: None }
}
}
pub struct PingBodyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> {
#[inline]
pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset<flatbuffers::Vector<'b, u8>>) {
self.fbb_
.push_slot_always::<flatbuffers::WIPOffset<_>>(PingBody::VT_PAYLOAD, payload);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PingBodyBuilder<'a, 'b, A> {
let start = _fbb.start_table();
PingBodyBuilder {
fbb_: _fbb,
start_: start,
}
}
#[inline]
pub fn finish(self) -> flatbuffers::WIPOffset<PingBody<'a>> {
let o = self.fbb_.end_table(self.start_);
flatbuffers::WIPOffset::new(o.value())
}
}
impl core::fmt::Debug for PingBody<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("PingBody");
ds.field("payload", &self.payload());
ds.finish()
}
}
} // pub mod models
+19
View File
@@ -0,0 +1,19 @@
#![allow(unused_imports)]
// Copyright 2024 RustFS 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.
#![allow(clippy::all)]
pub mod proto_gen;
mod flatbuffers_generated;
pub use flatbuffers_generated::models::*;
@@ -0,0 +1,15 @@
// Copyright 2024 RustFS 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.
pub mod node_service;
File diff suppressed because it is too large Load Diff
+59
View File
@@ -0,0 +1,59 @@
// Copyright 2024 RustFS 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.
#[allow(unsafe_code)]
mod generated;
use std::{error::Error, time::Duration};
pub use generated::*;
use proto_gen::node_service::node_service_client::NodeServiceClient;
use rustfs_common::globals::GLOBAL_Conn_Map;
use tonic::{
Request, Status,
metadata::MetadataValue,
service::interceptor::InterceptedService,
transport::{Channel, Endpoint},
};
// Default 100 MB
pub const DEFAULT_GRPC_SERVER_MESSAGE_LEN: usize = 100 * 1024 * 1024;
pub async fn node_service_time_out_client(
addr: &String,
) -> Result<
NodeServiceClient<
InterceptedService<Channel, Box<dyn Fn(Request<()>) -> Result<Request<()>, Status> + Send + Sync + 'static>>,
>,
Box<dyn Error>,
> {
let token: MetadataValue<_> = "rustfs rpc".parse()?;
let channel = match GLOBAL_Conn_Map.read().await.get(addr) {
Some(channel) => channel.clone(),
None => {
let connector = Endpoint::from_shared(addr.to_string())?.connect_timeout(Duration::from_secs(60));
connector.connect().await?
}
};
GLOBAL_Conn_Map.write().await.insert(addr.to_string(), channel.clone());
// let timeout_channel = Timeout::new(channel, Duration::from_secs(60));
Ok(NodeServiceClient::with_interceptor(
channel,
Box::new(move |mut req: Request<()>| {
req.metadata_mut().insert("authorization", token.clone());
Ok(req)
}),
))
}
+285
View File
@@ -0,0 +1,285 @@
// Copyright 2024 RustFS 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::{cmp, env, fs, io::Write, path::Path, process::Command};
type AnyError = Box<dyn std::error::Error>;
const VERSION_PROTOBUF: Version = Version(30, 2, 0); // 30.2.0
const VERSION_FLATBUFFERS: Version = Version(24, 3, 25); // 24.3.25
/// Build protos if the major version of `flatc` or `protoc` is greater
/// or lesser than the expected version.
const ENV_BUILD_PROTOS: &str = "BUILD_PROTOS";
/// Path of `flatc` binary.
const ENV_FLATC_PATH: &str = "FLATC_PATH";
fn main() -> Result<(), AnyError> {
let version = protobuf_compiler_version()?;
let need_compile = match version.compare_ext(&VERSION_PROTOBUF) {
Ok(cmp::Ordering::Equal) => true,
Ok(_) => {
let version_err = Version::build_error_message(&version, &VERSION_PROTOBUF).unwrap();
println!("cargo:warning=Tool `protoc` {version_err}, skip compiling.");
false
}
Err(version_err) => {
// return Err(format!("Tool `protoc` {version_err}, please update it.").into());
println!("cargo:warning=Tool `protoc` {version_err}, please update it.");
false
}
};
if !need_compile {
return Ok(());
}
// path of proto file
let project_root_dir = env::current_dir()?.join("");
let proto_dir = project_root_dir.clone();
let proto_files = &["node.proto"];
let proto_out_dir = project_root_dir.join("generated").join("proto_gen");
let flatbuffer_out_dir = project_root_dir.join("generated").join("flatbuffers_generated");
// let descriptor_set_path = PathBuf::from(env::var(ENV_OUT_DIR).unwrap()).join("proto-descriptor.bin");
tonic_build::configure()
.out_dir(proto_out_dir)
// .file_descriptor_set_path(descriptor_set_path)
.protoc_arg("--experimental_allow_proto3_optional")
.compile_well_known_types(true)
.bytes(["."])
.emit_rerun_if_changed(false)
.compile_protos(proto_files, &[proto_dir.clone()])
.map_err(|e| format!("Failed to generate protobuf file: {e}."))?;
// protos/gen/mod.rs
let generated_mod_rs_path = project_root_dir.join("generated").join("proto_gen").join("mod.rs");
let mut generated_mod_rs = fs::File::create(generated_mod_rs_path)?;
writeln!(&mut generated_mod_rs, "pub mod node_service;")?;
generated_mod_rs.flush()?;
let generated_mod_rs_path = project_root_dir.join("generated").join("mod.rs");
let mut generated_mod_rs = fs::File::create(generated_mod_rs_path)?;
writeln!(&mut generated_mod_rs, "#![allow(unused_imports)]")?;
writeln!(&mut generated_mod_rs, "#![allow(clippy::all)]")?;
writeln!(&mut generated_mod_rs, "pub mod proto_gen;")?;
generated_mod_rs.flush()?;
let flatc_path = match env::var(ENV_FLATC_PATH) {
Ok(path) => {
println!("cargo:warning=Specified flatc path by environment {ENV_FLATC_PATH}={path}");
path
}
Err(_) => "flatc".to_string(),
};
compile_flatbuffers_models(
&mut generated_mod_rs,
&flatc_path,
proto_dir.clone(),
flatbuffer_out_dir.clone(),
vec!["models"],
)?;
fmt();
Ok(())
}
/// Compile proto/**.fbs files.
fn compile_flatbuffers_models<P: AsRef<Path>, S: AsRef<str>>(
generated_mod_rs: &mut fs::File,
flatc_path: &str,
in_fbs_dir: P,
out_rust_dir: P,
mod_names: Vec<S>,
) -> Result<(), AnyError> {
let version = flatbuffers_compiler_version(flatc_path)?;
let need_compile = match version.compare_ext(&VERSION_FLATBUFFERS) {
Ok(cmp::Ordering::Equal) => true,
Ok(_) => {
let version_err = Version::build_error_message(&version, &VERSION_FLATBUFFERS).unwrap();
println!("cargo:warning=Tool `{flatc_path}` {version_err}, skip compiling.");
false
}
Err(version_err) => {
return Err(format!("Tool `{flatc_path}` {version_err}, please update it.").into());
}
};
let fbs_dir = in_fbs_dir.as_ref();
let rust_dir = out_rust_dir.as_ref();
fs::create_dir_all(rust_dir)?;
// $rust_dir/mod.rs
let mut sub_mod_rs = fs::File::create(rust_dir.join("mod.rs"))?;
writeln!(generated_mod_rs)?;
writeln!(generated_mod_rs, "mod flatbuffers_generated;")?;
for mod_name in mod_names.iter() {
let mod_name = mod_name.as_ref();
writeln!(generated_mod_rs, "pub use flatbuffers_generated::{mod_name}::*;")?;
writeln!(&mut sub_mod_rs, "pub mod {mod_name};")?;
if need_compile {
let fbs_file_path = fbs_dir.join(format!("{mod_name}.fbs"));
let output = Command::new(flatc_path)
.arg("-o")
.arg(rust_dir)
.arg("--rust")
.arg("--gen-mutable")
.arg("--gen-onefile")
.arg("--gen-name-strings")
.arg("--filename-suffix")
.arg("")
.arg(&fbs_file_path)
.output()
.map_err(|e| format!("Failed to execute process of flatc: {e}"))?;
if !output.status.success() {
return Err(format!(
"Failed to generate file '{}' by flatc(path: '{flatc_path}'): {}.",
fbs_file_path.display(),
String::from_utf8_lossy(&output.stderr),
)
.into());
}
}
}
generated_mod_rs.flush()?;
sub_mod_rs.flush()?;
Ok(())
}
/// Run command `flatc --version` to get the version of flatc.
///
/// ```ignore
/// $ flatc --version
/// flatc version 24.3.25
/// ```
fn flatbuffers_compiler_version(flatc_path: impl AsRef<Path>) -> Result<Version, String> {
let flatc_path = flatc_path.as_ref();
Version::try_get(format!("{}", flatc_path.display()), |output| {
const PREFIX_OF_VERSION: &str = "flatc version ";
let output = output.trim();
if let Some(version) = output.strip_prefix(PREFIX_OF_VERSION) {
Ok(version.to_string())
} else {
Err(format!("Failed to get flatc version: {output}"))
}
})
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
struct Version(u32, u32, u32);
impl Version {
fn try_get<F: FnOnce(&str) -> Result<String, String>>(exe: String, output_to_version_string: F) -> Result<Self, String> {
let cmd = format!("{exe} --version");
let output = std::process::Command::new(exe)
.arg("--version")
.output()
.map_err(|e| format!("Failed to execute `{cmd}`: {e}",))?;
let output_utf8 = String::from_utf8(output.stdout).map_err(|e| {
let output_lossy = String::from_utf8_lossy(e.as_bytes());
format!("Command `{cmd}` returned invalid UTF-8('{output_lossy}'): {e}")
})?;
if output.status.success() {
let version_string = output_to_version_string(&output_utf8)?;
Ok(version_string.parse::<Self>()?)
} else {
Err(format!("Failed to get version by command `{cmd}`: {output_utf8}"))
}
}
fn build_error_message(version: &Self, expected: &Self) -> Option<String> {
match version.compare_major_version(expected) {
cmp::Ordering::Equal => None,
cmp::Ordering::Greater => Some(format!("version({version}) is greater than version({expected})")),
cmp::Ordering::Less => Some(format!("version({version}) is lesser than version({expected})")),
}
}
fn compare_ext(&self, expected_version: &Self) -> Result<cmp::Ordering, String> {
match env::var(ENV_BUILD_PROTOS) {
Ok(build_protos) => {
if build_protos.is_empty() || build_protos == "0" {
Ok(self.compare_major_version(expected_version))
} else {
match self.compare_major_version(expected_version) {
cmp::Ordering::Equal => Ok(cmp::Ordering::Equal),
_ => Err(Self::build_error_message(self, expected_version).unwrap()),
}
}
}
Err(_) => Ok(self.compare_major_version(expected_version)),
}
}
fn compare_major_version(&self, other: &Self) -> cmp::Ordering {
self.0.cmp(&other.0)
}
}
impl std::str::FromStr for Version {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut version = [0_u32; 3];
for (i, v) in s.split('.').take(3).enumerate() {
version[i] = v.parse().map_err(|e| format!("Failed to parse version string '{s}': {e}"))?;
}
Ok(Version(version[0], version[1], version[2]))
}
}
impl std::fmt::Display for Version {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}.{}.{}", self.0, self.1, self.2)
}
}
/// Run command `protoc --version` to get the version of flatc.
///
/// ```ignore
/// $ protoc --version
/// libprotoc 27.0
/// ```
fn protobuf_compiler_version() -> Result<Version, String> {
Version::try_get("protoc".to_string(), |output| {
const PREFIX_OF_VERSION: &str = "libprotoc ";
let output = output.trim();
if let Some(version) = output.strip_prefix(PREFIX_OF_VERSION) {
Ok(version.to_string())
} else {
Err(format!("Failed to get protoc version: {output}"))
}
})
}
fn fmt() {
let output = Command::new("cargo").arg("fmt").arg("-p").arg("protos").status();
match output {
Ok(status) => {
if status.success() {
println!("cargo fmt executed successfully.");
} else {
eprintln!("cargo fmt failed with status: {status:?}");
}
}
Err(e) => {
eprintln!("Failed to execute cargo fmt: {e}");
}
}
}
+5
View File
@@ -0,0 +1,5 @@
namespace models;
table PingBody {
payload: [ubyte];
}
+846
View File
@@ -0,0 +1,846 @@
// Copyright 2024 RustFS 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.
syntax = "proto3";
package node_service;
/* -------------------------------------------------------------------- */
message Error {
uint32 code = 1;
string error_info = 2;
}
message PingRequest {
uint64 version = 1;
bytes body = 2;
}
message PingResponse {
uint64 version = 1;
bytes body = 2;
}
message HealBucketRequest {
string bucket = 1;
string options = 2;
}
message HealBucketResponse {
bool success = 1;
optional Error error = 2;
}
message ListBucketRequest {
string options = 1;
}
message ListBucketResponse {
bool success = 1;
repeated string bucket_infos = 2;
optional Error error = 3;
}
message MakeBucketRequest {
string name = 1;
string options = 2;
}
message MakeBucketResponse {
bool success = 1;
optional Error error = 2;
}
message GetBucketInfoRequest {
string bucket = 1;
string options = 2;
}
message GetBucketInfoResponse {
bool success = 1;
string bucket_info = 2;
optional Error error = 3;
}
message DeleteBucketRequest {
string bucket = 1;
}
message DeleteBucketResponse {
bool success = 1;
optional Error error = 2;
}
message ReadAllRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
}
message ReadAllResponse {
bool success = 1;
bytes data = 2;
optional Error error = 3;
}
message WriteAllRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
bytes data = 4;
}
message WriteAllResponse {
bool success = 1;
optional Error error = 2;
}
message DeleteRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
string options = 4;
}
message DeleteResponse {
bool success = 1;
optional Error error = 2;
}
message VerifyFileRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
string file_info = 4;
}
message VerifyFileResponse {
bool success = 1;
string check_parts_resp = 2;
optional Error error = 3;
}
message CheckPartsRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
string file_info = 4;
}
message CheckPartsResponse {
bool success = 1;
string check_parts_resp = 2;
optional Error error = 3;
}
message RenamePartRequest {
string disk = 1;
string src_volume = 2;
string src_path = 3;
string dst_volume = 4;
string dst_path = 5;
bytes meta = 6;
}
message RenamePartResponse {
bool success = 1;
optional Error error = 2;
}
message RenameFileRequest {
string disk = 1;
string src_volume = 2;
string src_path = 3;
string dst_volume = 4;
string dst_path = 5;
}
message RenameFileResponse {
bool success = 1;
optional Error error = 2;
}
message WriteRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
bool is_append = 4;
bytes data = 5;
}
message WriteResponse {
bool success = 1;
optional Error error = 2;
}
// message AppendRequest {
// string disk = 1; // indicate which one in the disks
// string volume = 2;
// string path = 3;
// bytes data = 4;
// }
//
// message AppendResponse {
// bool success = 1;
// optional Error error = 2;
// }
message ReadAtRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
int64 offset = 4;
int64 length = 5;
}
message ReadAtResponse {
bool success = 1;
bytes data = 2;
int64 read_size = 3;
optional Error error = 4;
}
message ListDirRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
}
message ListDirResponse {
bool success = 1;
repeated string volumes = 2;
optional Error error = 3;
}
message WalkDirRequest {
string disk = 1; // indicate which one in the disks
bytes walk_dir_options = 2;
}
message WalkDirResponse {
bool success = 1;
string meta_cache_entry = 2;
optional string error_info = 3;
}
message RenameDataRequest {
string disk = 1; // indicate which one in the disks
string src_volume = 2;
string src_path = 3;
string file_info = 4;
string dst_volume = 5;
string dst_path = 6;
}
message RenameDataResponse {
bool success = 1;
string rename_data_resp = 2;
optional Error error = 3;
}
message MakeVolumesRequest {
string disk = 1; // indicate which one in the disks
repeated string volumes = 2;
}
message MakeVolumesResponse {
bool success = 1;
optional Error error = 2;
}
message MakeVolumeRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
}
message MakeVolumeResponse {
bool success = 1;
optional Error error = 2;
}
message ListVolumesRequest {
string disk = 1; // indicate which one in the disks
}
message ListVolumesResponse {
bool success = 1;
repeated string volume_infos = 2;
optional Error error = 3;
}
message StatVolumeRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
}
message StatVolumeResponse {
bool success = 1;
string volume_info = 2;
optional Error error = 3;
}
message DeletePathsRequest {
string disk = 1;
string volume = 2;
repeated string paths = 3;
}
message DeletePathsResponse {
bool success = 1;
optional Error error = 2;
}
message UpdateMetadataRequest {
string disk = 1;
string volume = 2;
string path = 3;
string file_info = 4;
string opts = 5;
}
message UpdateMetadataResponse {
bool success = 1;
optional Error error = 2;
}
message WriteMetadataRequest {
string disk = 1; // indicate which one in the disks
string volume = 2;
string path = 3;
string file_info = 4;
}
message WriteMetadataResponse {
bool success = 1;
optional Error error = 2;
}
message ReadVersionRequest {
string disk = 1;
string volume = 2;
string path = 3;
string version_id = 4;
string opts = 5;
}
message ReadVersionResponse {
bool success = 1;
string file_info = 2;
optional Error error = 3;
}
message ReadXLRequest {
string disk = 1;
string volume = 2;
string path = 3;
bool read_data = 4;
}
message ReadXLResponse {
bool success = 1;
string raw_file_info = 2;
optional Error error = 3;
}
message DeleteVersionRequest {
string disk = 1;
string volume = 2;
string path = 3;
string file_info = 4;
bool force_del_marker = 5;
string opts = 6;
}
message DeleteVersionResponse {
bool success = 1;
string raw_file_info = 2;
optional Error error = 3;
}
message DeleteVersionsRequest {
string disk = 1;
string volume = 2;
repeated string versions = 3;
string opts = 4;
}
message DeleteVersionsResponse {
bool success = 1;
repeated string errors = 2;
optional Error error = 3;
}
message ReadMultipleRequest {
string disk = 1;
string read_multiple_req = 2;
}
message ReadMultipleResponse {
bool success = 1;
repeated string read_multiple_resps = 2;
optional Error error = 3;
}
message DeleteVolumeRequest {
string disk = 1;
string volume = 2;
}
message DeleteVolumeResponse {
bool success = 1;
optional Error error = 2;
}
message DiskInfoRequest {
string disk = 1;
string opts = 2;
}
message DiskInfoResponse {
bool success = 1;
string disk_info = 2;
optional Error error = 3;
}
message NsScannerRequest {
string disk = 1;
string cache = 2;
uint64 scan_mode = 3;
}
message NsScannerResponse {
bool success = 1;
string update = 2;
string data_usage_cache = 3;
optional Error error = 4;
}
// lock api have same argument type
message GenerallyLockRequest {
string args = 1;
}
message GenerallyLockResponse {
bool success = 1;
optional string error_info = 2;
}
message Mss {
map<string, string> value = 1;
}
message LocalStorageInfoRequest {
bool metrics = 1;
}
message LocalStorageInfoResponse {
bool success = 1;
bytes storage_info = 2;
optional string error_info = 3;
}
message ServerInfoRequest {
bool metrics = 1;
}
message ServerInfoResponse {
bool success = 1;
bytes server_properties = 2;
optional string error_info = 3;
}
message GetCpusRequest {}
message GetCpusResponse {
bool success = 1;
bytes cpus = 2;
optional string error_info = 3;
}
message GetNetInfoRequest {}
message GetNetInfoResponse {
bool success = 1;
bytes net_info = 2;
optional string error_info = 3;
}
message GetPartitionsRequest {}
message GetPartitionsResponse {
bool success = 1;
bytes partitions = 2;
optional string error_info = 3;
}
message GetOsInfoRequest {}
message GetOsInfoResponse {
bool success = 1;
bytes os_info = 2;
optional string error_info = 3;
}
message GetSELinuxInfoRequest {}
message GetSELinuxInfoResponse {
bool success = 1;
bytes sys_services = 2;
optional string error_info = 3;
}
message GetSysConfigRequest {}
message GetSysConfigResponse {
bool success = 1;
bytes sys_config = 2;
optional string error_info = 3;
}
message GetSysErrorsRequest {}
message GetSysErrorsResponse {
bool success = 1;
bytes sys_errors = 2;
optional string error_info = 3;
}
message GetMemInfoRequest {}
message GetMemInfoResponse {
bool success = 1;
bytes mem_info = 2;
optional string error_info = 3;
}
message GetMetricsRequest {
bytes metric_type = 1;
bytes opts = 2;
}
message GetMetricsResponse {
bool success = 1;
bytes realtime_metrics = 2;
optional string error_info = 3;
}
message GetProcInfoRequest {}
message GetProcInfoResponse {
bool success = 1;
bytes proc_info = 2;
optional string error_info = 3;
}
message StartProfilingRequest {
string profiler = 1;
}
message StartProfilingResponse {
bool success = 1;
optional string error_info = 2;
}
message DownloadProfileDataRequest {}
message DownloadProfileDataResponse {
bool success = 1;
map<string, bytes> data = 2;
optional string error_info = 3;
}
message GetBucketStatsDataRequest {
string bucket = 1;
}
message GetBucketStatsDataResponse {
bool success = 1;
bytes bucket_stats = 2;
optional string error_info = 3;
}
message GetSRMetricsDataRequest {}
message GetSRMetricsDataResponse {
bool success = 1;
bytes sr_metrics_summary = 2;
optional string error_info = 3;
}
message GetAllBucketStatsRequest {}
message GetAllBucketStatsResponse {
bool success = 1;
bytes bucket_stats_map = 2;
optional string error_info = 3;
}
message LoadBucketMetadataRequest {
string bucket = 1;
}
message LoadBucketMetadataResponse {
bool success = 1;
optional string error_info = 2;
}
message DeleteBucketMetadataRequest {
string bucket = 1;
}
message DeleteBucketMetadataResponse {
bool success = 1;
optional string error_info = 2;
}
message DeletePolicyRequest {
string policy_name = 1;
}
message DeletePolicyResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadPolicyRequest {
string policy_name = 1;
}
message LoadPolicyResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadPolicyMappingRequest {
string user_or_group = 1;
uint64 user_type = 2;
bool is_group = 3;
}
message LoadPolicyMappingResponse {
bool success = 1;
optional string error_info = 2;
}
message DeleteUserRequest {
string access_key = 1;
}
message DeleteUserResponse {
bool success = 1;
optional string error_info = 2;
}
message DeleteServiceAccountRequest {
string access_key = 1;
}
message DeleteServiceAccountResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadUserRequest {
string access_key = 1;
bool temp = 2;
}
message LoadUserResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadServiceAccountRequest {
string access_key = 1;
}
message LoadServiceAccountResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadGroupRequest {
string group = 1;
}
message LoadGroupResponse {
bool success = 1;
optional string error_info = 2;
}
message ReloadSiteReplicationConfigRequest {}
message ReloadSiteReplicationConfigResponse {
bool success = 1;
optional string error_info = 2;
}
message SignalServiceRequest {
Mss vars = 1;
}
message SignalServiceResponse {
bool success = 1;
optional string error_info = 2;
}
message BackgroundHealStatusRequest {}
message BackgroundHealStatusResponse {
bool success = 1;
bytes bg_heal_state = 2;
optional string error_info = 3;
}
message GetMetacacheListingRequest {
bytes opts = 1;
}
message GetMetacacheListingResponse {
bool success = 1;
bytes metacache = 2;
optional string error_info = 3;
}
message UpdateMetacacheListingRequest {
bytes metacache = 1;
}
message UpdateMetacacheListingResponse {
bool success = 1;
bytes metacache = 2;
optional string error_info = 3;
}
message ReloadPoolMetaRequest {}
message ReloadPoolMetaResponse {
bool success = 1;
optional string error_info = 2;
}
message StopRebalanceRequest {}
message StopRebalanceResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadRebalanceMetaRequest {
bool start_rebalance = 1;
}
message LoadRebalanceMetaResponse {
bool success = 1;
optional string error_info = 2;
}
message LoadTransitionTierConfigRequest {}
message LoadTransitionTierConfigResponse {
bool success = 1;
optional string error_info = 2;
}
/* -------------------------------------------------------------------- */
service NodeService {
/* -------------------------------meta service-------------------------- */
rpc Ping(PingRequest) returns (PingResponse) {};
rpc HealBucket(HealBucketRequest) returns (HealBucketResponse) {};
rpc ListBucket(ListBucketRequest) returns (ListBucketResponse) {};
rpc MakeBucket(MakeBucketRequest) returns (MakeBucketResponse) {};
rpc GetBucketInfo(GetBucketInfoRequest) returns (GetBucketInfoResponse) {};
rpc DeleteBucket(DeleteBucketRequest) returns (DeleteBucketResponse) {};
/* -------------------------------disk service-------------------------- */
rpc ReadAll(ReadAllRequest) returns (ReadAllResponse) {};
rpc WriteAll(WriteAllRequest) returns (WriteAllResponse) {};
rpc Delete(DeleteRequest) returns (DeleteResponse) {};
rpc VerifyFile(VerifyFileRequest) returns (VerifyFileResponse) {};
rpc CheckParts(CheckPartsRequest) returns (CheckPartsResponse) {};
rpc RenamePart(RenamePartRequest) returns (RenamePartResponse) {};
rpc RenameFile(RenameFileRequest) returns (RenameFileResponse) {};
rpc Write(WriteRequest) returns (WriteResponse) {};
rpc WriteStream(stream WriteRequest) returns (stream WriteResponse) {};
// rpc Append(AppendRequest) returns (AppendResponse) {};
rpc ReadAt(stream ReadAtRequest) returns (stream ReadAtResponse) {};
rpc ListDir(ListDirRequest) returns (ListDirResponse) {};
rpc WalkDir(WalkDirRequest) returns (stream WalkDirResponse) {};
rpc RenameData(RenameDataRequest) returns (RenameDataResponse) {};
rpc MakeVolumes(MakeVolumesRequest) returns (MakeVolumesResponse) {};
rpc MakeVolume(MakeVolumeRequest) returns (MakeVolumeResponse) {};
rpc ListVolumes(ListVolumesRequest) returns (ListVolumesResponse) {};
rpc StatVolume(StatVolumeRequest) returns (StatVolumeResponse) {};
rpc DeletePaths(DeletePathsRequest) returns (DeletePathsResponse) {};
rpc UpdateMetadata(UpdateMetadataRequest) returns (UpdateMetadataResponse) {};
rpc WriteMetadata(WriteMetadataRequest) returns (WriteMetadataResponse) {};
rpc ReadVersion(ReadVersionRequest) returns (ReadVersionResponse) {};
rpc ReadXL(ReadXLRequest) returns (ReadXLResponse) {};
rpc DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) {};
rpc DeleteVersions(DeleteVersionsRequest) returns (DeleteVersionsResponse) {};
rpc ReadMultiple(ReadMultipleRequest) returns (ReadMultipleResponse) {};
rpc DeleteVolume(DeleteVolumeRequest) returns (DeleteVolumeResponse) {};
rpc DiskInfo(DiskInfoRequest) returns (DiskInfoResponse) {};
rpc NsScanner(stream NsScannerRequest) returns (stream NsScannerResponse) {};
/* -------------------------------lock service-------------------------- */
rpc Lock(GenerallyLockRequest) returns (GenerallyLockResponse) {};
rpc UnLock(GenerallyLockRequest) returns (GenerallyLockResponse) {};
rpc RLock(GenerallyLockRequest) returns (GenerallyLockResponse) {};
rpc RUnLock(GenerallyLockRequest) returns (GenerallyLockResponse) {};
rpc ForceUnLock(GenerallyLockRequest) returns (GenerallyLockResponse) {};
rpc Refresh(GenerallyLockRequest) returns (GenerallyLockResponse) {};
/* -------------------------------peer rest service-------------------------- */
rpc LocalStorageInfo(LocalStorageInfoRequest) returns (LocalStorageInfoResponse) {};
rpc ServerInfo(ServerInfoRequest) returns (ServerInfoResponse) {};
rpc GetCpus(GetCpusRequest) returns (GetCpusResponse) {};
rpc GetNetInfo(GetNetInfoRequest) returns (GetNetInfoResponse) {};
rpc GetPartitions(GetPartitionsRequest) returns (GetPartitionsResponse) {};
rpc GetOsInfo(GetOsInfoRequest) returns (GetOsInfoResponse) {};
rpc GetSELinuxInfo(GetSELinuxInfoRequest) returns (GetSELinuxInfoResponse) {};
rpc GetSysConfig(GetSysConfigRequest) returns (GetSysConfigResponse) {};
rpc GetSysErrors(GetSysErrorsRequest) returns (GetSysErrorsResponse) {};
rpc GetMemInfo(GetMemInfoRequest) returns (GetMemInfoResponse) {};
rpc GetMetrics(GetMetricsRequest) returns (GetMetricsResponse) {};
rpc GetProcInfo(GetProcInfoRequest) returns (GetProcInfoResponse) {};
rpc StartProfiling(StartProfilingRequest) returns (StartProfilingResponse) {};
rpc DownloadProfileData(DownloadProfileDataRequest) returns (DownloadProfileDataResponse) {};
rpc GetBucketStats(GetBucketStatsDataRequest) returns (GetBucketStatsDataResponse) {};
rpc GetSRMetrics(GetSRMetricsDataRequest) returns (GetSRMetricsDataResponse) {};
rpc GetAllBucketStats(GetAllBucketStatsRequest) returns (GetAllBucketStatsResponse) {};
rpc LoadBucketMetadata(LoadBucketMetadataRequest) returns (LoadBucketMetadataResponse) {};
rpc DeleteBucketMetadata(DeleteBucketMetadataRequest) returns (DeleteBucketMetadataResponse) {};
rpc DeletePolicy(DeletePolicyRequest) returns (DeletePolicyResponse) {};
rpc LoadPolicy(LoadPolicyRequest) returns (LoadPolicyResponse) {};
rpc LoadPolicyMapping(LoadPolicyMappingRequest) returns (LoadPolicyMappingResponse) {};
rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) {};
rpc DeleteServiceAccount(DeleteServiceAccountRequest) returns (DeleteServiceAccountResponse) {};
rpc LoadUser(LoadUserRequest) returns (LoadUserResponse) {};
rpc LoadServiceAccount(LoadServiceAccountRequest) returns (LoadServiceAccountResponse) {};
rpc LoadGroup(LoadGroupRequest) returns (LoadGroupResponse) {};
rpc ReloadSiteReplicationConfig(ReloadSiteReplicationConfigRequest) returns (ReloadSiteReplicationConfigResponse) {};
// rpc VerifyBinary() returns () {};
// rpc CommitBinary() returns () {};
rpc SignalService(SignalServiceRequest) returns (SignalServiceResponse) {};
rpc BackgroundHealStatus(BackgroundHealStatusRequest) returns (BackgroundHealStatusResponse) {};
rpc GetMetacacheListing(GetMetacacheListingRequest) returns (GetMetacacheListingResponse) {};
rpc UpdateMetacacheListing(UpdateMetacacheListingRequest) returns (UpdateMetacacheListingResponse) {};
rpc ReloadPoolMeta(ReloadPoolMetaRequest) returns (ReloadPoolMetaResponse) {};
rpc StopRebalance(StopRebalanceRequest) returns (StopRebalanceResponse) {};
rpc LoadRebalanceMeta(LoadRebalanceMetaRequest) returns (LoadRebalanceMetaResponse) {};
rpc LoadTransitionTierConfig(LoadTransitionTierConfigRequest) returns (LoadTransitionTierConfigResponse) {};
}