From 03589201fb23e03a3bd7e5250f656b64bfcc7520 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 21 Feb 2025 13:46:35 +0800 Subject: [PATCH 001/103] Implement initialization for packages/logging - Add initialization logic for the `rustfs-logging` crate. - Provide examples for logging utilities. - Include tests for logging and telemetry functionalities. - Ensure proper configuration of dependencies in `Cargo.toml`. --- Cargo.lock | 140 +++++++++++++++++++++++++++ Cargo.toml | 10 +- packages/logging/Cargo.toml | 35 +++++++ packages/logging/src/audit.rs | 153 ++++++++++++++++++++++++++++++ packages/logging/src/lib.rs | 83 ++++++++++++++++ packages/logging/src/logger.rs | 46 +++++++++ packages/logging/src/telemetry.rs | 113 ++++++++++++++++++++++ rustfs/src/logging/mod.rs | 0 rustfs/src/main.rs | 14 +-- 9 files changed, 587 insertions(+), 7 deletions(-) create mode 100644 packages/logging/Cargo.toml create mode 100644 packages/logging/src/audit.rs create mode 100644 packages/logging/src/lib.rs create mode 100644 packages/logging/src/logger.rs create mode 100644 packages/logging/src/telemetry.rs create mode 100644 rustfs/src/logging/mod.rs diff --git a/Cargo.lock b/Cargo.lock index d1dc017d0..d6a65c06e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4290,6 +4290,109 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "opentelemetry" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "236e667b670a5cdf90c258f5a55794ec5ac5027e960c224bff8367a59e1e6426" +dependencies = [ + "futures-core", + "futures-sink", + "js-sys", + "pin-project-lite", + "thiserror 2.0.11", + "tracing", +] + +[[package]] +name = "opentelemetry-http" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8863faf2910030d139fb48715ad5ff2f35029fc5f244f6d5f689ddcf4d26253" +dependencies = [ + "async-trait", + "bytes", + "http", + "opentelemetry", + "reqwest", + "tracing", +] + +[[package]] +name = "opentelemetry-otlp" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bef114c6d41bea83d6dc60eb41720eedd0261a67af57b66dd2b84ac46c01d91" +dependencies = [ + "async-trait", + "futures-core", + "http", + "opentelemetry", + "opentelemetry-http", + "opentelemetry-proto", + "opentelemetry_sdk", + "prost", + "reqwest", + "thiserror 2.0.11", + "tokio", + "tonic", + "tracing", +] + +[[package]] +name = "opentelemetry-proto" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f8870d3024727e99212eb3bb1762ec16e255e3e6f58eeb3dc8db1aa226746d" +dependencies = [ + "opentelemetry", + "opentelemetry_sdk", + "prost", + "tonic", +] + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fb3a2f78c2d55362cd6c313b8abedfbc0142ab3c2676822068fd2ab7d51f9b7" + +[[package]] +name = "opentelemetry-stdout" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb0e5a5132e4b80bf037a78e3e12c8402535199f5de490d0c38f7eac71bc831" +dependencies = [ + "async-trait", + "chrono", + "futures-util", + "opentelemetry", + "opentelemetry_sdk", + "serde", + "thiserror 2.0.11", +] + +[[package]] +name = "opentelemetry_sdk" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84dfad6042089c7fc1f6118b7040dc2eb4ab520abbf410b79dc481032af39570" +dependencies = [ + "async-trait", + "futures-channel", + "futures-executor", + "futures-util", + "glob", + "opentelemetry", + "percent-encoding", + "rand 0.8.5", + "serde_json", + "thiserror 2.0.11", + "tokio", + "tokio-stream", + "tracing", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -5213,6 +5316,7 @@ dependencies = [ "base64", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", "h2", @@ -5443,6 +5547,23 @@ dependencies = [ "zip", ] +[[package]] +name = "rustfs-logging" +version = "0.0.1" +dependencies = [ + "chrono", + "opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "opentelemetry-stdout", + "opentelemetry_sdk", + "serde", + "tokio", + "tracing", + "tracing-opentelemetry", + "tracing-subscriber", +] + [[package]] name = "rustix" version = "0.38.44" @@ -6440,6 +6561,7 @@ dependencies = [ "bytes", "libc", "mio", + "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", "socket2", @@ -6738,6 +6860,24 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-opentelemetry" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721f2d2569dce9f3dfbbddee5906941e953bfcdf736a62da3377f5751650cc36" +dependencies = [ + "js-sys", + "once_cell", + "opentelemetry", + "opentelemetry_sdk", + "smallvec", + "tracing", + "tracing-core", + "tracing-log", + "tracing-subscriber", + "web-time", +] + [[package]] name = "tracing-serde" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index eed309921..511155ef1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "iam", "crypto", "cli/rustfs-gui", + "packages/logging", ] resolver = "2" @@ -59,6 +60,11 @@ lock = { path = "./common/lock" } lazy_static = "1.5.0" mime = "0.3.17" netif = "0.1.6" +opentelemetry = { version = "0.28" } +opentelemetry_sdk = { version = "0.28" } +opentelemetry-stdout = { version = "0.28.0" } +opentelemetry-otlp = { version = "0.28" } +opentelemetry-semantic-conventions = { version = "0.28.0", features = ["semconv_experimental"] } pin-project-lite = "0.2" # pin-utils = "0.1.0" prost = "0.13.4" @@ -71,6 +77,7 @@ reqwest = { version = "0.12.12", default-features = false, features = ["rustls-t rfd = "0.15.2" rmp = "0.8.14" rmp-serde = "1.3.0" +rustfs-logging = { path = "packages/logging", version = "0.0.1" } s3s = { git = "https://github.com/Nugine/s3s.git", rev = "529c8933a11528c506d5fbf7c4c2ab155db37dfe", default-features = true, features = [ "tower", ] } @@ -96,6 +103,7 @@ tracing = "0.1.41" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "time"] } tracing-appender = "0.2.3" +tracing-opentelemetry = "0.29" transform-stream = "0.3.1" url = "2.5.4" uuid = { version = "1.12.1", features = [ @@ -108,4 +116,4 @@ axum = "0.7.9" md-5 = "0.10.6" workers = { path = "./common/workers" } test-case = "3.3.1" -zip = "2.2.2" \ No newline at end of file +zip = "2.2.2" diff --git a/packages/logging/Cargo.toml b/packages/logging/Cargo.toml new file mode 100644 index 000000000..af37740d9 --- /dev/null +++ b/packages/logging/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "rustfs-logging" +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[lints] +workspace = true + +[dependencies] +opentelemetry = { workspace = true } +opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } +opentelemetry-stdout = { workspace = true } +opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "metrics"] } +opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] } +serde = { workspace = true } +tracing = { workspace = true } +tracing-opentelemetry = { workspace = true } +tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } +tokio = { workspace = true, features = ["full"] } + + + +[dev-dependencies] +chrono = { workspace = true } +opentelemetry = { workspace = true, features = ["trace", "metrics"] } +opentelemetry_sdk = { workspace = true, features = ["trace", "rt-tokio"] } +opentelemetry-stdout = { workspace = true, features = ["trace", "metrics"] } +opentelemetry-otlp = { workspace = true, features = ["metrics", "grpc-tonic"] } +opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] } +tokio = { workspace = true, features = ["full"] } +tracing = { workspace = true, features = ["std", "attributes"] } +tracing-subscriber = { workspace = true, features = ["registry", "std", "fmt"] } \ No newline at end of file diff --git a/packages/logging/src/audit.rs b/packages/logging/src/audit.rs new file mode 100644 index 000000000..0f120db2c --- /dev/null +++ b/packages/logging/src/audit.rs @@ -0,0 +1,153 @@ +use serde::{Deserialize, Serialize}; +use tokio::sync::mpsc; + +/// AuditEntry is a struct that represents an audit entry +/// that can be logged +/// # Fields +/// * `version` - The version of the audit entry +/// * `event_type` - The type of event that occurred +/// * `bucket` - The bucket that was accessed +/// * `object` - The object that was accessed +/// * `user` - The user that accessed the object +/// * `time` - The time the event occurred +/// * `user_agent` - The user agent that accessed the object +/// * `span_id` - The span ID of the event +/// # Example +/// ``` +/// use rustfs_logging::AuditEntry; +/// let entry = AuditEntry { +/// version: "1.0".to_string(), +/// event_type: "read".to_string(), +/// bucket: "bucket".to_string(), +/// object: "object".to_string(), +/// user: "user".to_string(), +/// time: "time".to_string(), +/// user_agent: "user_agent".to_string(), +/// span_id: "span_id".to_string(), +/// }; +/// ``` +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct AuditEntry { + pub version: String, + pub event_type: String, + pub bucket: String, + pub object: String, + pub user: String, + pub time: String, + pub user_agent: String, + pub span_id: String, +} + +/// AuditTarget is a trait that defines the interface for audit targets +/// that can receive audit entries +pub trait AuditTarget: Send + Sync { + fn send(&self, entry: AuditEntry); +} + +/// FileAuditTarget is an audit target that logs audit entries to a file +pub struct FileAuditTarget; + +impl AuditTarget for FileAuditTarget { + /// Send an audit entry to a file + /// # Arguments + /// * `entry` - The audit entry to send + /// # Example + /// ``` + /// use rustfs_logging::{AuditEntry, AuditTarget, FileAuditTarget}; + /// let entry = AuditEntry { + /// version: "1.0".to_string(), + /// event_type: "read".to_string(), + /// bucket: "bucket".to_string(), + /// object: "object".to_string(), + /// user: "user".to_string(), + /// time: "time".to_string(), + /// user_agent: "user_agent".to_string(), + /// span_id: "span_id".to_string(), + /// }; + /// FileAuditTarget.send(entry); + /// ``` + /// + fn send(&self, entry: AuditEntry) { + println!("File audit: {:?}", entry); + } +} + +/// AuditLogger is a logger that logs audit entries +/// to multiple targets +/// +/// # Example +/// ``` +/// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget}; +/// +/// #[tokio::main] +/// async fn main() { +/// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); +/// let entry = AuditEntry { +/// version: "1.0".to_string(), +/// event_type: "read".to_string(), +/// bucket: "bucket".to_string(), +/// object: "object".to_string(), +/// user: "user".to_string(), +/// time: "time".to_string(), +/// user_agent: "user_agent".to_string(), +/// span_id: "span_id".to_string(), +/// }; +/// logger.log(entry).await; +/// } +/// ``` +#[derive(Debug)] +pub struct AuditLogger { + tx: mpsc::Sender, +} + +impl AuditLogger { + /// Create a new AuditLogger with the given targets + /// that will receive audit entries + /// # Arguments + /// * `targets` - A vector of audit targets + /// # Returns + /// * An AuditLogger + /// # Example + /// ``` + /// use rustfs_logging::{AuditLogger, AuditEntry, FileAuditTarget}; + /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); + /// ``` + pub fn new(targets: Vec>) -> Self { + let (tx, mut rx) = mpsc::channel::(1000); + tokio::spawn(async move { + while let Some(entry) = rx.recv().await { + for target in &targets { + target.send(entry.clone()); + } + } + }); + Self { tx } + } + + /// Log an audit entry + /// # Arguments + /// * `entry` - The audit entry to log + /// # Example + /// ``` + /// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget}; + /// + /// #[tokio::main] + /// async fn main() { + /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); + /// let entry = AuditEntry { + /// version: "1.0".to_string(), + /// event_type: "read".to_string(), + /// bucket: "bucket".to_string(), + /// object: "object".to_string(), + /// user: "user".to_string(), + /// time: "time".to_string(), + /// user_agent: "user_agent".to_string(), + /// span_id: "span_id".to_string(), + /// }; + /// logger.log(entry).await; + /// } + /// ``` + pub async fn log(&self, entry: AuditEntry) { + let _ = self.tx.send(entry).await; + } +} diff --git a/packages/logging/src/lib.rs b/packages/logging/src/lib.rs new file mode 100644 index 000000000..3fdbb83d8 --- /dev/null +++ b/packages/logging/src/lib.rs @@ -0,0 +1,83 @@ +//! Logging utilities +/// +/// This crate provides utilities for logging. +/// +/// # Examples +/// ``` +/// use rustfs_logging::{log_info, log_error}; +/// +/// log_info("This is an informational message"); +/// log_error("This is an error message"); +/// ``` +pub use audit::{AuditEntry, AuditLogger, AuditTarget, FileAuditTarget}; +pub use logger::{log_debug, log_error, log_info}; +pub use telemetry::Telemetry; + +mod audit; +mod logger; +mod telemetry; + +#[cfg(test)] +mod tests { + use super::*; + use opentelemetry::global; + use opentelemetry::trace::TraceContextExt; + use std::time::{Duration, SystemTime}; + use tracing::{instrument, Span}; + use tracing_opentelemetry::OpenTelemetrySpanExt; + + #[instrument(fields(bucket, object, user))] + async fn put_object(audit_logger: &AuditLogger, bucket: String, object: String, user: String) { + let start_time = SystemTime::now(); + log_info("Starting PUT operation"); + + // Simulate the operation + tokio::time::sleep(Duration::from_millis(100)).await; + + // Record Metrics + let meter = global::meter("rustfs.rs"); + let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); + request_duration.record( + start_time.elapsed().unwrap().as_secs_f64(), + &[opentelemetry::KeyValue::new("operation", "put_object")], + ); + + // Gets the current span + let span = Span::current(); + + // Use 'OpenTelemetrySpanExt' to get 'SpanContext' + let span_context = span.context(); // Get context via OpenTelemetrySpanExt + let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId + + // Audit events are logged + let audit_entry = AuditEntry { + version: "1.0".to_string(), + event_type: "s3_put_object".to_string(), + bucket, + object, + user, + time: chrono::Utc::now().to_rfc3339(), + user_agent: "rustfs.rs-client".to_string(), + span_id, + }; + audit_logger.log(audit_entry).await; + + log_info("PUT operation completed"); + } + + #[tokio::test] + async fn test_main() { + let telemetry = Telemetry::init(); + + // Initialize multiple audit objectives + let audit_targets: Vec> = vec![Box::new(FileAuditTarget)]; + let audit_logger = AuditLogger::new(audit_targets); + + // Test the PUT operation + put_object(&audit_logger, "my-bucket".to_string(), "my-object.txt".to_string(), "user123".to_string()).await; + + // Wait for the export to complete + tokio::time::sleep(Duration::from_secs(2)).await; + drop(telemetry); // Make sure to clean up + } +} diff --git a/packages/logging/src/logger.rs b/packages/logging/src/logger.rs new file mode 100644 index 000000000..67c8e630c --- /dev/null +++ b/packages/logging/src/logger.rs @@ -0,0 +1,46 @@ +use tracing::{debug, error, info}; + +/// Log an info message +/// +/// # Arguments +/// msg: &str - The message to log +/// +/// # Example +/// ``` +/// use rustfs_logging::log_info; +/// +/// log_info("This is an info message"); +/// ``` +pub fn log_info(msg: &str) { + info!("{}", msg); +} + +/// Log an error message +/// +/// # Arguments +/// msg: &str - The message to log +/// +/// # Example +/// ``` +/// use rustfs_logging::log_error; +/// +/// log_error("This is an error message"); +/// ``` +pub fn log_error(msg: &str) { + error!("{}", msg); +} + +/// Log a debug message +/// +/// # Arguments +/// msg: &str - The message to log +/// +/// # Example +/// ``` +/// use rustfs_logging::log_debug; +/// +/// log_debug("This is a debug message"); +/// ``` +pub fn log_debug(msg: &str) { + debug!("{}", msg); +} diff --git a/packages/logging/src/telemetry.rs b/packages/logging/src/telemetry.rs new file mode 100644 index 000000000..4d1759c49 --- /dev/null +++ b/packages/logging/src/telemetry.rs @@ -0,0 +1,113 @@ +use opentelemetry::trace::TracerProvider; +use opentelemetry::{global, KeyValue}; +use opentelemetry_otlp::{self, WithExportConfig}; +use opentelemetry_sdk::{ + metrics::{MeterProviderBuilder, PeriodicReader, SdkMeterProvider}, + trace::{RandomIdGenerator, Sampler, SdkTracerProvider}, + Resource, +}; +use opentelemetry_semantic_conventions::{ + attribute::{DEPLOYMENT_ENVIRONMENT_NAME, SERVICE_NAME, SERVICE_VERSION}, + SCHEMA_URL, +}; +use tracing::Level; +use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; + +/// Telemetry is a wrapper around the OpenTelemetry SDK Tracer and Meter providers. +/// It initializes the global Tracer and Meter providers, and sets up the tracing subscriber. +/// The Tracer and Meter providers are shut down when the Telemetry instance is dropped. +/// This is a convenience struct to ensure that the global providers are properly initialized and shut down. +/// +/// # Example +/// ``` +/// use rustfs_logging::Telemetry; +/// +/// let _telemetry = Telemetry::init(); +/// ``` +pub struct Telemetry { + tracer_provider: SdkTracerProvider, + meter_provider: SdkMeterProvider, +} + +impl Telemetry { + pub fn init() -> Self { + // Define service resource information + let resource = Resource::builder() + .with_schema_url( + [ + KeyValue::new(SERVICE_NAME, env!("CARGO_PKG_NAME")), + KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")), + KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, "develop"), + ], + SCHEMA_URL, + ) + .build(); + + let tracer_exporter = opentelemetry_otlp::SpanExporter::builder() + .with_tonic() + .with_endpoint("http://localhost:4317") + .build() + .unwrap(); + + // Configure Tracer Provider + let tracer_provider = SdkTracerProvider::builder() + .with_sampler(Sampler::AlwaysOn) + .with_id_generator(RandomIdGenerator::default()) + .with_resource(resource.clone()) + .with_batch_exporter(tracer_exporter) + .with_simple_exporter(opentelemetry_stdout::SpanExporter::default()) + .build(); + + let meter_exporter = opentelemetry_otlp::MetricExporter::builder() + .with_tonic() + .with_endpoint("http://localhost:4317") + .with_temporality(opentelemetry_sdk::metrics::Temporality::default()) + .build() + .unwrap(); + + let meter_reader = PeriodicReader::builder(meter_exporter) + .with_interval(std::time::Duration::from_secs(30)) + .build(); + + // For debugging in development + let meter_stdout_reader = PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()).build(); + + // Configure Meter Provider + let meter_provider = MeterProviderBuilder::default() + .with_resource(resource) + .with_reader(meter_reader) + .with_reader(meter_stdout_reader) + .build(); + + // Set global Tracer and Meter providers + global::set_tracer_provider(tracer_provider.clone()); + global::set_meter_provider(meter_provider.clone()); + + let tracer = tracer_provider.tracer("tracing-otel-subscriber-rustfs-service"); + + // Configure `tracing subscriber` + tracing_subscriber::registry() + .with(tracing_subscriber::filter::LevelFilter::from_level(Level::DEBUG)) + .with(tracing_subscriber::fmt::layer().with_ansi(true)) + .with(MetricsLayer::new(meter_provider.clone())) + .with(OpenTelemetryLayer::new(tracer)) + .init(); + + Self { + tracer_provider, + meter_provider, + } + } +} + +impl Drop for Telemetry { + fn drop(&mut self) { + if let Err(err) = self.tracer_provider.shutdown() { + eprintln!("{err:?}"); + } + if let Err(err) = self.meter_provider.shutdown() { + eprintln!("{err:?}"); + } + } +} diff --git a/rustfs/src/logging/mod.rs b/rustfs/src/logging/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index a2ed47909..cfd84975a 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -3,8 +3,10 @@ mod auth; mod config; mod console; mod grpc; +mod logging; mod service; mod storage; + use crate::auth::IAMAuth; use clap::Parser; use common::{ @@ -68,7 +70,7 @@ fn main() -> Result<()> { //解析获得到的参数 let opt = config::Opt::parse(); - //设置trace + //设置 trace setup_tracing(); //运行参数 @@ -91,17 +93,17 @@ async fn run(opt: config::Opt) -> Result<()> { debug!("server_address {}", &server_address); - //设置AK和SK + //设置 AK 和 SK iam::init_global_action_cred(Some(opt.access_key.clone()), Some(opt.secret_key.clone())).unwrap(); set_global_rustfs_port(server_port); - //监听地址,端口从参数中获取 + //监听地址,端口从参数中获取 let listener = TcpListener::bind(server_address.clone()).await?; //获取监听地址 let local_addr: SocketAddr = listener.local_addr()?; - // 用于rpc + // 用于 rpc let (endpoint_pools, setup_type) = EndpointServerPools::from_volumes(server_address.clone().as_str(), opt.volumes.clone()) .map_err(|err| Error::from_string(err.to_string()))?; @@ -123,13 +125,13 @@ async fn run(opt: config::Opt) -> Result<()> { .map_err(|err| Error::from_string(err.to_string()))?; // Setup S3 service - // 本项目使用s3s库来实现s3服务 + // 本项目使用 s3s 库来实现 s3 服务 let service = { let store = storage::ecfs::FS::new(); // let mut b = S3ServiceBuilder::new(storage::ecfs::FS::new(server_address.clone(), endpoint_pools).await?); let mut b = S3ServiceBuilder::new(store.clone()); - //显示info信息 + //显示 info 信息 info!("authentication is enabled {}, {}", &opt.access_key, &opt.secret_key); b.set_auth(IAMAuth::new(opt.access_key, opt.secret_key)); From c04536b13249bfebdaee0992c51966e2edaa7906 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 21 Feb 2025 18:49:25 +0800 Subject: [PATCH 002/103] feat(logging): add Kafka and Webhook audit targets - Implemented `KafkaAuditTarget` to send audit entries to a Kafka topic. - Implemented `WebhookAuditTarget` to send audit entries to a specified webhook URL. - Updated `AuditLogger` to support multiple audit targets including Kafka and Webhook. - Added examples and documentation for the new audit targets. --- Cargo.lock | 33 ++++++++++++++ Cargo.toml | 1 + packages/logging/Cargo.toml | 8 ++++ packages/logging/src/audit.rs | 84 +++++++++++++++++++++++++++++++++++ packages/logging/src/lib.rs | 12 ++++- 5 files changed, 137 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d6a65c06e..1df7969a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5192,6 +5192,36 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" +[[package]] +name = "rdkafka" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b52c81ac3cac39c9639b95c20452076e74b8d9a71bc6fc4d83407af2ea6fff" +dependencies = [ + "futures-channel", + "futures-util", + "libc", + "log", + "rdkafka-sys", + "serde", + "serde_derive", + "serde_json", + "slab", + "tokio", +] + +[[package]] +name = "rdkafka-sys" +version = "4.8.0+2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced38182dc436b3d9df0c77976f37a67134df26b050df1f0006688e46fc4c8be" +dependencies = [ + "libc", + "libz-sys", + "num_enum", + "pkg-config", +] + [[package]] name = "reader" version = "0.0.1" @@ -5557,7 +5587,10 @@ dependencies = [ "opentelemetry-semantic-conventions", "opentelemetry-stdout", "opentelemetry_sdk", + "rdkafka", + "reqwest", "serde", + "serde_json", "tokio", "tracing", "tracing-opentelemetry", diff --git a/Cargo.toml b/Cargo.toml index 511155ef1..581799808 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ protobuf = "3.7" protos = { path = "./common/protos" } rand = "0.8.5" reqwest = { version = "0.12.12", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream"] } +rdkafka = { version = "0.37", features = ["tokio"] } rfd = "0.15.2" rmp = "0.8.14" rmp-serde = "1.3.0" diff --git a/packages/logging/Cargo.toml b/packages/logging/Cargo.toml index af37740d9..5b8f84493 100644 --- a/packages/logging/Cargo.toml +++ b/packages/logging/Cargo.toml @@ -9,6 +9,11 @@ version.workspace = true [lints] workspace = true +[features] +default = [] +audit-kafka = ["dep:rdkafka", "dep:serde_json"] +audit-webhook = ["dep:reqwest"] + [dependencies] opentelemetry = { workspace = true } opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } @@ -20,6 +25,9 @@ tracing = { workspace = true } tracing-opentelemetry = { workspace = true } tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } tokio = { workspace = true, features = ["full"] } +rdkafka = { workspace = true, features = ["tokio"], optional = true } +reqwest = { workspace = true, features = ["json"], optional = true } +serde_json = { workspace = true, optional = true } diff --git a/packages/logging/src/audit.rs b/packages/logging/src/audit.rs index 0f120db2c..311d31044 100644 --- a/packages/logging/src/audit.rs +++ b/packages/logging/src/audit.rs @@ -1,3 +1,12 @@ +#[cfg(feature = "audit-kafka")] +use rdkafka::{ + producer::{FutureProducer, FutureRecord}, + ClientConfig, +}; + +#[cfg(feature = "audit-webhook")] +use reqwest::Client; + use serde::{Deserialize, Serialize}; use tokio::sync::mpsc; @@ -72,6 +81,80 @@ impl AuditTarget for FileAuditTarget { } } +#[cfg(feature = "audit-webhook")] +/// Webhook audit objectives +pub struct WebhookAuditTarget { + client: Client, + url: String, +} + +#[cfg(feature = "audit-webhook")] +impl WebhookAuditTarget { + pub fn new(url: &str) -> Self { + Self { + client: Client::new(), + url: url.to_string(), + } + } +} + +#[cfg(feature = "audit-webhook")] +impl AuditTarget for WebhookAuditTarget { + fn send(&self, entry: AuditEntry) { + let client = self.client.clone(); + let url = self.url.clone(); + tokio::spawn(async move { + if let Err(e) = client.post(&url).json(&entry).send().await { + eprintln!("Failed to send to Webhook: {:?}", e); + } + }); + } +} + +#[cfg(feature = "audit-kafka")] +/// Kafka audit objectives +pub struct KafkaAuditTarget { + producer: FutureProducer, + topic: String, +} + +#[cfg(feature = "audit-kafka")] +impl KafkaAuditTarget { + pub fn new(brokers: &str, topic: &str) -> Self { + let producer: FutureProducer = ClientConfig::new() + .set("bootstrap.servers", brokers) + .set("message.timeout.ms", "5000") + .create() + .expect("Kafka producer creation failed"); + Self { + producer, + topic: topic.to_string(), + } + } +} + +#[cfg(feature = "audit-kafka")] +impl AuditTarget for KafkaAuditTarget { + fn send(&self, entry: AuditEntry) { + let topic = self.topic.clone(); + let span_id = entry.span_id.clone(); + let payload = serde_json::to_string(&entry).unwrap(); + // let record = FutureRecord::to(&topic).payload(&payload).key(&span_id); + tokio::spawn({ + // 在异步闭包内部创建 record + let topic = topic; + let payload = payload; + let span_id = span_id; + let producer = self.producer.clone(); + async move { + let record = FutureRecord::to(&topic).payload(&payload).key(&span_id); + if let Err(e) = producer.send(record, std::time::Duration::from_secs(0)).await { + eprintln!("Failed to send to Kafka: {:?}", e); + } + } + }); + } +} /// AuditLogger is a logger that logs audit entries /// to multiple targets /// @@ -110,6 +193,7 @@ impl AuditLogger { /// # Example /// ``` /// use rustfs_logging::{AuditLogger, AuditEntry, FileAuditTarget}; + /// /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); /// ``` pub fn new(targets: Vec>) -> Self { diff --git a/packages/logging/src/lib.rs b/packages/logging/src/lib.rs index 3fdbb83d8..280d9e76a 100644 --- a/packages/logging/src/lib.rs +++ b/packages/logging/src/lib.rs @@ -9,6 +9,10 @@ /// log_info("This is an informational message"); /// log_error("This is an error message"); /// ``` +#[cfg(feature = "audit-kafka")] +pub use audit::KafkaAuditTarget; +#[cfg(feature = "audit-webhook")] +pub use audit::WebhookAuditTarget; pub use audit::{AuditEntry, AuditLogger, AuditTarget, FileAuditTarget}; pub use logger::{log_debug, log_error, log_info}; pub use telemetry::Telemetry; @@ -66,11 +70,17 @@ mod tests { } #[tokio::test] + // #[cfg(feature = "audit-webhook")] + // #[cfg(feature = "audit-kafka")] async fn test_main() { let telemetry = Telemetry::init(); // Initialize multiple audit objectives - let audit_targets: Vec> = vec![Box::new(FileAuditTarget)]; + let audit_targets: Vec> = vec![ + Box::new(FileAuditTarget), + // Box::new(KafkaAuditTarget::new("localhost:9092", "rustfs-audit")), + // Box::new(WebhookAuditTarget::new("http://localhost:8080/audit")), + ]; let audit_logger = AuditLogger::new(audit_targets); // Test the PUT operation From b117281c58ed84f4acfee9a2e28b7419f0f237c8 Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 23 Feb 2025 16:38:41 +0800 Subject: [PATCH 003/103] improve code for audit --- Cargo.lock | 18 ++++++++ packages/logging/src/audit.rs | 80 ++++++++++++++++++++++++++++++++++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 65f3a58fe..d4a69555b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3523,6 +3523,18 @@ dependencies = [ "x11", ] +[[package]] +name = "libz-sys" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -7085,6 +7097,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.2.0" diff --git a/packages/logging/src/audit.rs b/packages/logging/src/audit.rs index 311d31044..712ed088a 100644 --- a/packages/logging/src/audit.rs +++ b/packages/logging/src/audit.rs @@ -60,6 +60,7 @@ impl AuditTarget for FileAuditTarget { /// Send an audit entry to a file /// # Arguments /// * `entry` - The audit entry to send + /// /// # Example /// ``` /// use rustfs_logging::{AuditEntry, AuditTarget, FileAuditTarget}; @@ -75,7 +76,6 @@ impl AuditTarget for FileAuditTarget { /// }; /// FileAuditTarget.send(entry); /// ``` - /// fn send(&self, entry: AuditEntry) { println!("File audit: {:?}", entry); } @@ -83,6 +83,14 @@ impl AuditTarget for FileAuditTarget { #[cfg(feature = "audit-webhook")] /// Webhook audit objectives +/// #Arguments +/// * `client` - The reqwest client +/// * `url` - The URL of the webhook +/// # Example +/// ``` +/// use rustfs_logging::WebhookAuditTarget; +/// let target = WebhookAuditTarget::new("http://localhost:8080"); +/// ``` pub struct WebhookAuditTarget { client: Client, url: String, @@ -113,6 +121,52 @@ impl AuditTarget for WebhookAuditTarget { #[cfg(feature = "audit-kafka")] /// Kafka audit objectives +/// # Arguments +/// * `producer` - The Kafka producer +/// * `topic` - The Kafka topic +/// # Example +/// ``` +/// use rustfs_logging::KafkaAuditTarget; +/// let target = KafkaAuditTarget::new("localhost:9092", "rustfs-audit"); +/// ``` +/// # Note +/// This feature requires the `rdkafka` crate +/// # Example +/// ```toml +/// [dependencies] +/// rdkafka = "0.26.0" +/// rustfs_logging = { version = "0.1.0", features = ["audit-kafka"] } +/// ``` +/// # Note +/// The `rdkafka` crate requires the `librdkafka` library to be installed +/// # Example +/// ```sh +/// sudo apt-get install librdkafka-dev +/// ``` +/// # Note +/// The `rdkafka` crate requires the `libssl-dev` and `pkg-config` packages to be installed +/// # Example +/// ```sh +/// sudo apt-get install libssl-dev pkg-config +/// ``` +/// # Note +/// The `rdkafka` crate requires the `zlib1g-dev` package to be installed +/// # Example +/// ```sh +/// sudo apt-get install zlib1g-dev +/// ``` +/// # Note +/// The `rdkafka` crate requires the `zstd` package to be installed +/// # Example +/// ```sh +/// sudo apt-get install zstd +/// ``` +/// # Note +/// The `rdkafka` crate requires the `lz4` package to be installed +/// # Example +/// ```sh +/// sudo apt-get install lz4 +/// ``` pub struct KafkaAuditTarget { producer: FutureProducer, topic: String, @@ -178,7 +232,31 @@ impl AuditTarget for KafkaAuditTarget { /// logger.log(entry).await; /// } /// ``` + #[derive(Debug)] +/// AuditLogger is a logger that logs audit entries +/// to multiple targets +/// # Example +/// ``` +/// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget}; +/// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); +/// ``` +/// # Note +/// This feature requires the `tokio` crate +/// # Example +/// ```toml +/// [dependencies] +/// tokio = { version = "1", features = ["full"] } +/// rustfs_logging = { version = "0.1.0"} +/// ``` +/// # Note +/// This feature requires the `serde` crate +/// # Example +/// ```toml +/// [dependencies] +/// serde = { version = "1", features = ["derive"] } +/// rustfs_logging = { version = "0.1.0"} +/// ``` pub struct AuditLogger { tx: mpsc::Sender, } From 5ca101b81c4af6a71f20753e8fa548982610b13c Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 27 Feb 2025 19:00:47 +0800 Subject: [PATCH 004/103] add --- Cargo.lock | 15 +++++ Cargo.toml | 19 ++++++ packages/logging/Cargo.toml | 1 + packages/logging/src/audit.rs | 6 +- packages/logging/src/lib.rs | 101 +++++++++++++++++++++++++++++- packages/logging/src/telemetry.rs | 58 +++++++++++++---- 6 files changed, 186 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4a69555b..5f75b06b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4278,6 +4278,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "opentelemetry-appender-tracing" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c513c7af3bec30113f3d4620134ff923295f1e9c580fda2b8abe0831f925ddc0" +dependencies = [ + "opentelemetry", + "tracing", + "tracing-core", + "tracing-log", + "tracing-opentelemetry", + "tracing-subscriber", +] + [[package]] name = "opentelemetry-http" version = "0.28.0" @@ -5546,6 +5560,7 @@ version = "0.0.1" dependencies = [ "chrono", "opentelemetry", + "opentelemetry-appender-tracing", "opentelemetry-otlp", "opentelemetry-semantic-conventions", "opentelemetry-stdout", diff --git a/Cargo.toml b/Cargo.toml index 8cad324fa..f9a80d9d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,6 +61,7 @@ lazy_static = "1.5.0" mime = "0.3.17" netif = "0.1.6" opentelemetry = { version = "0.28" } +opentelemetry-appender-tracing = { version = "0.28.1" } opentelemetry_sdk = { version = "0.28" } opentelemetry-stdout = { version = "0.28.0" } opentelemetry-otlp = { version = "0.28" } @@ -119,3 +120,21 @@ md-5 = "0.10.6" workers = { path = "./common/workers" } test-case = "3.3.1" zip = "2.2.2" + + +[profile] + +[profile.wasm-dev] +inherits = "dev" +opt-level = 1 + +[profile.server-dev] +inherits = "dev" + +[profile.android-dev] +inherits = "dev" + +[profile.release] +opt-level = 3 # Optimization Level (0-3) +lto = true # Optimize when linking +codegen-units = 1 # Reduce code generation units to improve optimization \ No newline at end of file diff --git a/packages/logging/Cargo.toml b/packages/logging/Cargo.toml index 5b8f84493..73c7c3f97 100644 --- a/packages/logging/Cargo.toml +++ b/packages/logging/Cargo.toml @@ -16,6 +16,7 @@ audit-webhook = ["dep:reqwest"] [dependencies] opentelemetry = { workspace = true } +opentelemetry-appender-tracing = { workspace = true, features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } opentelemetry-stdout = { workspace = true } opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "metrics"] } diff --git a/packages/logging/src/audit.rs b/packages/logging/src/audit.rs index 712ed088a..a8c5d5a24 100644 --- a/packages/logging/src/audit.rs +++ b/packages/logging/src/audit.rs @@ -86,7 +86,7 @@ impl AuditTarget for FileAuditTarget { /// #Arguments /// * `client` - The reqwest client /// * `url` - The URL of the webhook -/// # Example +/// # Example /// ``` /// use rustfs_logging::WebhookAuditTarget; /// let target = WebhookAuditTarget::new("http://localhost:8080"); @@ -310,6 +310,10 @@ impl AuditLogger { /// } /// ``` pub async fn log(&self, entry: AuditEntry) { + // 将日志消息记录到当前 Span + tracing::Span::current() + .record("log_message", &entry.bucket) + .record("source", &entry.event_type); let _ = self.tx.send(entry).await; } } diff --git a/packages/logging/src/lib.rs b/packages/logging/src/lib.rs index 280d9e76a..70e1eb2a5 100644 --- a/packages/logging/src/lib.rs +++ b/packages/logging/src/lib.rs @@ -1,4 +1,5 @@ //! Logging utilities + /// /// This crate provides utilities for logging. /// @@ -24,8 +25,9 @@ mod telemetry; #[cfg(test)] mod tests { use super::*; + use chrono::Utc; use opentelemetry::global; - use opentelemetry::trace::TraceContextExt; + use opentelemetry::trace::{TraceContextExt, Tracer}; use std::time::{Duration, SystemTime}; use tracing::{instrument, Span}; use tracing_opentelemetry::OpenTelemetrySpanExt; @@ -60,7 +62,7 @@ mod tests { bucket, object, user, - time: chrono::Utc::now().to_rfc3339(), + time: Utc::now().to_rfc3339(), user_agent: "rustfs.rs-client".to_string(), span_id, }; @@ -83,11 +85,106 @@ mod tests { ]; let audit_logger = AuditLogger::new(audit_targets); + // 创建根 Span 并执行操作 + // let tracer = global::tracer("main"); + // tracer.in_span("main_operation", |cx| { + // Span::current().set_parent(cx); + // log_info("Starting test async"); + // tokio::runtime::Runtime::new().unwrap().block_on(async { + log_info("Starting test"); // Test the PUT operation put_object(&audit_logger, "my-bucket".to_string(), "my-object.txt".to_string(), "user123".to_string()).await; + tokio::time::sleep(Duration::from_millis(100)).await; + query_object(&audit_logger, "my-bucket".to_string(), "my-object.txt".to_string(), "user123".to_string()).await; + tokio::time::sleep(Duration::from_millis(100)).await; + for i in 0..100 { + put_object( + &audit_logger, + format!("my-bucket-{}", i), + format!("my-object-{}", i), + "user123".to_string(), + ) + .await; + tokio::time::sleep(Duration::from_millis(100)).await; + query_object( + &audit_logger, + format!("my-bucket-{}", i), + format!("my-object-{}", i), + "user123".to_string(), + ) + .await; + tokio::time::sleep(Duration::from_millis(100)).await; + } // Wait for the export to complete tokio::time::sleep(Duration::from_secs(2)).await; + log_info("Test completed"); + // }); + // }); drop(telemetry); // Make sure to clean up } + + #[instrument(fields(bucket, object, user))] + async fn query_object(audit_logger: &AuditLogger, bucket: String, object: String, user: String) { + let start_time = SystemTime::now(); + log_info("Starting query operation"); + + // Simulate the operation + tokio::time::sleep(Duration::from_millis(100)).await; + + // Record Metrics + let meter = global::meter("rustfs.rs"); + let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); + request_duration.record( + start_time.elapsed().unwrap().as_secs_f64(), + &[opentelemetry::KeyValue::new("operation", "query_object")], + ); + + // Gets the current span + let span = Span::current(); + // Use 'OpenTelemetrySpanExt' to get 'SpanContext' + let span_context = span.context(); // Get context via OpenTelemetrySpanExt + let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId + query_one(user.clone()); + query_two(user.clone()); + query_three(user.clone()); + // Audit events are logged + let audit_entry = AuditEntry { + version: "1.0".to_string(), + event_type: "s3_query_object".to_string(), + bucket, + object, + user, + time: Utc::now().to_rfc3339(), + user_agent: "rustfs.rs-client".to_string(), + span_id, + }; + audit_logger.log(audit_entry).await; + + log_info("query operation completed"); + } + #[instrument(fields(user))] + fn query_one(user: String) { + // 初始化 OpenTelemetry Tracer + let tracer = global::tracer("query_one"); + tracer.in_span("doing_work", |cx| { + // Traced app logic here... + Span::current().set_parent(cx); + log_info("Doing work..."); + let current_span = Span::current(); + let span_context = current_span.context(); + let trace_id = span_context.clone().span().span_context().trace_id().to_string(); + let span_id = span_context.clone().span().span_context().span_id().to_string(); + log_info(format!("trace_id: {}, span_id: {}", trace_id, span_id).as_str()); + }); + log_info(format!("Starting query_one operation user:{}", user).as_str()); + } + #[instrument(fields(user))] + fn query_two(user: String) { + log_info(format!("Starting query_two operation user:{}", user).as_str()); + } + #[instrument(fields(user))] + fn query_three(user: String) { + log_info(format!("Starting query_three operation user: {}", user).as_str()); + } } diff --git a/packages/logging/src/telemetry.rs b/packages/logging/src/telemetry.rs index 4d1759c49..edd362cd9 100644 --- a/packages/logging/src/telemetry.rs +++ b/packages/logging/src/telemetry.rs @@ -1,18 +1,22 @@ use opentelemetry::trace::TracerProvider; use opentelemetry::{global, KeyValue}; +use opentelemetry_appender_tracing::layer; use opentelemetry_otlp::{self, WithExportConfig}; +use opentelemetry_sdk::logs::SdkLoggerProvider; use opentelemetry_sdk::{ metrics::{MeterProviderBuilder, PeriodicReader, SdkMeterProvider}, trace::{RandomIdGenerator, Sampler, SdkTracerProvider}, Resource, }; +use opentelemetry_semantic_conventions::attribute::NETWORK_LOCAL_ADDRESS; use opentelemetry_semantic_conventions::{ attribute::{DEPLOYMENT_ENVIRONMENT_NAME, SERVICE_NAME, SERVICE_VERSION}, SCHEMA_URL, }; -use tracing::Level; +use std::time::Duration; +use tracing::{info, Level}; use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; +use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer}; /// Telemetry is a wrapper around the OpenTelemetry SDK Tracer and Meter providers. /// It initializes the global Tracer and Meter providers, and sets up the tracing subscriber. @@ -34,11 +38,13 @@ impl Telemetry { pub fn init() -> Self { // Define service resource information let resource = Resource::builder() + .with_service_name("rustfs-service") .with_schema_url( [ - KeyValue::new(SERVICE_NAME, env!("CARGO_PKG_NAME")), - KeyValue::new(SERVICE_VERSION, env!("CARGO_PKG_VERSION")), + KeyValue::new(SERVICE_NAME, "rustfs-service"), + KeyValue::new(SERVICE_VERSION, "0.1.0"), KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, "develop"), + KeyValue::new(NETWORK_LOCAL_ADDRESS, "127.0.0.1"), ], SCHEMA_URL, ) @@ -47,6 +53,8 @@ impl Telemetry { let tracer_exporter = opentelemetry_otlp::SpanExporter::builder() .with_tonic() .with_endpoint("http://localhost:4317") + .with_protocol(opentelemetry_otlp::Protocol::Grpc) + .with_timeout(Duration::from_secs(3)) .build() .unwrap(); @@ -56,35 +64,61 @@ impl Telemetry { .with_id_generator(RandomIdGenerator::default()) .with_resource(resource.clone()) .with_batch_exporter(tracer_exporter) - .with_simple_exporter(opentelemetry_stdout::SpanExporter::default()) + // .with_simple_exporter(opentelemetry_stdout::SpanExporter::default()) .build(); let meter_exporter = opentelemetry_otlp::MetricExporter::builder() .with_tonic() .with_endpoint("http://localhost:4317") + .with_protocol(opentelemetry_otlp::Protocol::Grpc) + .with_timeout(Duration::from_secs(3)) .with_temporality(opentelemetry_sdk::metrics::Temporality::default()) .build() .unwrap(); let meter_reader = PeriodicReader::builder(meter_exporter) - .with_interval(std::time::Duration::from_secs(30)) + .with_interval(Duration::from_secs(30)) .build(); // For debugging in development - let meter_stdout_reader = PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()).build(); + // let meter_stdout_reader = PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()).build(); // Configure Meter Provider let meter_provider = MeterProviderBuilder::default() - .with_resource(resource) + .with_resource(resource.clone()) .with_reader(meter_reader) - .with_reader(meter_stdout_reader) + // .with_reader(meter_stdout_reader) .build(); // Set global Tracer and Meter providers global::set_tracer_provider(tracer_provider.clone()); global::set_meter_provider(meter_provider.clone()); - let tracer = tracer_provider.tracer("tracing-otel-subscriber-rustfs-service"); + let tracer = tracer_provider.tracer("rustfs-service"); + + // // let _stdout_exporter = opentelemetry_stdout::LogExporter::default(); + // let otlp_exporter = opentelemetry_otlp::LogExporter::builder() + // .with_tonic() + // .with_endpoint("http://localhost:4317") + // // .with_timeout(Duration::from_secs(3)) + // // .with_protocol(opentelemetry_otlp::Protocol::Grpc) + // .build() + // .unwrap(); + // let provider: SdkLoggerProvider = SdkLoggerProvider::builder() + // .with_resource(resource.clone()) + // .with_simple_exporter(otlp_exporter) + // .build(); + // let filter_otel = EnvFilter::new("debug") + // // .add_directive("hyper=off".parse().unwrap()) + // // .add_directive("opentelemetry=off".parse().unwrap()) + // // .add_directive("tonic=off".parse().unwrap()) + // // .add_directive("h2=off".parse().unwrap()) + // .add_directive("reqwest=off".parse().unwrap()); + // let otel_layer = layer::OpenTelemetryTracingBridge::new(&provider).with_filter(filter_otel); + let filter_fmt = EnvFilter::new("info").add_directive("opentelemetry=debug".parse().unwrap()); + let fmt_layer = tracing_subscriber::fmt::layer() + .with_thread_names(true) + .with_filter(filter_fmt); // Configure `tracing subscriber` tracing_subscriber::registry() @@ -92,8 +126,10 @@ impl Telemetry { .with(tracing_subscriber::fmt::layer().with_ansi(true)) .with(MetricsLayer::new(meter_provider.clone())) .with(OpenTelemetryLayer::new(tracer)) + // .with(otel_layer) + .with(fmt_layer) .init(); - + info!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", message = "This is an example message"); Self { tracer_provider, meter_provider, From bcab86fc388adce01b1f7cd84fa728ee66c72e6c Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 9 Mar 2025 10:47:03 +0800 Subject: [PATCH 005/103] rename `rustfs-logging` to `rustfs-obs` --- Cargo.lock | 172 +++++++++++++++++++-- Cargo.toml | 4 +- packages/{logging => obs}/Cargo.toml | 2 +- packages/{logging => obs}/src/audit.rs | 22 +-- packages/{logging => obs}/src/lib.rs | 4 +- packages/{logging => obs}/src/logger.rs | 6 +- packages/{logging => obs}/src/telemetry.rs | 2 +- rustfs/Cargo.toml | 1 + 8 files changed, 181 insertions(+), 32 deletions(-) rename packages/{logging => obs}/Cargo.toml (98%) rename packages/{logging => obs}/src/audit.rs (93%) rename packages/{logging => obs}/src/lib.rs (98%) rename packages/{logging => obs}/src/logger.rs (86%) rename packages/{logging => obs}/src/telemetry.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index a99f98d83..fb04b7c42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1377,7 +1377,7 @@ dependencies = [ "futures-util", "generational-box", "longest-increasing-subsequence", - "rustc-hash", + "rustc-hash 1.1.0", "rustversion", "serde", "slab", @@ -1443,7 +1443,7 @@ dependencies = [ "objc_id", "once_cell", "rfd 0.14.1", - "rustc-hash", + "rustc-hash 1.1.0", "serde", "serde_json", "signal-hook", @@ -1604,7 +1604,7 @@ dependencies = [ "dioxus-html", "js-sys", "lazy-js-bundle", - "rustc-hash", + "rustc-hash 1.1.0", "serde", "sledgehammer_bindgen", "sledgehammer_utils", @@ -1710,7 +1710,7 @@ dependencies = [ "generational-box", "once_cell", "parking_lot 0.12.3", - "rustc-hash", + "rustc-hash 1.1.0", "tracing", "warnings", ] @@ -1737,7 +1737,7 @@ dependencies = [ "generational-box", "js-sys", "lazy-js-bundle", - "rustc-hash", + "rustc-hash 1.1.0", "serde", "serde-wasm-bindgen", "serde_json", @@ -1971,6 +1971,15 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + [[package]] name = "endi" version = "1.1.0" @@ -2881,6 +2890,24 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + [[package]] name = "hyper-timeout" version = "0.5.2" @@ -4912,6 +4939,58 @@ dependencies = [ "serde", ] +[[package]] +name = "quinn" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash 2.1.1", + "rustls", + "socket2", + "thiserror 2.0.11", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" +dependencies = [ + "bytes", + "getrandom 0.2.15", + "rand 0.8.5", + "ring", + "rustc-hash 2.1.1", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.11", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46f3055866785f6b92bc6164b76be02ca8f2eb4b002c0354b28cf4c119e5944" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.38" @@ -5197,19 +5276,16 @@ checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ "base64", "bytes", -<<<<<<< HEAD "encoding_rs", "futures-channel", -||||||| e65bee0 - "encoding_rs", -======= ->>>>>>> 1d58a07f296b9dedba832bb31b31eb9faf38b85c "futures-core", "futures-util", + "h2", "http", "http-body", "http-body-util", "hyper", + "hyper-rustls", "hyper-util", "ipnet", "js-sys", @@ -5219,11 +5295,17 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", + "rustls", + "rustls-pemfile", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", + "system-configuration", "tokio", + "tokio-rustls", "tokio-util", "tower 0.5.2", "tower-service", @@ -5232,6 +5314,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", + "webpki-roots", "windows-registry", ] @@ -5365,6 +5448,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + [[package]] name = "rustc_version" version = "0.4.1" @@ -5416,6 +5505,7 @@ dependencies = [ "protos", "rmp-serde", "rust-embed", + "rustfs-obs", "s3s", "serde", "serde_json", @@ -5460,7 +5550,7 @@ dependencies = [ ] [[package]] -name = "rustfs-logging" +name = "rustfs-obs" version = "0.0.1" dependencies = [ "chrono", @@ -5522,6 +5612,9 @@ name = "rustls-pki-types" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -6024,7 +6117,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "debdd4b83524961983cea3c55383b3910fd2f24fd13a188f5b091d2d504a61ae" dependencies = [ - "rustc-hash", + "rustc-hash 1.1.0", ] [[package]] @@ -6208,6 +6301,27 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.9.0", + "core-foundation 0.9.4", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -6435,6 +6549,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.43.0" @@ -7227,6 +7356,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webbrowser" version = "0.8.15" @@ -7288,6 +7427,15 @@ dependencies = [ "system-deps", ] +[[package]] +name = "webpki-roots" +version = "0.26.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webview2-com" version = "0.33.0" diff --git a/Cargo.toml b/Cargo.toml index 6915a975a..70e5e3888 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ "iam", # Identity and Access Management "crypto", # Cryptography and security features "cli/rustfs-gui", # Graphical user interface client - "packages/logging", # Logging utilities + "packages/obs", # Observability utilities ] resolver = "2" @@ -81,7 +81,7 @@ rdkafka = { version = "0.37", features = ["tokio"] } rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } rmp = "0.8.14" rmp-serde = "1.3.0" -rustfs-logging = { path = "packages/logging", version = "0.0.1" } +rustfs-obs = { path = "packages/obs", version = "0.0.1" } rust-embed = "8.6.0" s3s = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779", default-features = true, features = [ "tower", diff --git a/packages/logging/Cargo.toml b/packages/obs/Cargo.toml similarity index 98% rename from packages/logging/Cargo.toml rename to packages/obs/Cargo.toml index 73c7c3f97..0e5b3407f 100644 --- a/packages/logging/Cargo.toml +++ b/packages/obs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rustfs-logging" +name = "rustfs-obs" edition.workspace = true license.workspace = true repository.workspace = true diff --git a/packages/logging/src/audit.rs b/packages/obs/src/audit.rs similarity index 93% rename from packages/logging/src/audit.rs rename to packages/obs/src/audit.rs index a8c5d5a24..b353d83fb 100644 --- a/packages/logging/src/audit.rs +++ b/packages/obs/src/audit.rs @@ -23,7 +23,7 @@ use tokio::sync::mpsc; /// * `span_id` - The span ID of the event /// # Example /// ``` -/// use rustfs_logging::AuditEntry; +/// use rustfs_obs::AuditEntry; /// let entry = AuditEntry { /// version: "1.0".to_string(), /// event_type: "read".to_string(), @@ -63,7 +63,7 @@ impl AuditTarget for FileAuditTarget { /// /// # Example /// ``` - /// use rustfs_logging::{AuditEntry, AuditTarget, FileAuditTarget}; + /// use rustfs_obs::{AuditEntry, AuditTarget, FileAuditTarget}; /// let entry = AuditEntry { /// version: "1.0".to_string(), /// event_type: "read".to_string(), @@ -88,7 +88,7 @@ impl AuditTarget for FileAuditTarget { /// * `url` - The URL of the webhook /// # Example /// ``` -/// use rustfs_logging::WebhookAuditTarget; +/// use rustfs_obs::WebhookAuditTarget; /// let target = WebhookAuditTarget::new("http://localhost:8080"); /// ``` pub struct WebhookAuditTarget { @@ -126,7 +126,7 @@ impl AuditTarget for WebhookAuditTarget { /// * `topic` - The Kafka topic /// # Example /// ``` -/// use rustfs_logging::KafkaAuditTarget; +/// use rustfs_obs::KafkaAuditTarget; /// let target = KafkaAuditTarget::new("localhost:9092", "rustfs-audit"); /// ``` /// # Note @@ -135,7 +135,7 @@ impl AuditTarget for WebhookAuditTarget { /// ```toml /// [dependencies] /// rdkafka = "0.26.0" -/// rustfs_logging = { version = "0.1.0", features = ["audit-kafka"] } +/// rustfs_obs = { version = "0.1.0", features = ["audit-kafka"] } /// ``` /// # Note /// The `rdkafka` crate requires the `librdkafka` library to be installed @@ -214,7 +214,7 @@ impl AuditTarget for KafkaAuditTarget { /// /// # Example /// ``` -/// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget}; +/// use rustfs_obs::{AuditEntry, AuditLogger, FileAuditTarget}; /// /// #[tokio::main] /// async fn main() { @@ -238,7 +238,7 @@ impl AuditTarget for KafkaAuditTarget { /// to multiple targets /// # Example /// ``` -/// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget}; +/// use rustfs_obs::{AuditEntry, AuditLogger, FileAuditTarget}; /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); /// ``` /// # Note @@ -247,7 +247,7 @@ impl AuditTarget for KafkaAuditTarget { /// ```toml /// [dependencies] /// tokio = { version = "1", features = ["full"] } -/// rustfs_logging = { version = "0.1.0"} +/// rustfs_obs = { version = "0.1.0"} /// ``` /// # Note /// This feature requires the `serde` crate @@ -255,7 +255,7 @@ impl AuditTarget for KafkaAuditTarget { /// ```toml /// [dependencies] /// serde = { version = "1", features = ["derive"] } -/// rustfs_logging = { version = "0.1.0"} +/// rustfs_obs = { version = "0.1.0"} /// ``` pub struct AuditLogger { tx: mpsc::Sender, @@ -270,7 +270,7 @@ impl AuditLogger { /// * An AuditLogger /// # Example /// ``` - /// use rustfs_logging::{AuditLogger, AuditEntry, FileAuditTarget}; + /// use rustfs_obs::{AuditLogger, AuditEntry, FileAuditTarget}; /// /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); /// ``` @@ -291,7 +291,7 @@ impl AuditLogger { /// * `entry` - The audit entry to log /// # Example /// ``` - /// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget}; + /// use rustfs_obs::{AuditEntry, AuditLogger, FileAuditTarget}; /// /// #[tokio::main] /// async fn main() { diff --git a/packages/logging/src/lib.rs b/packages/obs/src/lib.rs similarity index 98% rename from packages/logging/src/lib.rs rename to packages/obs/src/lib.rs index 70e1eb2a5..caf993220 100644 --- a/packages/logging/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -5,7 +5,7 @@ /// /// # Examples /// ``` -/// use rustfs_logging::{log_info, log_error}; +/// use rustfs_obs::{log_info, log_error}; /// /// log_info("This is an informational message"); /// log_error("This is an error message"); @@ -24,7 +24,7 @@ mod telemetry; #[cfg(test)] mod tests { - use super::*; + use crate::{log_info, AuditEntry, AuditLogger, AuditTarget, FileAuditTarget, Telemetry}; use chrono::Utc; use opentelemetry::global; use opentelemetry::trace::{TraceContextExt, Tracer}; diff --git a/packages/logging/src/logger.rs b/packages/obs/src/logger.rs similarity index 86% rename from packages/logging/src/logger.rs rename to packages/obs/src/logger.rs index 67c8e630c..023419592 100644 --- a/packages/logging/src/logger.rs +++ b/packages/obs/src/logger.rs @@ -7,7 +7,7 @@ use tracing::{debug, error, info}; /// /// # Example /// ``` -/// use rustfs_logging::log_info; +/// use rustfs_obs::log_info; /// /// log_info("This is an info message"); /// ``` @@ -22,7 +22,7 @@ pub fn log_info(msg: &str) { /// /// # Example /// ``` -/// use rustfs_logging::log_error; +/// use rustfs_obs::log_error; /// /// log_error("This is an error message"); /// ``` @@ -37,7 +37,7 @@ pub fn log_error(msg: &str) { /// /// # Example /// ``` -/// use rustfs_logging::log_debug; +/// use rustfs_obs::log_debug; /// /// log_debug("This is a debug message"); /// ``` diff --git a/packages/logging/src/telemetry.rs b/packages/obs/src/telemetry.rs similarity index 99% rename from packages/logging/src/telemetry.rs rename to packages/obs/src/telemetry.rs index edd362cd9..0eed5466d 100644 --- a/packages/logging/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -25,7 +25,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilte /// /// # Example /// ``` -/// use rustfs_logging::Telemetry; +/// use rustfs_obs::Telemetry; /// /// let _telemetry = Telemetry::init(); /// ``` diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index e27c59575..b156e2c96 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -76,6 +76,7 @@ mime_guess = "2.0.5" rust-embed = { workspace = true, features = ["interpolate-folder-path"] } local-ip-address = { workspace = true } chrono = { workspace = true } +rustfs-obs = { workspace = true } [build-dependencies] prost-build.workspace = true From eaa506add5163a351cd6d6066dc7a0ec8670a7e6 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 12 Mar 2025 00:46:01 +0800 Subject: [PATCH 006/103] improve code for observability --- Cargo.lock | 276 +++++++++++++++--- Cargo.toml | 12 +- packages/obs/Cargo.toml | 18 +- packages/obs/examples/config.toml | 31 ++ packages/obs/examples/server.rs | 78 ++++++ packages/obs/src/audit.rs | 319 --------------------- packages/obs/src/config.rs | 90 ++++++ packages/obs/src/entry.rs | 80 ++++++ packages/obs/src/lib.rs | 210 ++------------ packages/obs/src/logger.rs | 272 +++++++++++++++--- packages/obs/src/sink.rs | 450 ++++++++++++++++++++++++++++++ packages/obs/src/telemetry.rs | 279 +++++++++++------- packages/obs/src/utils.rs | 42 +++ packages/obs/src/worker.rs | 13 + 14 files changed, 1480 insertions(+), 690 deletions(-) create mode 100644 packages/obs/examples/config.toml create mode 100644 packages/obs/examples/server.rs delete mode 100644 packages/obs/src/audit.rs create mode 100644 packages/obs/src/config.rs create mode 100644 packages/obs/src/entry.rs create mode 100644 packages/obs/src/sink.rs create mode 100644 packages/obs/src/utils.rs create mode 100644 packages/obs/src/worker.rs diff --git a/Cargo.lock b/Cargo.lock index fb04b7c42..ca81fe744 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,6 +176,12 @@ dependencies = [ "password-hash", ] +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + [[package]] name = "arrayvec" version = "0.7.6" @@ -352,9 +358,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.86" +version = "0.1.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644dd749086bf3771a2fbc5f256fdb982d53f011c7d5d560304eafeecebce79d" +checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97" dependencies = [ "proc-macro2", "quote", @@ -486,6 +492,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" @@ -907,6 +919,25 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "config" +version = "0.15.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb07d21d12f9f0bc5e7c3e97ccc78b2341b9b4a4604eac3ed7c1d0d6e2c3b23e" +dependencies = [ + "async-trait", + "convert_case 0.6.0", + "json5", + "pathdiff", + "ron", + "rust-ini", + "serde", + "serde_json", + "toml", + "winnow 0.7.3", + "yaml-rust2", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -923,6 +954,26 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cb3c4a0d3776f7535c32793be81d6d5fec0d48ac70955d9834e643aa249a52f" +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "tiny-keccak", +] + [[package]] name = "const-serialize" version = "0.6.2" @@ -1135,7 +1186,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "test-case", - "thiserror 2.0.11", + "thiserror 2.0.12", "time", ] @@ -1415,7 +1466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b0cca3e7a10a4a3df37ea52c4cc7a53e5c9233489e03ee3f2829471fc3099a" dependencies = [ "async-trait", - "base64", + "base64 0.22.1", "cocoa 0.25.0", "core-foundation 0.9.4", "dioxus-cli-config", @@ -1509,7 +1560,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe99b48a1348eec385b5c4bd3e80fd863b0d3b47257d34e2ddc58754dec5d128" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "ciborium", "dioxus-desktop", @@ -1850,6 +1901,15 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1948,7 +2008,7 @@ dependencies = [ "sha2 0.11.0-pre.4", "siphasher 1.0.1", "tempfile", - "thiserror 2.0.11", + "thiserror 2.0.12", "time", "tokio", "tokio-stream", @@ -2132,6 +2192,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "foreign-types" version = "0.5.0" @@ -2720,6 +2786,18 @@ name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.2", +] [[package]] name = "heck" @@ -2962,7 +3040,7 @@ dependencies = [ "serde_json", "strum", "test-case", - "thiserror 2.0.11", + "thiserror 2.0.12", "time", "tokio", "tracing", @@ -3287,13 +3365,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json5" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" +dependencies = [ + "pest", + "pest_derive", + "serde", +] + [[package]] name = "jsonwebtoken" version = "9.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" dependencies = [ - "base64", + "base64 0.22.1", "js-sys", "pem", "ring", @@ -4218,7 +4307,7 @@ dependencies = [ "futures-sink", "js-sys", "pin-project-lite", - "thiserror 2.0.11", + "thiserror 2.0.12", "tracing", ] @@ -4265,7 +4354,7 @@ dependencies = [ "opentelemetry_sdk", "prost", "reqwest", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tonic", "tracing", @@ -4301,7 +4390,7 @@ dependencies = [ "opentelemetry", "opentelemetry_sdk", "serde", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -4319,7 +4408,7 @@ dependencies = [ "percent-encoding", "rand 0.8.5", "serde_json", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tokio-stream", "tracing", @@ -4331,6 +4420,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-multimap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" +dependencies = [ + "dlv-list", + "hashbrown 0.14.5", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -4473,6 +4572,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "pbkdf2" version = "0.12.2" @@ -4489,7 +4594,7 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" dependencies = [ - "base64", + "base64 0.22.1", "serde", ] @@ -4499,6 +4604,51 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +dependencies = [ + "memchr", + "thiserror 2.0.12", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "pest_meta" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" +dependencies = [ + "once_cell", + "pest", + "sha2 0.10.8", +] + [[package]] name = "petgraph" version = "0.7.1" @@ -4952,7 +5102,7 @@ dependencies = [ "rustc-hash 2.1.1", "rustls", "socket2", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tracing", ] @@ -4971,7 +5121,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.11", + "thiserror 2.0.12", "tinyvec", "tracing", "web-time", @@ -4988,7 +5138,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5164,7 +5314,7 @@ dependencies = [ "pin-project-lite", "s3s", "sha2 0.11.0-pre.4", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", "tracing", ] @@ -5206,7 +5356,7 @@ checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ "getrandom 0.2.15", "libredox", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -5274,7 +5424,7 @@ version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "encoding_rs", "futures-channel", @@ -5401,6 +5551,18 @@ dependencies = [ "serde", ] +[[package]] +name = "ron" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" +dependencies = [ + "base64 0.21.7", + "bitflags 2.9.0", + "serde", + "serde_derive", +] + [[package]] name = "rust-embed" version = "8.6.0" @@ -5436,6 +5598,17 @@ dependencies = [ "walkdir", ] +[[package]] +name = "rust-ini" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e310ef0e1b6eeb79169a1171daf9abcb87a2e17c03bee2c4bb100b55c75409f" +dependencies = [ + "cfg-if", + "ordered-multimap", + "trim-in-place", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -5553,7 +5726,10 @@ dependencies = [ name = "rustfs-obs" version = "0.0.1" dependencies = [ + "async-trait", "chrono", + "config", + "local-ip-address", "opentelemetry", "opentelemetry-appender-tracing", "opentelemetry-otlp", @@ -5564,8 +5740,10 @@ dependencies = [ "reqwest", "serde", "serde_json", + "thiserror 2.0.12", "tokio", "tracing", + "tracing-core", "tracing-opentelemetry", "tracing-subscriber", ] @@ -5676,7 +5854,7 @@ dependencies = [ "smallvec", "std-next", "sync_wrapper", - "thiserror 2.0.11", + "thiserror 2.0.12", "time", "tokio", "tower 0.5.2", @@ -5694,7 +5872,7 @@ dependencies = [ "indexmap 2.7.1", "serde", "serde_json", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -6066,7 +6244,7 @@ checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" dependencies = [ "num-bigint", "num-traits", - "thiserror 2.0.11", + "thiserror 2.0.12", "time", ] @@ -6197,7 +6375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bafdb55260d9b29c04fa52351e0db2a4aaeadc462cd884ccd7771c5a31aaf1aa" dependencies = [ "simdutf8", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -6467,11 +6645,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -6487,9 +6665,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -6539,6 +6717,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -6566,9 +6753,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a" dependencies = [ "backtrace", "bytes", @@ -6694,7 +6881,7 @@ dependencies = [ "async-stream", "async-trait", "axum", - "base64", + "base64 0.22.1", "bytes", "flate2", "h2", @@ -6960,10 +7147,16 @@ dependencies = [ "objc2-foundation 0.3.0", "once_cell", "png", - "thiserror 2.0.11", + "thiserror 2.0.12", "windows-sys 0.59.0", ] +[[package]] +name = "trim-in-place" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343e926fc669bc8cde4fa3129ab681c63671bae288b1f1081ceee6d9d37904fc" + [[package]] name = "try-lock" version = "0.2.5" @@ -6994,6 +7187,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "uds_windows" version = "1.1.0" @@ -7870,7 +8069,7 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac0099a336829fbf54c26b5f620c68980ebbe37196772aeaf6118df4931b5cb0" dependencies = [ - "base64", + "base64 0.22.1", "block", "cocoa 0.26.0", "core-graphics 0.24.0", @@ -7941,6 +8140,17 @@ version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" +[[package]] +name = "yaml-rust2" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "232bdb534d65520716bef0bbb205ff8f2db72d807b19c0bc3020853b92a0cd4b" +dependencies = [ + "arraydeque", + "encoding_rs", + "hashlink", +] + [[package]] name = "yoke" version = "0.7.5" diff --git a/Cargo.toml b/Cargo.toml index 70e5e3888..fff723ded 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,12 +32,13 @@ all = "warn" [workspace.dependencies] madmin = { path = "./madmin" } -async-trait = "0.1.86" +async-trait = "0.1.87" backon = "1.3.0" bytes = "1.9.0" bytesize = "1.3.0" chrono = { version = "0.4.40", features = ["serde"] } clap = { version = "4.5.31", features = ["derive", "env"] } +config = "0.15.9" dioxus = { version = "0.6.3", features = ["router"] } dirs = "6.0.0" ecstore = { path = "./ecstore" } @@ -63,7 +64,7 @@ local-ip-address = "0.6.3" mime = "0.3.17" netif = "0.1.6" opentelemetry = { version = "0.28" } -opentelemetry-appender-tracing = { version = "0.28.1" } +opentelemetry-appender-tracing = { version = "0.28.1", features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { version = "0.28" } opentelemetry-stdout = { version = "0.28.0" } opentelemetry-otlp = { version = "0.28" } @@ -76,7 +77,7 @@ prost-types = "0.13.4" protobuf = "3.7" protos = { path = "./common/protos" } rand = "0.8.5" -reqwest = { version = "0.12.12", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream"] } +reqwest = { version = "0.12.12", default-features = false, features = ["json", "rustls-tls", "charset", "http2", "macos-system-configuration", "stream"] } rdkafka = { version = "0.37", features = ["tokio"] } rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } rmp = "0.8.14" @@ -92,7 +93,7 @@ serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.138" sha2 = "0.10.8" tempfile = "3.16.0" -thiserror = "2.0.11" +thiserror = "2.0.12" time = { version = "0.3.37", features = [ "std", "parsing", @@ -100,13 +101,14 @@ time = { version = "0.3.37", features = [ "macros", "serde", ] } -tokio = { version = "1.43.0", features = ["fs", "rt-multi-thread"] } +tokio = { version = "1.44.0", features = ["fs", "rt-multi-thread"] } tonic = { version = "0.12.3", features = ["gzip"] } tonic-build = "0.12.3" tonic-reflection = "0.12" tokio-stream = "0.1.17" tower = { version = "0.5.2", features = ["timeout"] } tracing = "0.1.41" +tracing-core = "0.1.33" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "time"] } tracing-appender = "0.2.3" diff --git a/packages/obs/Cargo.toml b/packages/obs/Cargo.toml index 0e5b3407f..8753d63c7 100644 --- a/packages/obs/Cargo.toml +++ b/packages/obs/Cargo.toml @@ -10,11 +10,15 @@ version.workspace = true workspace = true [features] -default = [] -audit-kafka = ["dep:rdkafka", "dep:serde_json"] -audit-webhook = ["dep:reqwest"] +default = ["file"] +kafka = ["dep:rdkafka", "dep:serde_json"] +webhook = ["dep:reqwest"] +file = [] [dependencies] +async-trait = { workspace = true } +chrono = { workspace = true } +config = { workspace = true } opentelemetry = { workspace = true } opentelemetry-appender-tracing = { workspace = true, features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } @@ -23,13 +27,15 @@ opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "metrics"] } opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] } serde = { workspace = true } tracing = { workspace = true } +tracing-core = { workspace = true } tracing-opentelemetry = { workspace = true } tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } -tokio = { workspace = true, features = ["full"] } +tokio = { workspace = true, features = ["sync", "fs"] } rdkafka = { workspace = true, features = ["tokio"], optional = true } -reqwest = { workspace = true, features = ["json"], optional = true } +reqwest = { workspace = true, optional = true, default-features = false } serde_json = { workspace = true, optional = true } - +thiserror = { workspace = true } +local-ip-address = { workspace = true } [dev-dependencies] diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml new file mode 100644 index 000000000..9c3c68a26 --- /dev/null +++ b/packages/obs/examples/config.toml @@ -0,0 +1,31 @@ +[observability] +endpoint = "http://localhost:4317" +use_stdout = true +sample_ratio = 0.5 +meter_interval = 30 +service_name = "logging_service" +service_version = "0.1.0" +deployment_environment = "develop" + +[sinks] +[sinks.kafka] +enabled = false +bootstrap_servers = "localhost:9092" +topic = "logs" +batch_size = 100 # Default is 100 if not specified +batch_timeout_ms = 1000 # Default is 1000ms if not specified + +[sinks.webhook] +enabled = false +url = "http://localhost:8080/webhook" +batch_size = 100 # Default is 3 if not specified +batch_timeout_ms = 1000 # Default is 100ms if not specified + +[sinks.file] +enabled = true +path = "app.log" +batch_size = 100 +batch_timeout_ms = 1000 # Default is 8192 bytes if not specified + +[logger] +queue_capacity = 10000 \ No newline at end of file diff --git a/packages/obs/examples/server.rs b/packages/obs/examples/server.rs new file mode 100644 index 000000000..b2c104dd3 --- /dev/null +++ b/packages/obs/examples/server.rs @@ -0,0 +1,78 @@ +use opentelemetry::global; +use opentelemetry::trace::TraceContextExt; +use rustfs_obs::{init_logging, load_config, LogEntry}; +use std::time::{Duration, SystemTime}; +use tracing::{info, instrument, Span}; +use tracing_core::Level; +use tracing_opentelemetry::OpenTelemetrySpanExt; + +#[tokio::main] +async fn main() { + let start_time = SystemTime::now(); + let config = load_config(Some("packages/obs/examples/config".to_string())); + info!("Configuration file loading is complete {:?}", config.clone()); + let (logger, _guard) = init_logging(config); + info!("Log module initialization is completed"); + // Simulate the operation + tokio::time::sleep(Duration::from_millis(100)).await; + + // Record Metrics + let meter = global::meter("rustfs.rs"); + let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); + request_duration.record( + start_time.elapsed().unwrap().as_secs_f64(), + &[opentelemetry::KeyValue::new("operation", "put_object")], + ); + + // Gets the current span + let span = Span::current(); + // Use 'OpenTelemetrySpanExt' to get 'SpanContext' + let span_context = span.context(); // Get context via OpenTelemetrySpanExt + let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId + let trace_id = span_context.span().span_context().trace_id().to_string(); // Get the TraceId + let result = logger + .log(LogEntry::new( + Level::INFO, + "Process user requests".to_string(), + "api_handler".to_string(), + Some("req-12345".to_string()), + Some("user-6789".to_string()), + vec![ + ("endpoint".to_string(), "/api/v1/data".to_string()), + ("method".to_string(), "GET".to_string()), + ("span_id".to_string(), span_id), + ("trace_id".to_string(), trace_id), + ], + )) + .await; + info!("Logging is completed {:?}", result); + put_object("bucket".to_string(), "object".to_string(), "user".to_string()).await; + info!("Logging is completed"); + tokio::time::sleep(Duration::from_secs(2)).await; + info!("Program ends"); +} + +#[instrument(fields(bucket, object, user))] +async fn put_object(bucket: String, object: String, user: String) { + let start_time = SystemTime::now(); + info!("Starting PUT operation"); + // Gets the current span + let span = Span::current(); + // Use 'OpenTelemetrySpanExt' to get 'SpanContext' + let span_context = span.context(); // Get context via OpenTelemetrySpanExt + let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId + let trace_id = span_context.span().span_context().trace_id().to_string(); // Get the TraceId + info!( + "Starting PUT operation content: bucket = {}, object = {}, user = {},span_id = {},trace_id = {},start_time = {}", + bucket, + object, + user, + span_id, + trace_id, + start_time.elapsed().unwrap().as_secs_f64() + ); + // Simulate the operation + tokio::time::sleep(Duration::from_millis(100)).await; + + info!("PUT operation completed"); +} diff --git a/packages/obs/src/audit.rs b/packages/obs/src/audit.rs deleted file mode 100644 index b353d83fb..000000000 --- a/packages/obs/src/audit.rs +++ /dev/null @@ -1,319 +0,0 @@ -#[cfg(feature = "audit-kafka")] -use rdkafka::{ - producer::{FutureProducer, FutureRecord}, - ClientConfig, -}; - -#[cfg(feature = "audit-webhook")] -use reqwest::Client; - -use serde::{Deserialize, Serialize}; -use tokio::sync::mpsc; - -/// AuditEntry is a struct that represents an audit entry -/// that can be logged -/// # Fields -/// * `version` - The version of the audit entry -/// * `event_type` - The type of event that occurred -/// * `bucket` - The bucket that was accessed -/// * `object` - The object that was accessed -/// * `user` - The user that accessed the object -/// * `time` - The time the event occurred -/// * `user_agent` - The user agent that accessed the object -/// * `span_id` - The span ID of the event -/// # Example -/// ``` -/// use rustfs_obs::AuditEntry; -/// let entry = AuditEntry { -/// version: "1.0".to_string(), -/// event_type: "read".to_string(), -/// bucket: "bucket".to_string(), -/// object: "object".to_string(), -/// user: "user".to_string(), -/// time: "time".to_string(), -/// user_agent: "user_agent".to_string(), -/// span_id: "span_id".to_string(), -/// }; -/// ``` -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct AuditEntry { - pub version: String, - pub event_type: String, - pub bucket: String, - pub object: String, - pub user: String, - pub time: String, - pub user_agent: String, - pub span_id: String, -} - -/// AuditTarget is a trait that defines the interface for audit targets -/// that can receive audit entries -pub trait AuditTarget: Send + Sync { - fn send(&self, entry: AuditEntry); -} - -/// FileAuditTarget is an audit target that logs audit entries to a file -pub struct FileAuditTarget; - -impl AuditTarget for FileAuditTarget { - /// Send an audit entry to a file - /// # Arguments - /// * `entry` - The audit entry to send - /// - /// # Example - /// ``` - /// use rustfs_obs::{AuditEntry, AuditTarget, FileAuditTarget}; - /// let entry = AuditEntry { - /// version: "1.0".to_string(), - /// event_type: "read".to_string(), - /// bucket: "bucket".to_string(), - /// object: "object".to_string(), - /// user: "user".to_string(), - /// time: "time".to_string(), - /// user_agent: "user_agent".to_string(), - /// span_id: "span_id".to_string(), - /// }; - /// FileAuditTarget.send(entry); - /// ``` - fn send(&self, entry: AuditEntry) { - println!("File audit: {:?}", entry); - } -} - -#[cfg(feature = "audit-webhook")] -/// Webhook audit objectives -/// #Arguments -/// * `client` - The reqwest client -/// * `url` - The URL of the webhook -/// # Example -/// ``` -/// use rustfs_obs::WebhookAuditTarget; -/// let target = WebhookAuditTarget::new("http://localhost:8080"); -/// ``` -pub struct WebhookAuditTarget { - client: Client, - url: String, -} - -#[cfg(feature = "audit-webhook")] -impl WebhookAuditTarget { - pub fn new(url: &str) -> Self { - Self { - client: Client::new(), - url: url.to_string(), - } - } -} - -#[cfg(feature = "audit-webhook")] -impl AuditTarget for WebhookAuditTarget { - fn send(&self, entry: AuditEntry) { - let client = self.client.clone(); - let url = self.url.clone(); - tokio::spawn(async move { - if let Err(e) = client.post(&url).json(&entry).send().await { - eprintln!("Failed to send to Webhook: {:?}", e); - } - }); - } -} - -#[cfg(feature = "audit-kafka")] -/// Kafka audit objectives -/// # Arguments -/// * `producer` - The Kafka producer -/// * `topic` - The Kafka topic -/// # Example -/// ``` -/// use rustfs_obs::KafkaAuditTarget; -/// let target = KafkaAuditTarget::new("localhost:9092", "rustfs-audit"); -/// ``` -/// # Note -/// This feature requires the `rdkafka` crate -/// # Example -/// ```toml -/// [dependencies] -/// rdkafka = "0.26.0" -/// rustfs_obs = { version = "0.1.0", features = ["audit-kafka"] } -/// ``` -/// # Note -/// The `rdkafka` crate requires the `librdkafka` library to be installed -/// # Example -/// ```sh -/// sudo apt-get install librdkafka-dev -/// ``` -/// # Note -/// The `rdkafka` crate requires the `libssl-dev` and `pkg-config` packages to be installed -/// # Example -/// ```sh -/// sudo apt-get install libssl-dev pkg-config -/// ``` -/// # Note -/// The `rdkafka` crate requires the `zlib1g-dev` package to be installed -/// # Example -/// ```sh -/// sudo apt-get install zlib1g-dev -/// ``` -/// # Note -/// The `rdkafka` crate requires the `zstd` package to be installed -/// # Example -/// ```sh -/// sudo apt-get install zstd -/// ``` -/// # Note -/// The `rdkafka` crate requires the `lz4` package to be installed -/// # Example -/// ```sh -/// sudo apt-get install lz4 -/// ``` -pub struct KafkaAuditTarget { - producer: FutureProducer, - topic: String, -} - -#[cfg(feature = "audit-kafka")] -impl KafkaAuditTarget { - pub fn new(brokers: &str, topic: &str) -> Self { - let producer: FutureProducer = ClientConfig::new() - .set("bootstrap.servers", brokers) - .set("message.timeout.ms", "5000") - .create() - .expect("Kafka producer creation failed"); - Self { - producer, - topic: topic.to_string(), - } - } -} - -#[cfg(feature = "audit-kafka")] -impl AuditTarget for KafkaAuditTarget { - fn send(&self, entry: AuditEntry) { - let topic = self.topic.clone(); - let span_id = entry.span_id.clone(); - let payload = serde_json::to_string(&entry).unwrap(); - // let record = FutureRecord::to(&topic).payload(&payload).key(&span_id); - tokio::spawn({ - // 在异步闭包内部创建 record - let topic = topic; - let payload = payload; - let span_id = span_id; - let producer = self.producer.clone(); - async move { - let record = FutureRecord::to(&topic).payload(&payload).key(&span_id); - if let Err(e) = producer.send(record, std::time::Duration::from_secs(0)).await { - eprintln!("Failed to send to Kafka: {:?}", e); - } - } - }); - } -} -/// AuditLogger is a logger that logs audit entries -/// to multiple targets -/// -/// # Example -/// ``` -/// use rustfs_obs::{AuditEntry, AuditLogger, FileAuditTarget}; -/// -/// #[tokio::main] -/// async fn main() { -/// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); -/// let entry = AuditEntry { -/// version: "1.0".to_string(), -/// event_type: "read".to_string(), -/// bucket: "bucket".to_string(), -/// object: "object".to_string(), -/// user: "user".to_string(), -/// time: "time".to_string(), -/// user_agent: "user_agent".to_string(), -/// span_id: "span_id".to_string(), -/// }; -/// logger.log(entry).await; -/// } -/// ``` - -#[derive(Debug)] -/// AuditLogger is a logger that logs audit entries -/// to multiple targets -/// # Example -/// ``` -/// use rustfs_obs::{AuditEntry, AuditLogger, FileAuditTarget}; -/// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); -/// ``` -/// # Note -/// This feature requires the `tokio` crate -/// # Example -/// ```toml -/// [dependencies] -/// tokio = { version = "1", features = ["full"] } -/// rustfs_obs = { version = "0.1.0"} -/// ``` -/// # Note -/// This feature requires the `serde` crate -/// # Example -/// ```toml -/// [dependencies] -/// serde = { version = "1", features = ["derive"] } -/// rustfs_obs = { version = "0.1.0"} -/// ``` -pub struct AuditLogger { - tx: mpsc::Sender, -} - -impl AuditLogger { - /// Create a new AuditLogger with the given targets - /// that will receive audit entries - /// # Arguments - /// * `targets` - A vector of audit targets - /// # Returns - /// * An AuditLogger - /// # Example - /// ``` - /// use rustfs_obs::{AuditLogger, AuditEntry, FileAuditTarget}; - /// - /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); - /// ``` - pub fn new(targets: Vec>) -> Self { - let (tx, mut rx) = mpsc::channel::(1000); - tokio::spawn(async move { - while let Some(entry) = rx.recv().await { - for target in &targets { - target.send(entry.clone()); - } - } - }); - Self { tx } - } - - /// Log an audit entry - /// # Arguments - /// * `entry` - The audit entry to log - /// # Example - /// ``` - /// use rustfs_obs::{AuditEntry, AuditLogger, FileAuditTarget}; - /// - /// #[tokio::main] - /// async fn main() { - /// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]); - /// let entry = AuditEntry { - /// version: "1.0".to_string(), - /// event_type: "read".to_string(), - /// bucket: "bucket".to_string(), - /// object: "object".to_string(), - /// user: "user".to_string(), - /// time: "time".to_string(), - /// user_agent: "user_agent".to_string(), - /// span_id: "span_id".to_string(), - /// }; - /// logger.log(entry).await; - /// } - /// ``` - pub async fn log(&self, entry: AuditEntry) { - // 将日志消息记录到当前 Span - tracing::Span::current() - .record("log_message", &entry.bucket) - .record("source", &entry.event_type); - let _ = self.tx.send(entry).await; - } -} diff --git a/packages/obs/src/config.rs b/packages/obs/src/config.rs new file mode 100644 index 000000000..8b14f7d0d --- /dev/null +++ b/packages/obs/src/config.rs @@ -0,0 +1,90 @@ +use config::{Config, File, FileFormat}; +use serde::Deserialize; +use std::env; + +/// OpenTelemetry Configuration +#[derive(Debug, Deserialize, Clone, Default)] +pub struct OtelConfig { + pub endpoint: String, + pub use_stdout: bool, + pub sample_ratio: f64, + pub meter_interval: u64, + pub service_name: String, + pub service_version: String, + pub deployment_environment: String, +} + +/// Kafka Sink Configuration - Add batch parameters +#[derive(Debug, Deserialize, Clone)] +pub struct KafkaSinkConfig { + pub enabled: bool, + pub bootstrap_servers: String, + pub topic: String, + pub batch_size: Option, // Batch size, default 100 + pub batch_timeout_ms: Option, // Batch timeout time, default 1000ms +} + +/// Webhook Sink Configuration - Add Retry Parameters +#[derive(Debug, Deserialize, Clone)] +pub struct WebhookSinkConfig { + pub enabled: bool, + pub url: String, + pub max_retries: Option, // Maximum number of retry times, default 3 + pub retry_delay_ms: Option, // Retry the delay cardinality, default 100ms +} + +/// File Sink Configuration - Add buffering parameters +#[derive(Debug, Deserialize, Clone)] +pub struct FileSinkConfig { + pub enabled: bool, + pub path: String, + pub buffer_size: Option, // Write buffer size, default 8192 + pub flush_interval_ms: Option, // Refresh interval time, default 1000ms + pub flush_threshold: Option, // Refresh threshold, default 100 logs +} + +/// Sink configuration collection +#[derive(Debug, Deserialize, Clone)] +pub struct SinkConfig { + pub kafka: KafkaSinkConfig, + pub webhook: WebhookSinkConfig, + pub file: FileSinkConfig, +} + +///Logger Configuration +#[derive(Debug, Deserialize, Clone)] +pub struct LoggerConfig { + pub queue_capacity: Option, +} + +/// Overall application configuration +#[derive(Debug, Deserialize, Clone)] +pub struct AppConfig { + pub observability: OtelConfig, + pub sinks: SinkConfig, + pub logger: LoggerConfig, +} + +/// Loading the configuration file +/// Supports TOML, YAML and .env formats, read in order by priority +pub fn load_config(config_dir: Option) -> AppConfig { + let config_dir = config_dir.unwrap_or_else(|| { + env::current_dir() + .map(|path| path.to_string_lossy().to_string()) + .unwrap_or_else(|_| { + eprintln!("Warning: Failed to get current directory, using empty path"); + String::new() + }) + }); + + println!("config_dir: {}", config_dir); + + let config = Config::builder() + .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Toml)) + .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Yaml).required(false)) + .add_source(config::Environment::with_prefix("")) + .build() + .unwrap(); + + config.try_deserialize().unwrap() +} diff --git a/packages/obs/src/entry.rs b/packages/obs/src/entry.rs new file mode 100644 index 000000000..a8cef168a --- /dev/null +++ b/packages/obs/src/entry.rs @@ -0,0 +1,80 @@ +use chrono::{DateTime, Utc}; +use serde::de::Error; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use tracing_core::Level; + +/// Wrapper for `tracing_core::Level` to implement `Serialize` and `Deserialize` +#[derive(Debug, Clone)] +pub struct SerializableLevel(pub Level); + +impl From for SerializableLevel { + fn from(level: Level) -> Self { + SerializableLevel(level) + } +} + +impl From for Level { + fn from(serializable_level: SerializableLevel) -> Self { + serializable_level.0 + } +} + +impl Serialize for SerializableLevel { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(self.0.as_str()) + } +} + +impl<'de> Deserialize<'de> for SerializableLevel { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + match s.as_str() { + "TRACE" => Ok(SerializableLevel(Level::TRACE)), + "DEBUG" => Ok(SerializableLevel(Level::DEBUG)), + "INFO" => Ok(SerializableLevel(Level::INFO)), + "WARN" => Ok(SerializableLevel(Level::WARN)), + "ERROR" => Ok(SerializableLevel(Level::ERROR)), + _ => Err(D::Error::custom("unknown log level")), + } + } +} + +/// Server log entry structure +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct LogEntry { + pub timestamp: DateTime, // Log timestamp + pub level: SerializableLevel, // Log Level + pub message: String, // Log messages + pub source: String, // Log source (such as module name) + pub request_id: Option, // Request ID (Common Server Fields) + pub user_id: Option, // User ID (Common Server Fields) + pub fields: Vec<(String, String)>, // Attached fields (key value pairs) +} + +impl LogEntry { + /// Create a new LogEntry + pub fn new( + level: Level, + message: String, + source: String, + request_id: Option, + user_id: Option, + fields: Vec<(String, String)>, + ) -> Self { + LogEntry { + timestamp: Utc::now(), + level: SerializableLevel::from(level), + message, + source, + request_id, + user_id, + fields, + } + } +} diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index caf993220..469547d61 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -1,190 +1,32 @@ -//! Logging utilities - +/// # obs /// -/// This crate provides utilities for logging. -/// -/// # Examples -/// ``` -/// use rustfs_obs::{log_info, log_error}; -/// -/// log_info("This is an informational message"); -/// log_error("This is an error message"); -/// ``` -#[cfg(feature = "audit-kafka")] -pub use audit::KafkaAuditTarget; -#[cfg(feature = "audit-webhook")] -pub use audit::WebhookAuditTarget; -pub use audit::{AuditEntry, AuditLogger, AuditTarget, FileAuditTarget}; -pub use logger::{log_debug, log_error, log_info}; -pub use telemetry::Telemetry; - -mod audit; +/// `obs` is a logging and observability library for Rust. +/// It provides a simple and easy-to-use interface for logging and observability. +/// It is built on top of the `log` crate and `opentelemetry` crate. +mod config; +mod entry; mod logger; +mod sink; mod telemetry; +mod utils; +mod worker; -#[cfg(test)] -mod tests { - use crate::{log_info, AuditEntry, AuditLogger, AuditTarget, FileAuditTarget, Telemetry}; - use chrono::Utc; - use opentelemetry::global; - use opentelemetry::trace::{TraceContextExt, Tracer}; - use std::time::{Duration, SystemTime}; - use tracing::{instrument, Span}; - use tracing_opentelemetry::OpenTelemetrySpanExt; +pub use config::load_config; +pub use config::{AppConfig, OtelConfig}; +pub use entry::{LogEntry, SerializableLevel}; +pub use logger::start_logger; +pub use logger::{LogError, Logger}; +pub use sink::Sink; +pub use telemetry::init_telemetry; +pub use utils::{get_local_ip, get_local_ip_with_default}; +pub use worker::start_worker; - #[instrument(fields(bucket, object, user))] - async fn put_object(audit_logger: &AuditLogger, bucket: String, object: String, user: String) { - let start_time = SystemTime::now(); - log_info("Starting PUT operation"); - - // Simulate the operation - tokio::time::sleep(Duration::from_millis(100)).await; - - // Record Metrics - let meter = global::meter("rustfs.rs"); - let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); - request_duration.record( - start_time.elapsed().unwrap().as_secs_f64(), - &[opentelemetry::KeyValue::new("operation", "put_object")], - ); - - // Gets the current span - let span = Span::current(); - - // Use 'OpenTelemetrySpanExt' to get 'SpanContext' - let span_context = span.context(); // Get context via OpenTelemetrySpanExt - let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId - - // Audit events are logged - let audit_entry = AuditEntry { - version: "1.0".to_string(), - event_type: "s3_put_object".to_string(), - bucket, - object, - user, - time: Utc::now().to_rfc3339(), - user_agent: "rustfs.rs-client".to_string(), - span_id, - }; - audit_logger.log(audit_entry).await; - - log_info("PUT operation completed"); - } - - #[tokio::test] - // #[cfg(feature = "audit-webhook")] - // #[cfg(feature = "audit-kafka")] - async fn test_main() { - let telemetry = Telemetry::init(); - - // Initialize multiple audit objectives - let audit_targets: Vec> = vec![ - Box::new(FileAuditTarget), - // Box::new(KafkaAuditTarget::new("localhost:9092", "rustfs-audit")), - // Box::new(WebhookAuditTarget::new("http://localhost:8080/audit")), - ]; - let audit_logger = AuditLogger::new(audit_targets); - - // 创建根 Span 并执行操作 - // let tracer = global::tracer("main"); - // tracer.in_span("main_operation", |cx| { - // Span::current().set_parent(cx); - // log_info("Starting test async"); - // tokio::runtime::Runtime::new().unwrap().block_on(async { - log_info("Starting test"); - // Test the PUT operation - put_object(&audit_logger, "my-bucket".to_string(), "my-object.txt".to_string(), "user123".to_string()).await; - tokio::time::sleep(Duration::from_millis(100)).await; - query_object(&audit_logger, "my-bucket".to_string(), "my-object.txt".to_string(), "user123".to_string()).await; - tokio::time::sleep(Duration::from_millis(100)).await; - for i in 0..100 { - put_object( - &audit_logger, - format!("my-bucket-{}", i), - format!("my-object-{}", i), - "user123".to_string(), - ) - .await; - tokio::time::sleep(Duration::from_millis(100)).await; - query_object( - &audit_logger, - format!("my-bucket-{}", i), - format!("my-object-{}", i), - "user123".to_string(), - ) - .await; - tokio::time::sleep(Duration::from_millis(100)).await; - } - - // Wait for the export to complete - tokio::time::sleep(Duration::from_secs(2)).await; - log_info("Test completed"); - // }); - // }); - drop(telemetry); // Make sure to clean up - } - - #[instrument(fields(bucket, object, user))] - async fn query_object(audit_logger: &AuditLogger, bucket: String, object: String, user: String) { - let start_time = SystemTime::now(); - log_info("Starting query operation"); - - // Simulate the operation - tokio::time::sleep(Duration::from_millis(100)).await; - - // Record Metrics - let meter = global::meter("rustfs.rs"); - let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); - request_duration.record( - start_time.elapsed().unwrap().as_secs_f64(), - &[opentelemetry::KeyValue::new("operation", "query_object")], - ); - - // Gets the current span - let span = Span::current(); - // Use 'OpenTelemetrySpanExt' to get 'SpanContext' - let span_context = span.context(); // Get context via OpenTelemetrySpanExt - let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId - query_one(user.clone()); - query_two(user.clone()); - query_three(user.clone()); - // Audit events are logged - let audit_entry = AuditEntry { - version: "1.0".to_string(), - event_type: "s3_query_object".to_string(), - bucket, - object, - user, - time: Utc::now().to_rfc3339(), - user_agent: "rustfs.rs-client".to_string(), - span_id, - }; - audit_logger.log(audit_entry).await; - - log_info("query operation completed"); - } - #[instrument(fields(user))] - fn query_one(user: String) { - // 初始化 OpenTelemetry Tracer - let tracer = global::tracer("query_one"); - tracer.in_span("doing_work", |cx| { - // Traced app logic here... - Span::current().set_parent(cx); - log_info("Doing work..."); - let current_span = Span::current(); - let span_context = current_span.context(); - let trace_id = span_context.clone().span().span_context().trace_id().to_string(); - let span_id = span_context.clone().span().span_context().span_id().to_string(); - log_info(format!("trace_id: {}, span_id: {}", trace_id, span_id).as_str()); - }); - log_info(format!("Starting query_one operation user:{}", user).as_str()); - } - #[instrument(fields(user))] - fn query_two(user: String) { - log_info(format!("Starting query_two operation user:{}", user).as_str()); - } - #[instrument(fields(user))] - fn query_three(user: String) { - log_info(format!("Starting query_three operation user: {}", user).as_str()); - } +/// Log module initialization function +/// +/// Return to Logger and Clean Guard +pub fn init_logging(config: AppConfig) -> (Logger, telemetry::OtelGuard) { + let guard = init_telemetry(&config.observability); + let sinks = sink::create_sinks(&config); + let logger = start_logger(&config, sinks); + (logger, guard) } diff --git a/packages/obs/src/logger.rs b/packages/obs/src/logger.rs index 023419592..f2297c9ef 100644 --- a/packages/obs/src/logger.rs +++ b/packages/obs/src/logger.rs @@ -1,46 +1,238 @@ -use tracing::{debug, error, info}; +use crate::{AppConfig, LogEntry, SerializableLevel, Sink}; +use std::sync::Arc; +use tokio::sync::mpsc::{self, Receiver, Sender}; -/// Log an info message -/// -/// # Arguments -/// msg: &str - The message to log -/// -/// # Example -/// ``` -/// use rustfs_obs::log_info; -/// -/// log_info("This is an info message"); -/// ``` -pub fn log_info(msg: &str) { - info!("{}", msg); +/// Server log processor +pub struct Logger { + sender: Sender, // Log sending channel + queue_capacity: usize, } -/// Log an error message -/// -/// # Arguments -/// msg: &str - The message to log -/// -/// # Example -/// ``` -/// use rustfs_obs::log_error; -/// -/// log_error("This is an error message"); -/// ``` -pub fn log_error(msg: &str) { - error!("{}", msg); +impl Logger { + /// Create a new Logger instance + /// Returns Logger and corresponding Receiver + pub fn new(config: &AppConfig) -> (Self, Receiver) { + // Get queue capacity from configuration, or use default values 10000 + let queue_capacity = config.logger.queue_capacity.unwrap_or(10000); + let (sender, receiver) = mpsc::channel(queue_capacity); + ( + Logger { + sender, + queue_capacity, + }, + receiver, + ) + } + + // Add a method to get queue capacity + pub fn queue_capacity(&self) -> usize { + self.queue_capacity + } + + /// Asynchronous logging of server logs + /// Attach the log to the current Span and generate a separate Tracing Event + #[tracing::instrument(skip(self), fields(log_source = "logger"))] + pub async fn log(&self, entry: LogEntry) -> Result<(), LogError> { + // Log messages to the current Span + tracing::Span::current() + .record("log_message", &entry.message) + .record("source", &entry.source); + + // Record queue utilization (if a certain threshold is exceeded) + let queue_len = self.sender.capacity(); + let utilization = queue_len as f64 / self.queue_capacity as f64; + if utilization > 0.8 { + tracing::warn!("Log queue utilization high: {:.1}%", utilization * 100.0); + } + + // Generate independent Tracing Events with full LogEntry information + // Generate corresponding events according to level + match entry.level { + SerializableLevel(tracing::Level::ERROR) => { + tracing::error!( + target: "server_logs", + timestamp = %entry.timestamp, + message = %entry.message, + source = %entry.source, + request_id = ?entry.request_id, + user_id = ?entry.user_id, + fields = ?entry.fields + ); + } + SerializableLevel(tracing::Level::WARN) => { + tracing::warn!( + target: "server_logs", + timestamp = %entry.timestamp, + message = %entry.message, + source = %entry.source, + request_id = ?entry.request_id, + user_id = ?entry.user_id, + fields = ?entry.fields + ); + } + SerializableLevel(tracing::Level::INFO) => { + tracing::info!( + target: "server_logs", + timestamp = %entry.timestamp, + message = %entry.message, + source = %entry.source, + request_id = ?entry.request_id, + user_id = ?entry.user_id, + fields = ?entry.fields + ); + } + SerializableLevel(tracing::Level::DEBUG) => { + tracing::debug!( + target: "server_logs", + timestamp = %entry.timestamp, + message = %entry.message, + source = %entry.source, + request_id = ?entry.request_id, + user_id = ?entry.user_id, + fields = ?entry.fields + ); + } + SerializableLevel(tracing::Level::TRACE) => { + tracing::trace!( + target: "server_logs", + timestamp = %entry.timestamp, + message = %entry.message, + source = %entry.source, + request_id = ?entry.request_id, + user_id = ?entry.user_id, + fields = ?entry.fields + ); + } + } + + // Send logs to asynchronous queues to improve error handling + match self.sender.try_send(entry) { + Ok(_) => Ok(()), + Err(mpsc::error::TrySendError::Full(entry)) => { + // Processing strategy when queue is full + tracing::warn!("Log queue full, applying backpressure"); + match tokio::time::timeout( + std::time::Duration::from_millis(500), + self.sender.send(entry), + ) + .await + { + Ok(Ok(_)) => Ok(()), + Ok(Err(_)) => Err(LogError::SendFailed("Channel closed")), + Err(_) => Err(LogError::Timeout("Queue backpressure timeout")), + } + } + Err(mpsc::error::TrySendError::Closed(_)) => { + Err(LogError::SendFailed("Logger channel closed")) + } + } + } + + // Add convenient methods to simplify logging + // Fix the info() method, replacing None with an empty vector instead of the Option type + pub async fn info(&self, message: &str, source: &str) -> Result<(), LogError> { + self.log(LogEntry::new( + tracing::Level::INFO, + message.to_string(), + source.to_string(), + None, + None, + Vec::new(), // 使用空向量代替 None + )) + .await + } + + /// Add warn() method + pub async fn error(&self, message: &str, source: &str) -> Result<(), LogError> { + self.log(LogEntry::new( + tracing::Level::ERROR, + message.to_string(), + source.to_string(), + None, + None, + Vec::new(), + )) + .await + } + + /// Add warn() method + pub async fn warn(&self, message: &str, source: &str) -> Result<(), LogError> { + self.log(LogEntry::new( + tracing::Level::WARN, + message.to_string(), + source.to_string(), + None, + None, + Vec::new(), + )) + .await + } + + /// Add debug() method + pub async fn debug(&self, message: &str, source: &str) -> Result<(), LogError> { + self.log(LogEntry::new( + tracing::Level::DEBUG, + message.to_string(), + source.to_string(), + None, + None, + Vec::new(), + )) + .await + } + + /// Add trace() method + pub async fn trace(&self, message: &str, source: &str) -> Result<(), LogError> { + self.log(LogEntry::new( + tracing::Level::TRACE, + message.to_string(), + source.to_string(), + None, + None, + Vec::new(), + )) + .await + } + + // Add extension methods with context information for more flexibility + pub async fn info_with_context( + &self, + message: &str, + source: &str, + request_id: Option, + user_id: Option, + fields: Vec<(String, String)>, + ) -> Result<(), LogError> { + self.log(LogEntry::new( + tracing::Level::INFO, + message.to_string(), + source.to_string(), + request_id, + user_id, + fields, + )) + .await + } + + // Add elegant closing method + pub async fn shutdown(self) -> Result<(), LogError> { + drop(self.sender); //Close the sending end so that the receiver knows that there is no new message + Ok(()) + } } -/// Log a debug message -/// -/// # Arguments -/// msg: &str - The message to log -/// -/// # Example -/// ``` -/// use rustfs_obs::log_debug; -/// -/// log_debug("This is a debug message"); -/// ``` -pub fn log_debug(msg: &str) { - debug!("{}", msg); +// Define custom error type +#[derive(Debug, thiserror::Error)] +pub enum LogError { + #[error("Failed to send log: {0}")] + SendFailed(&'static str), + #[error("Operation timed out: {0}")] + Timeout(&'static str), +} + +/// Start the log module +pub fn start_logger(config: &AppConfig, sinks: Vec>) -> Logger { + let (logger, receiver) = Logger::new(config); + tokio::spawn(crate::worker::start_worker(receiver, sinks)); + logger } diff --git a/packages/obs/src/sink.rs b/packages/obs/src/sink.rs new file mode 100644 index 000000000..37785cfba --- /dev/null +++ b/packages/obs/src/sink.rs @@ -0,0 +1,450 @@ +use crate::{AppConfig, LogEntry}; +use async_trait::async_trait; +use std::sync::Arc; +use tokio::fs::OpenOptions; +use tokio::io; +use tokio::io::AsyncWriteExt; + +/// Sink Trait definition, asynchronously write logs +#[async_trait] +pub trait Sink: Send + Sync { + async fn write(&self, entry: &LogEntry); +} + +#[cfg(feature = "kafka")] +/// Kafka Sink Implementation +pub struct KafkaSink { + producer: rdkafka::producer::FutureProducer, + topic: String, + batch_size: usize, + batch_timeout_ms: u64, + entries: Arc>>, + last_flush: Arc, +} + +#[cfg(feature = "kafka")] +impl KafkaSink { + /// Create a new KafkaSink instance + pub fn new(producer: rdkafka::producer::FutureProducer, topic: String, batch_size: usize, batch_timeout_ms: u64) -> Self { + // Create Arc-wrapped values first + let entries = Arc::new(tokio::sync::Mutex::new(Vec::with_capacity(batch_size))); + let last_flush = Arc::new(std::sync::atomic::AtomicU64::new( + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64, + )); + let sink = KafkaSink { + producer: producer.clone(), + topic: topic.clone(), + batch_size, + batch_timeout_ms, + entries: entries.clone(), + last_flush: last_flush.clone(), + }; + + // Start background flusher + tokio::spawn(Self::periodic_flush(producer, topic, entries, last_flush, batch_timeout_ms)); + + sink + } + + /// Add a getter method to read the batch_timeout_ms field + #[allow(dead_code)] + pub fn batch_timeout(&self) -> u64 { + self.batch_timeout_ms + } + + /// Add a method to dynamically adjust the timeout if needed + #[allow(dead_code)] + pub fn set_batch_timeout(&mut self, new_timeout_ms: u64) { + self.batch_timeout_ms = new_timeout_ms; + } + + async fn periodic_flush( + producer: rdkafka::producer::FutureProducer, + topic: String, + entries: Arc>>, + last_flush: Arc, + timeout_ms: u64, + ) { + loop { + tokio::time::sleep(tokio::time::Duration::from_millis(timeout_ms / 2)).await; + + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64; + + let last = last_flush.load(std::sync::atomic::Ordering::Relaxed); + + if now - last >= timeout_ms { + let mut batch = entries.lock().await; + if !batch.is_empty() { + Self::send_batch(&producer, &topic, batch.drain(..).collect()).await; + last_flush.store(now, std::sync::atomic::Ordering::Relaxed); + } + } + } + } + + async fn send_batch(producer: &rdkafka::producer::FutureProducer, topic: &str, entries: Vec) { + for entry in entries { + let payload = match serde_json::to_string(&entry) { + Ok(p) => p, + Err(e) => { + eprintln!("Failed to serialize log entry: {}", e); + continue; + } + }; + + let span_id = entry.timestamp.to_rfc3339(); + + let _ = producer + .send( + rdkafka::producer::FutureRecord::to(topic).payload(&payload).key(&span_id), + std::time::Duration::from_secs(5), + ) + .await; + } + } +} + +#[cfg(feature = "kafka")] +#[async_trait] +impl Sink for KafkaSink { + async fn write(&self, entry: &LogEntry) { + let mut batch = self.entries.lock().await; + batch.push(entry.clone()); + + let should_flush_by_size = batch.len() >= self.batch_size; + let should_flush_by_time = { + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64; + let last = self.last_flush.load(std::sync::atomic::Ordering::Relaxed); + now - last >= self.batch_timeout_ms + }; + + if should_flush_by_size || should_flush_by_time { + // Existing flush logic + let entries_to_send: Vec = batch.drain(..).collect(); + let producer = self.producer.clone(); + let topic = self.topic.clone(); + + self.last_flush.store( + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64, + std::sync::atomic::Ordering::Relaxed, + ); + + tokio::spawn(async move { + KafkaSink::send_batch(&producer, &topic, entries_to_send).await; + }); + } + } +} + +#[cfg(feature = "kafka")] +impl Drop for KafkaSink { + fn drop(&mut self) { + // Perform any necessary cleanup here + // For example, you might want to flush any remaining entries + let producer = self.producer.clone(); + let topic = self.topic.clone(); + let entries = self.entries.clone(); + let last_flush = self.last_flush.clone(); + + tokio::spawn(async move { + let mut batch = entries.lock().await; + if !batch.is_empty() { + KafkaSink::send_batch(&producer, &topic, batch.drain(..).collect()).await; + last_flush.store( + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64, + std::sync::atomic::Ordering::Relaxed, + ); + } + }); + + eprintln!("Dropping KafkaSink with topic: {}", self.topic); + } +} + +#[cfg(feature = "webhook")] +/// Webhook Sink Implementation +pub struct WebhookSink { + url: String, + client: reqwest::Client, + max_retries: usize, + retry_delay_ms: u64, +} + +#[cfg(feature = "webhook")] +impl WebhookSink { + pub fn new(url: String, max_retries: usize, retry_delay_ms: u64) -> Self { + WebhookSink { + url, + client: reqwest::Client::builder() + .timeout(std::time::Duration::from_secs(10)) + .build() + .unwrap_or_else(|_| reqwest::Client::new()), + max_retries, + retry_delay_ms, + } + } +} + +#[cfg(feature = "webhook")] +#[async_trait] +impl Sink for WebhookSink { + async fn write(&self, entry: &LogEntry) { + let mut retries = 0; + let url = self.url.clone(); + let entry_clone = entry.clone(); + + while retries < self.max_retries { + match self.client.post(&url).json(&entry_clone).send().await { + Ok(response) if response.status().is_success() => { + return; + } + _ => { + retries += 1; + if retries < self.max_retries { + tokio::time::sleep(tokio::time::Duration::from_millis( + self.retry_delay_ms * (1 << retries), // Exponential backoff + )) + .await; + } + } + } + } + + eprintln!("Failed to send log to webhook after {} retries", self.max_retries); + } +} + +#[cfg(feature = "webhook")] +impl Drop for WebhookSink { + fn drop(&mut self) { + // Perform any necessary cleanup here + // For example, you might want to log that the sink is being dropped + eprintln!("Dropping WebhookSink with URL: {}", self.url); + } +} + +#[cfg(feature = "file")] +/// File Sink Implementation +pub struct FileSink { + path: String, + buffer_size: usize, + writer: Arc>>, + entry_count: std::sync::atomic::AtomicUsize, + last_flush: std::sync::atomic::AtomicU64, + flush_interval_ms: u64, // Time between flushes + flush_threshold: usize, // Number of entries before flush +} + +#[cfg(feature = "file")] +impl FileSink { + #[allow(dead_code)] + pub async fn new( + path: String, + buffer_size: usize, + flush_interval_ms: u64, + flush_threshold: usize, + ) -> Result { + let file = OpenOptions::new().append(true).create(true).open(&path).await?; + + let writer = tokio::io::BufWriter::with_capacity(buffer_size, file); + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64; + Ok(FileSink { + path, + buffer_size, + writer: Arc::new(tokio::sync::Mutex::new(writer)), + entry_count: std::sync::atomic::AtomicUsize::new(0), + last_flush: std::sync::atomic::AtomicU64::new(now), + flush_interval_ms, + flush_threshold, + }) + } + + #[allow(dead_code)] + async fn initialize_writer(&mut self) -> io::Result<()> { + let file = tokio::fs::File::create(&self.path).await?; + + // Use buffer_size to create a buffer writer with a specified capacity + let buf_writer = io::BufWriter::with_capacity(self.buffer_size, file); + + // Replace the original writer with the new Mutex + self.writer = Arc::new(tokio::sync::Mutex::new(buf_writer)); + Ok(()) + } + + // Get the current buffer size + #[allow(dead_code)] + pub fn buffer_size(&self) -> usize { + self.buffer_size + } + + // How to dynamically adjust the buffer size + #[allow(dead_code)] + pub async fn set_buffer_size(&mut self, new_size: usize) -> io::Result<()> { + if self.buffer_size != new_size { + self.buffer_size = new_size; + // Reinitialize the writer directly, without checking is_some() + self.initialize_writer().await?; + } + Ok(()) + } + + // Check if flushing is needed based on count or time + fn should_flush(&self) -> bool { + // Check entry count threshold + if self.entry_count.load(std::sync::atomic::Ordering::Relaxed) >= self.flush_threshold { + return true; + } + + // Check time threshold + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64; + + let last = self.last_flush.load(std::sync::atomic::Ordering::Relaxed); + now - last >= self.flush_interval_ms + } +} + +#[cfg(feature = "file")] +#[async_trait] +impl Sink for FileSink { + async fn write(&self, entry: &LogEntry) { + let line = format!("{:?}\n", entry); + let mut writer = self.writer.lock().await; + + if let Err(e) = writer.write_all(line.as_bytes()).await { + eprintln!("Failed to write log to file {}: {}", self.path, e); + return; + } + + // Only flush periodically to improve performance + // Logic to determine when to flush could be added here + // Increment the entry count + self.entry_count.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + + // Check if we should flush + if self.should_flush() { + if let Err(e) = writer.flush().await { + eprintln!("Failed to flush log file {}: {}", self.path, e); + return; + } + + // Reset counters + self.entry_count.store(0, std::sync::atomic::Ordering::Relaxed); + + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64; + + self.last_flush.store(now, std::sync::atomic::Ordering::Relaxed); + } + } +} + +#[cfg(feature = "file")] +impl Drop for FileSink { + fn drop(&mut self) { + let writer = self.writer.clone(); + let path = self.path.clone(); + + tokio::task::spawn_blocking(move || { + let rt = tokio::runtime::Runtime::new().unwrap(); + rt.block_on(async { + let mut writer = writer.lock().await; + if let Err(e) = writer.flush().await { + eprintln!("Failed to flush log file {}: {}", path, e); + } + }); + }); + } +} + +/// Create a list of Sink instances +pub fn create_sinks(config: &AppConfig) -> Vec> { + let mut sinks: Vec> = Vec::new(); + + #[cfg(feature = "kafka")] + if config.sinks.kafka.enabled { + match rdkafka::config::ClientConfig::new() + .set("bootstrap.servers", &config.sinks.kafka.bootstrap_servers) + .set("message.timeout.ms", "5000") + .create() + { + Ok(producer) => { + sinks.push(Arc::new(KafkaSink::new( + producer, + config.sinks.kafka.topic.clone(), + config.sinks.kafka.batch_size.unwrap_or(100), + config.sinks.kafka.batch_timeout_ms.unwrap_or(1000), + ))); + } + Err(e) => eprintln!("Failed to create Kafka producer: {}", e), + } + } + + #[cfg(feature = "webhook")] + if config.sinks.webhook.enabled { + sinks.push(Arc::new(WebhookSink::new( + config.sinks.webhook.url.clone(), + config.sinks.webhook.max_retries.unwrap_or(3), + config.sinks.webhook.retry_delay_ms.unwrap_or(100), + ))); + } + + #[cfg(feature = "file")] + { + let path = if config.sinks.file.enabled { + config.sinks.file.path.clone() + } else { + "default.log".to_string() + }; + + // Use synchronous file operations + let file_result = std::fs::OpenOptions::new().append(true).create(true).open(&path); + + match file_result { + Ok(file) => { + let buffer_size = config.sinks.file.buffer_size.unwrap_or(8192); + let writer = tokio::io::BufWriter::with_capacity(buffer_size, tokio::fs::File::from_std(file)); + + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64; + + sinks.push(Arc::new(FileSink { + path: path.clone(), + buffer_size, + writer: Arc::new(tokio::sync::Mutex::new(writer)), + entry_count: std::sync::atomic::AtomicUsize::new(0), + last_flush: std::sync::atomic::AtomicU64::new(now), + flush_interval_ms: config.sinks.file.flush_interval_ms.unwrap_or(1000), + flush_threshold: config.sinks.file.flush_threshold.unwrap_or(100), + })); + } + Err(e) => eprintln!("Failed to create file sink: {}", e), + } + } + + sinks +} diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index 0eed5466d..fb1111303 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -1,149 +1,222 @@ +use crate::{get_local_ip_with_default, OtelConfig}; use opentelemetry::trace::TracerProvider; use opentelemetry::{global, KeyValue}; use opentelemetry_appender_tracing::layer; -use opentelemetry_otlp::{self, WithExportConfig}; +use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::logs::SdkLoggerProvider; use opentelemetry_sdk::{ metrics::{MeterProviderBuilder, PeriodicReader, SdkMeterProvider}, trace::{RandomIdGenerator, Sampler, SdkTracerProvider}, Resource, }; -use opentelemetry_semantic_conventions::attribute::NETWORK_LOCAL_ADDRESS; use opentelemetry_semantic_conventions::{ - attribute::{DEPLOYMENT_ENVIRONMENT_NAME, SERVICE_NAME, SERVICE_VERSION}, + attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_NAME, SERVICE_VERSION}, SCHEMA_URL, }; -use std::time::Duration; -use tracing::{info, Level}; use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer}; -/// Telemetry is a wrapper around the OpenTelemetry SDK Tracer and Meter providers. -/// It initializes the global Tracer and Meter providers, and sets up the tracing subscriber. -/// The Tracer and Meter providers are shut down when the Telemetry instance is dropped. -/// This is a convenience struct to ensure that the global providers are properly initialized and shut down. +/// A guard object that manages the lifecycle of OpenTelemetry components. +/// +/// This struct holds references to the created OpenTelemetry providers and ensures +/// they are properly shut down when the guard is dropped. It implements the RAII +/// (Resource Acquisition Is Initialization) pattern for managing telemetry resources. +/// +/// When this guard goes out of scope, it will automatically shut down: +/// - The tracer provider (for distributed tracing) +/// - The meter provider (for metrics collection) +/// - The logger provider (for structured logging) /// /// # Example -/// ``` -/// use rustfs_obs::Telemetry; /// -/// let _telemetry = Telemetry::init(); /// ``` -pub struct Telemetry { +/// use rustfs_obs::{init_telemetry, OtelConfig}; +/// +/// let config = OtelConfig::default(); +/// let otel_guard = init_telemetry(&config); +/// +/// // The guard is kept alive for the duration of the application +/// // When it's dropped, all telemetry components are properly shut down +/// drop(otel_guard); +/// ``` +pub struct OtelGuard { tracer_provider: SdkTracerProvider, meter_provider: SdkMeterProvider, + logger_provider: SdkLoggerProvider, } -impl Telemetry { - pub fn init() -> Self { - // Define service resource information - let resource = Resource::builder() - .with_service_name("rustfs-service") - .with_schema_url( - [ - KeyValue::new(SERVICE_NAME, "rustfs-service"), - KeyValue::new(SERVICE_VERSION, "0.1.0"), - KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, "develop"), - KeyValue::new(NETWORK_LOCAL_ADDRESS, "127.0.0.1"), - ], - SCHEMA_URL, - ) - .build(); +impl Drop for OtelGuard { + fn drop(&mut self) { + if let Err(err) = self.tracer_provider.shutdown() { + eprintln!("Tracer shutdown error: {:?}", err); + } + if let Err(err) = self.meter_provider.shutdown() { + eprintln!("Meter shutdown error: {:?}", err); + } + if let Err(err) = self.logger_provider.shutdown() { + eprintln!("Logger shutdown error: {:?}", err); + } + } +} - let tracer_exporter = opentelemetry_otlp::SpanExporter::builder() +/// create OpenTelemetry Resource +fn resource(config: &OtelConfig) -> Resource { + Resource::builder() + .with_service_name(config.service_name.clone()) + .with_schema_url( + [ + KeyValue::new(SERVICE_NAME, config.service_name.clone()), + KeyValue::new(SERVICE_VERSION, config.service_version.clone()), + KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, config.deployment_environment.clone()), + KeyValue::new(NETWORK_LOCAL_ADDRESS, get_local_ip_with_default()), + ], + SCHEMA_URL, + ) + .build() +} + +/// Initialize Meter Provider +fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { + let mut builder = MeterProviderBuilder::default().with_resource(resource(config)); + // If endpoint is empty, use stdout output + if config.endpoint.is_empty() { + builder = builder.with_reader( + PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()) + .with_interval(std::time::Duration::from_secs(config.meter_interval)) + .build(), + ); + } else { + // If endpoint is not empty, use otlp output + let exporter = opentelemetry_otlp::MetricExporter::builder() .with_tonic() - .with_endpoint("http://localhost:4317") - .with_protocol(opentelemetry_otlp::Protocol::Grpc) - .with_timeout(Duration::from_secs(3)) - .build() - .unwrap(); - - // Configure Tracer Provider - let tracer_provider = SdkTracerProvider::builder() - .with_sampler(Sampler::AlwaysOn) - .with_id_generator(RandomIdGenerator::default()) - .with_resource(resource.clone()) - .with_batch_exporter(tracer_exporter) - // .with_simple_exporter(opentelemetry_stdout::SpanExporter::default()) - .build(); - - let meter_exporter = opentelemetry_otlp::MetricExporter::builder() - .with_tonic() - .with_endpoint("http://localhost:4317") - .with_protocol(opentelemetry_otlp::Protocol::Grpc) - .with_timeout(Duration::from_secs(3)) + .with_endpoint(&config.endpoint) .with_temporality(opentelemetry_sdk::metrics::Temporality::default()) .build() .unwrap(); + builder = builder.with_reader( + PeriodicReader::builder(exporter) + .with_interval(std::time::Duration::from_secs(config.meter_interval)) + .build(), + ); + // If use_stdout is true, output to stdout at the same time + if config.use_stdout { + builder = builder.with_reader( + PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()) + .with_interval(std::time::Duration::from_secs(config.meter_interval)) + .build(), + ); + } + } - let meter_reader = PeriodicReader::builder(meter_exporter) - .with_interval(Duration::from_secs(30)) - .build(); + let meter_provider = builder.build(); + global::set_meter_provider(meter_provider.clone()); + meter_provider +} - // For debugging in development - // let meter_stdout_reader = PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()).build(); +/// Initialize Tracer Provider +fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { + let sampler = if config.sample_ratio > 0.0 && config.sample_ratio < 1.0 { + Sampler::TraceIdRatioBased(config.sample_ratio) + } else { + Sampler::AlwaysOn + }; + let builder = SdkTracerProvider::builder() + .with_sampler(sampler) + .with_id_generator(RandomIdGenerator::default()) + .with_resource(resource(config)); - // Configure Meter Provider - let meter_provider = MeterProviderBuilder::default() - .with_resource(resource.clone()) - .with_reader(meter_reader) - // .with_reader(meter_stdout_reader) - .build(); + let tracer_provider = if config.endpoint.is_empty() { + builder + .with_simple_exporter(opentelemetry_stdout::SpanExporter::default()) + .build() + } else { + let exporter = opentelemetry_otlp::SpanExporter::builder() + .with_tonic() + .with_endpoint(&config.endpoint) + .build() + .unwrap(); + if config.use_stdout { + builder + .with_batch_exporter(exporter) + .with_batch_exporter(opentelemetry_stdout::SpanExporter::default()) + } else { + builder.with_batch_exporter(exporter) + } + .build() + }; - // Set global Tracer and Meter providers - global::set_tracer_provider(tracer_provider.clone()); - global::set_meter_provider(meter_provider.clone()); + global::set_tracer_provider(tracer_provider.clone()); + tracer_provider +} - let tracer = tracer_provider.tracer("rustfs-service"); +/// Initialize Telemetry +pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { + let tracer_provider = init_tracer_provider(config); + let meter_provider = init_meter_provider(config); + let tracer = tracer_provider.tracer(config.service_name.clone()); - // // let _stdout_exporter = opentelemetry_stdout::LogExporter::default(); - // let otlp_exporter = opentelemetry_otlp::LogExporter::builder() - // .with_tonic() - // .with_endpoint("http://localhost:4317") - // // .with_timeout(Duration::from_secs(3)) - // // .with_protocol(opentelemetry_otlp::Protocol::Grpc) - // .build() - // .unwrap(); - // let provider: SdkLoggerProvider = SdkLoggerProvider::builder() - // .with_resource(resource.clone()) - // .with_simple_exporter(otlp_exporter) - // .build(); - // let filter_otel = EnvFilter::new("debug") - // // .add_directive("hyper=off".parse().unwrap()) - // // .add_directive("opentelemetry=off".parse().unwrap()) - // // .add_directive("tonic=off".parse().unwrap()) - // // .add_directive("h2=off".parse().unwrap()) - // .add_directive("reqwest=off".parse().unwrap()); - // let otel_layer = layer::OpenTelemetryTracingBridge::new(&provider).with_filter(filter_otel); + let logger_provider = if config.endpoint.is_empty() { + SdkLoggerProvider::builder() + .with_resource(resource(config)) + .with_simple_exporter(opentelemetry_stdout::LogExporter::default()) + .build() + } else { + let exporter = opentelemetry_otlp::LogExporter::builder() + .with_tonic() + .with_endpoint(&config.endpoint) + .build() + .unwrap(); + SdkLoggerProvider::builder() + .with_resource(resource(config)) + .with_batch_exporter(exporter) + .with_batch_exporter(opentelemetry_stdout::LogExporter::default()) + .build() + }; + + let otel_layer = layer::OpenTelemetryTracingBridge::new(&logger_provider); + // For the OpenTelemetry layer, add a tracing filter to filter events from + // OpenTelemetry and its dependent crates (opentelemetry-otlp uses crates + // like reqwest/tonic etc.) from being sent back to OTel itself, thus + // preventing infinite telemetry generation. The filter levels are set as + // follows: + // - Allow `info` level and above by default. + // - Restrict `opentelemetry`, `hyper`, `tonic`, and `reqwest` completely. + // Note: This will also drop events from crates like `tonic` etc. even when + // they are used outside the OTLP Exporter. For more details, see: + // https://github.com/open-telemetry/opentelemetry-rust/issues/761 + let filter_otel = EnvFilter::new("info") + .add_directive("hyper=off".parse().unwrap()) + .add_directive("opentelemetry=off".parse().unwrap()) + .add_directive("tonic=off".parse().unwrap()) + .add_directive("h2=off".parse().unwrap()) + .add_directive("reqwest=off".parse().unwrap()); + let otel_layer = otel_layer.with_filter(filter_otel); + let registry = tracing_subscriber::registry() + .with(tracing_subscriber::filter::LevelFilter::INFO) + .with(OpenTelemetryLayer::new(tracer)) + .with(MetricsLayer::new(meter_provider.clone())) + .with(otel_layer); + if config.endpoint.is_empty() { + // Create a new tracing::Fmt layer to print the logs to stdout. It has a + // default filter of `info` level and above, and `debug` and above for logs + // from OpenTelemetry crates. The filter levels can be customized as needed. let filter_fmt = EnvFilter::new("info").add_directive("opentelemetry=debug".parse().unwrap()); let fmt_layer = tracing_subscriber::fmt::layer() .with_thread_names(true) .with_filter(filter_fmt); - // Configure `tracing subscriber` - tracing_subscriber::registry() - .with(tracing_subscriber::filter::LevelFilter::from_level(Level::DEBUG)) + registry .with(tracing_subscriber::fmt::layer().with_ansi(true)) - .with(MetricsLayer::new(meter_provider.clone())) - .with(OpenTelemetryLayer::new(tracer)) - // .with(otel_layer) .with(fmt_layer) .init(); - info!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "otel@opentelemetry.io", message = "This is an example message"); - Self { - tracer_provider, - meter_provider, - } + } else { + registry.with(tracing_subscriber::fmt::layer().with_ansi(false)).init(); + println!("Logs and meter,tracer enabled"); } -} -impl Drop for Telemetry { - fn drop(&mut self) { - if let Err(err) = self.tracer_provider.shutdown() { - eprintln!("{err:?}"); - } - if let Err(err) = self.meter_provider.shutdown() { - eprintln!("{err:?}"); - } + OtelGuard { + tracer_provider, + meter_provider, + logger_provider, } } diff --git a/packages/obs/src/utils.rs b/packages/obs/src/utils.rs new file mode 100644 index 000000000..774594577 --- /dev/null +++ b/packages/obs/src/utils.rs @@ -0,0 +1,42 @@ +use local_ip_address::{local_ip, local_ipv6}; +use std::net::{IpAddr, Ipv4Addr}; + +/// Get the IP address of the machine +/// +/// Priority is given to trying to get the IPv4 address, and if it fails, try to get the IPv6 address. +/// If both fail to retrieve, None is returned. +/// +/// # Returns +/// +/// * `Some(IpAddr)` - Native IP address (IPv4 or IPv6) +/// * `None` - Unable to obtain any native IP address +pub fn get_local_ip() -> Option { + local_ip().ok().or_else(|| local_ipv6().ok()) +} + +/// Get the IP address of the machine as a string +/// +/// If the IP address cannot be obtained, returns "127.0.0.1" as the default value. +/// +/// # Returns +/// +/// * `String` - Native IP address (IPv4 or IPv6) as a string, or the default value +pub fn get_local_ip_with_default() -> String { + get_local_ip() + .unwrap_or_else(|| IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))) // Provide a safe default value + .to_string() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_get_local_ip() { + match get_local_ip() { + Some(ip) => println!("the ip address of this machine:{}", ip), + None => println!("Unable to obtain the IP address of the machine"), + } + assert!(get_local_ip().is_some()); + } +} diff --git a/packages/obs/src/worker.rs b/packages/obs/src/worker.rs new file mode 100644 index 000000000..a04327945 --- /dev/null +++ b/packages/obs/src/worker.rs @@ -0,0 +1,13 @@ +use crate::{entry::LogEntry, sink::Sink}; +use std::sync::Arc; +use tokio::sync::mpsc::Receiver; + +/// Start the log processing worker thread +pub async fn start_worker(receiver: Receiver, sinks: Vec>) { + let mut receiver = receiver; + while let Some(entry) = receiver.recv().await { + for sink in &sinks { + sink.write(&entry).await; + } + } +} From c3ca7960e90a75eb3c2c08d5e3801e55ad365a27 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 12 Mar 2025 11:58:10 +0800 Subject: [PATCH 007/103] improve dependencies feature --- packages/obs/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/obs/Cargo.toml b/packages/obs/Cargo.toml index 8753d63c7..216e4296a 100644 --- a/packages/obs/Cargo.toml +++ b/packages/obs/Cargo.toml @@ -30,7 +30,7 @@ tracing = { workspace = true } tracing-core = { workspace = true } tracing-opentelemetry = { workspace = true } tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } -tokio = { workspace = true, features = ["sync", "fs"] } +tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread"] } rdkafka = { workspace = true, features = ["tokio"], optional = true } reqwest = { workspace = true, optional = true, default-features = false } serde_json = { workspace = true, optional = true } From ef162396cfb66776753258a80e37286e9f6058da Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 16 Mar 2025 16:33:52 +0800 Subject: [PATCH 008/103] improve code --- Cargo.lock | 1 + packages/obs/Cargo.toml | 5 +- packages/obs/examples/config.toml | 4 +- packages/obs/examples/server.rs | 69 +-- packages/obs/src/config.rs | 12 +- packages/obs/src/entry/audit.rs | 88 ++++ packages/obs/src/entry/base.rs | 114 +++++ packages/obs/src/{entry.rs => entry/log.rs} | 3 + packages/obs/src/entry/mod.rs | 3 + packages/obs/src/lib.rs | 43 +- packages/obs/src/logger.rs | 464 +++++++++++++++----- packages/obs/src/sink.rs | 7 +- packages/obs/src/telemetry.rs | 107 +++-- packages/obs/src/worker.rs | 2 +- rustfs/src/main.rs | 8 +- 15 files changed, 724 insertions(+), 206 deletions(-) create mode 100644 packages/obs/src/entry/audit.rs create mode 100644 packages/obs/src/entry/base.rs rename packages/obs/src/{entry.rs => entry/log.rs} (95%) create mode 100644 packages/obs/src/entry/mod.rs diff --git a/Cargo.lock b/Cargo.lock index ca81fe744..f619b7a52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5744,6 +5744,7 @@ dependencies = [ "tokio", "tracing", "tracing-core", + "tracing-error", "tracing-opentelemetry", "tracing-subscriber", ] diff --git a/packages/obs/Cargo.toml b/packages/obs/Cargo.toml index 216e4296a..86a9fb6c4 100644 --- a/packages/obs/Cargo.toml +++ b/packages/obs/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [features] default = ["file"] -kafka = ["dep:rdkafka", "dep:serde_json"] +kafka = ["dep:rdkafka"] webhook = ["dep:reqwest"] file = [] @@ -28,12 +28,13 @@ opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_ex serde = { workspace = true } tracing = { workspace = true } tracing-core = { workspace = true } +tracing-error = { workspace = true } tracing-opentelemetry = { workspace = true } tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread"] } rdkafka = { workspace = true, features = ["tokio"], optional = true } reqwest = { workspace = true, optional = true, default-features = false } -serde_json = { workspace = true, optional = true } +serde_json = { workspace = true } thiserror = { workspace = true } local-ip-address = { workspace = true } diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml index 9c3c68a26..2ceac4397 100644 --- a/packages/obs/examples/config.toml +++ b/packages/obs/examples/config.toml @@ -3,7 +3,7 @@ endpoint = "http://localhost:4317" use_stdout = true sample_ratio = 0.5 meter_interval = 30 -service_name = "logging_service" +service_name = "rustfs_obs_service" service_version = "0.1.0" deployment_environment = "develop" @@ -23,7 +23,7 @@ batch_timeout_ms = 1000 # Default is 100ms if not specified [sinks.file] enabled = true -path = "app.log" +path = "logs/app.log" batch_size = 100 batch_timeout_ms = 1000 # Default is 8192 bytes if not specified diff --git a/packages/obs/examples/server.rs b/packages/obs/examples/server.rs index b2c104dd3..60b275de2 100644 --- a/packages/obs/examples/server.rs +++ b/packages/obs/examples/server.rs @@ -1,47 +1,53 @@ use opentelemetry::global; -use opentelemetry::trace::TraceContextExt; -use rustfs_obs::{init_logging, load_config, LogEntry}; +use rustfs_obs::{get_logger, init_obs, load_config, log_info, LogEntry}; use std::time::{Duration, SystemTime}; -use tracing::{info, instrument, Span}; +use tracing::{info, instrument}; use tracing_core::Level; -use tracing_opentelemetry::OpenTelemetrySpanExt; #[tokio::main] async fn main() { - let start_time = SystemTime::now(); let config = load_config(Some("packages/obs/examples/config".to_string())); - info!("Configuration file loading is complete {:?}", config.clone()); - let (logger, _guard) = init_logging(config); - info!("Log module initialization is completed"); + let (_logger, _guard) = init_obs(config.clone()).await; // Simulate the operation tokio::time::sleep(Duration::from_millis(100)).await; + run( + "service-demo".to_string(), + "object-demo".to_string(), + "user-demo".to_string(), + "service-demo".to_string(), + ) + .await; + info!("Program ends"); +} + +#[instrument(fields(bucket, object, user))] +async fn run(bucket: String, object: String, user: String, service_name: String) { + let start_time = SystemTime::now(); + info!("Log module initialization is completed service_name: {:?}", service_name); // Record Metrics let meter = global::meter("rustfs.rs"); let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); request_duration.record( start_time.elapsed().unwrap().as_secs_f64(), - &[opentelemetry::KeyValue::new("operation", "put_object")], + &[opentelemetry::KeyValue::new("operation", "run")], ); - // Gets the current span - let span = Span::current(); - // Use 'OpenTelemetrySpanExt' to get 'SpanContext' - let span_context = span.context(); // Get context via OpenTelemetrySpanExt - let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId - let trace_id = span_context.span().span_context().trace_id().to_string(); // Get the TraceId - let result = logger + let result = get_logger() + .lock() + .await .log(LogEntry::new( Level::INFO, "Process user requests".to_string(), "api_handler".to_string(), + Some("demo-audit".to_string()), Some("req-12345".to_string()), - Some("user-6789".to_string()), + Some(user), vec![ ("endpoint".to_string(), "/api/v1/data".to_string()), ("method".to_string(), "GET".to_string()), - ("span_id".to_string(), span_id), - ("trace_id".to_string(), trace_id), + ("bucket".to_string(), bucket), + ("object-length".to_string(), object.len().to_string()), ], )) .await; @@ -49,28 +55,31 @@ async fn main() { put_object("bucket".to_string(), "object".to_string(), "user".to_string()).await; info!("Logging is completed"); tokio::time::sleep(Duration::from_secs(2)).await; - info!("Program ends"); + info!("Program run ends"); } #[instrument(fields(bucket, object, user))] async fn put_object(bucket: String, object: String, user: String) { let start_time = SystemTime::now(); - info!("Starting PUT operation"); - // Gets the current span - let span = Span::current(); - // Use 'OpenTelemetrySpanExt' to get 'SpanContext' - let span_context = span.context(); // Get context via OpenTelemetrySpanExt - let span_id = span_context.span().span_context().span_id().to_string(); // Get the SpanId - let trace_id = span_context.span().span_context().trace_id().to_string(); // Get the TraceId + info!("Starting put_object operation"); + + let meter = global::meter("rustfs.rs"); + let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); + request_duration.record( + start_time.elapsed().unwrap().as_secs_f64(), + &[opentelemetry::KeyValue::new("operation", "put_object")], + ); + info!( - "Starting PUT operation content: bucket = {}, object = {}, user = {},span_id = {},trace_id = {},start_time = {}", + "Starting PUT operation content: bucket = {}, object = {}, user = {},start_time = {}", bucket, object, user, - span_id, - trace_id, start_time.elapsed().unwrap().as_secs_f64() ); + + let result = log_info("put_object logger info", "put_object").await; + info!("put_object is completed {:?}", result); // Simulate the operation tokio::time::sleep(Duration::from_millis(100)).await; diff --git a/packages/obs/src/config.rs b/packages/obs/src/config.rs index 8b14f7d0d..c6e57c421 100644 --- a/packages/obs/src/config.rs +++ b/packages/obs/src/config.rs @@ -15,7 +15,7 @@ pub struct OtelConfig { } /// Kafka Sink Configuration - Add batch parameters -#[derive(Debug, Deserialize, Clone)] +#[derive(Debug, Deserialize, Clone, Default)] pub struct KafkaSinkConfig { pub enabled: bool, pub bootstrap_servers: String, @@ -25,7 +25,7 @@ pub struct KafkaSinkConfig { } /// Webhook Sink Configuration - Add Retry Parameters -#[derive(Debug, Deserialize, Clone)] +#[derive(Debug, Deserialize, Clone, Default)] pub struct WebhookSinkConfig { pub enabled: bool, pub url: String, @@ -34,7 +34,7 @@ pub struct WebhookSinkConfig { } /// File Sink Configuration - Add buffering parameters -#[derive(Debug, Deserialize, Clone)] +#[derive(Debug, Deserialize, Clone, Default)] pub struct FileSinkConfig { pub enabled: bool, pub path: String, @@ -44,7 +44,7 @@ pub struct FileSinkConfig { } /// Sink configuration collection -#[derive(Debug, Deserialize, Clone)] +#[derive(Debug, Deserialize, Clone, Default)] pub struct SinkConfig { pub kafka: KafkaSinkConfig, pub webhook: WebhookSinkConfig, @@ -52,13 +52,13 @@ pub struct SinkConfig { } ///Logger Configuration -#[derive(Debug, Deserialize, Clone)] +#[derive(Debug, Deserialize, Clone, Default)] pub struct LoggerConfig { pub queue_capacity: Option, } /// Overall application configuration -#[derive(Debug, Deserialize, Clone)] +#[derive(Debug, Deserialize, Clone, Default)] pub struct AppConfig { pub observability: OtelConfig, pub sinks: SinkConfig, diff --git a/packages/obs/src/entry/audit.rs b/packages/obs/src/entry/audit.rs new file mode 100644 index 000000000..4e5099857 --- /dev/null +++ b/packages/obs/src/entry/audit.rs @@ -0,0 +1,88 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; + +/// ObjectVersion object version key/versionId +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ObjectVersion { + #[serde(rename = "objectName")] + pub object_name: String, + #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] + pub version_id: Option, +} + +/// API details structure +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct ApiDetails { + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] + pub bucket: Option, + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "objects", skip_serializing_if = "Vec::is_empty", default)] + pub objects: Vec, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option, + #[serde(rename = "statusCode", skip_serializing_if = "Option::is_none")] + pub status_code: Option, + #[serde(rename = "rx")] + pub input_bytes: i64, + #[serde(rename = "tx")] + pub output_bytes: i64, + #[serde(rename = "txHeaders", skip_serializing_if = "Option::is_none")] + pub header_bytes: Option, + #[serde(rename = "timeToFirstByte", skip_serializing_if = "Option::is_none")] + pub time_to_first_byte: Option, + #[serde(rename = "timeToFirstByteInNS", skip_serializing_if = "Option::is_none")] + pub time_to_first_byte_in_ns: Option, + #[serde(rename = "timeToResponse", skip_serializing_if = "Option::is_none")] + pub time_to_response: Option, + #[serde(rename = "timeToResponseInNS", skip_serializing_if = "Option::is_none")] + pub time_to_response_in_ns: Option, +} + +/// Entry - audit entry logs +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct AuditEntry { + pub version: String, + #[serde(rename = "deploymentid", skip_serializing_if = "Option::is_none")] + pub deployment_id: Option, + pub time: DateTime, + pub event: String, + + // Class of audit message - S3, admin ops, bucket management + #[serde(rename = "type", skip_serializing_if = "Option::is_none")] + pub entry_type: Option, + + // Deprecated, replaced by 'Event' + pub trigger: String, + pub api: ApiDetails, + #[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")] + pub remote_host: Option, + #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")] + pub request_id: Option, + #[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")] + pub user_agent: Option, + #[serde(rename = "requestPath", skip_serializing_if = "Option::is_none")] + pub req_path: Option, + #[serde(rename = "requestHost", skip_serializing_if = "Option::is_none")] + pub req_host: Option, + #[serde(rename = "requestClaims", skip_serializing_if = "Option::is_none")] + pub req_claims: Option>, + #[serde(rename = "requestQuery", skip_serializing_if = "Option::is_none")] + pub req_query: Option>, + #[serde(rename = "requestHeader", skip_serializing_if = "Option::is_none")] + pub req_header: Option>, + #[serde(rename = "responseHeader", skip_serializing_if = "Option::is_none")] + pub resp_header: Option>, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, + #[serde(rename = "accessKey", skip_serializing_if = "Option::is_none")] + pub access_key: Option, + #[serde(rename = "parentUser", skip_serializing_if = "Option::is_none")] + pub parent_user: Option, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option, +} diff --git a/packages/obs/src/entry/base.rs b/packages/obs/src/entry/base.rs new file mode 100644 index 000000000..aa9d22ab7 --- /dev/null +++ b/packages/obs/src/entry/base.rs @@ -0,0 +1,114 @@ +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; + +/// ObjectVersion object version key/versionId +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ObjectVersion { + #[serde(rename = "objectName")] + pub object_name: String, + #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] + pub version_id: Option, +} + +/// Args - defines the arguments for the API +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Args { + #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] + pub bucket: Option, + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] + pub version_id: Option, + #[serde(rename = "objects", skip_serializing_if = "Option::is_none")] + pub objects: Option>, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +/// Trace - defines the trace +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Trace { + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + #[serde(rename = "source", skip_serializing_if = "Option::is_none")] + pub source: Option>, + #[serde(rename = "variables", skip_serializing_if = "Option::is_none")] + pub variables: Option>, +} + +/// API - defines the api type and its args +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct API { + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "args", skip_serializing_if = "Option::is_none")] + pub args: Option, +} + +/// Log kind/level enum +#[derive(Debug, Clone, Serialize, Deserialize)] +pub enum LogKind { + #[serde(rename = "INFO")] + Info, + #[serde(rename = "WARNING")] + Warning, + #[serde(rename = "ERROR")] + Error, + #[serde(rename = "FATAL")] + Fatal, +} + +/// Entry - defines fields and values of each log entry +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Entry { + #[serde(rename = "site", skip_serializing_if = "Option::is_none")] + pub site: Option, + + #[serde(rename = "deploymentid", skip_serializing_if = "Option::is_none")] + pub deployment_id: Option, + + pub level: LogKind, + + #[serde(rename = "errKind", skip_serializing_if = "Option::is_none")] + pub log_kind: Option, // Deprecated Jan 2024 + + pub time: DateTime, + + #[serde(rename = "api", skip_serializing_if = "Option::is_none")] + pub api: Option, + + #[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")] + pub remote_host: Option, + + #[serde(rename = "host", skip_serializing_if = "Option::is_none")] + pub host: Option, + + #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")] + pub request_id: Option, + + #[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")] + pub user_agent: Option, + + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, + + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub trace: Option, +} + +/// Info holds console log messages +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Info { + #[serde(flatten)] + pub entry: Entry, + + pub console_msg: String, + + #[serde(rename = "node")] + pub node_name: String, + + #[serde(skip)] + pub err: Option, +} diff --git a/packages/obs/src/entry.rs b/packages/obs/src/entry/log.rs similarity index 95% rename from packages/obs/src/entry.rs rename to packages/obs/src/entry/log.rs index a8cef168a..6960fef21 100644 --- a/packages/obs/src/entry.rs +++ b/packages/obs/src/entry/log.rs @@ -52,6 +52,7 @@ pub struct LogEntry { pub level: SerializableLevel, // Log Level pub message: String, // Log messages pub source: String, // Log source (such as module name) + pub target: Option, // Log target pub request_id: Option, // Request ID (Common Server Fields) pub user_id: Option, // User ID (Common Server Fields) pub fields: Vec<(String, String)>, // Attached fields (key value pairs) @@ -63,6 +64,7 @@ impl LogEntry { level: Level, message: String, source: String, + target: Option, request_id: Option, user_id: Option, fields: Vec<(String, String)>, @@ -72,6 +74,7 @@ impl LogEntry { level: SerializableLevel::from(level), message, source, + target, request_id, user_id, fields, diff --git a/packages/obs/src/entry/mod.rs b/packages/obs/src/entry/mod.rs new file mode 100644 index 000000000..efc697e01 --- /dev/null +++ b/packages/obs/src/entry/mod.rs @@ -0,0 +1,3 @@ +pub(crate) mod audit; +mod base; +pub(crate) mod log; diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index 469547d61..079d9abfc 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -13,20 +13,53 @@ mod worker; pub use config::load_config; pub use config::{AppConfig, OtelConfig}; -pub use entry::{LogEntry, SerializableLevel}; +pub use entry::log::{LogEntry, SerializableLevel}; pub use logger::start_logger; +pub use logger::{ + ensure_logger_initialized, get_global_logger, init_global_logger, locked_logger, log_debug, log_error, log_info, log_trace, + log_warn, log_with_context, +}; pub use logger::{LogError, Logger}; pub use sink::Sink; +use std::sync::Arc; pub use telemetry::init_telemetry; +use tokio::sync::Mutex; pub use utils::{get_local_ip, get_local_ip_with_default}; pub use worker::start_worker; -/// Log module initialization function +/// Initialize the observability module /// -/// Return to Logger and Clean Guard -pub fn init_logging(config: AppConfig) -> (Logger, telemetry::OtelGuard) { +/// # Parameters +/// - `config`: Configuration information +/// +/// # Returns +/// A tuple containing the logger and the telemetry guard +/// +/// # Example +/// ``` +/// use rustfs_obs::{AppConfig, init_obs}; +/// +/// let config = AppConfig::default(); +/// let (logger, guard) = init_obs(config); +/// ``` +pub async fn init_obs(config: AppConfig) -> (Arc>, telemetry::OtelGuard) { let guard = init_telemetry(&config.observability); let sinks = sink::create_sinks(&config); - let logger = start_logger(&config, sinks); + let logger = init_global_logger(&config, sinks).await; (logger, guard) } + +/// Get the global logger instance +/// This function returns a reference to the global logger instance. +/// +/// # Returns +/// A reference to the global logger instance +/// +/// # Example +/// ``` +/// use rustfs_obs::get_logger; +/// let logger = get_logger(); +/// ``` +pub fn get_logger() -> &'static Arc> { + get_global_logger() +} diff --git a/packages/obs/src/logger.rs b/packages/obs/src/logger.rs index f2297c9ef..a3848cc3b 100644 --- a/packages/obs/src/logger.rs +++ b/packages/obs/src/logger.rs @@ -1,8 +1,14 @@ use crate::{AppConfig, LogEntry, SerializableLevel, Sink}; use std::sync::Arc; use tokio::sync::mpsc::{self, Receiver, Sender}; +use tokio::sync::{Mutex, OnceCell}; +use tracing_core::Level; + +// Add the global instance at the module level +static GLOBAL_LOGGER: OnceCell>> = OnceCell::const_new(); /// Server log processor +#[derive(Debug)] pub struct Logger { sender: Sender, // Log sending channel queue_capacity: usize, @@ -15,17 +21,21 @@ impl Logger { // Get queue capacity from configuration, or use default values 10000 let queue_capacity = config.logger.queue_capacity.unwrap_or(10000); let (sender, receiver) = mpsc::channel(queue_capacity); - ( - Logger { - sender, - queue_capacity, - }, - receiver, - ) + (Logger { sender, queue_capacity }, receiver) } - // Add a method to get queue capacity - pub fn queue_capacity(&self) -> usize { + /// get the queue capacity + /// This function returns the queue capacity. + /// # Returns + /// The queue capacity + /// # Example + /// ``` + /// use rustfs_obs::Logger; + /// async fn example(logger: &Logger) { + /// let _ = logger.get_queue_capacity(); + /// } + /// ``` + pub fn get_queue_capacity(&self) -> usize { self.queue_capacity } @@ -37,20 +47,20 @@ impl Logger { tracing::Span::current() .record("log_message", &entry.message) .record("source", &entry.source); + println!("target start is {:?}", &entry.target); + let target = if let Some(target) = &entry.target { + target.clone() + } else { + "server_logs".to_string() + }; - // Record queue utilization (if a certain threshold is exceeded) - let queue_len = self.sender.capacity(); - let utilization = queue_len as f64 / self.queue_capacity as f64; - if utilization > 0.8 { - tracing::warn!("Log queue utilization high: {:.1}%", utilization * 100.0); - } - + println!("target end is {:?}", target); // Generate independent Tracing Events with full LogEntry information // Generate corresponding events according to level match entry.level { - SerializableLevel(tracing::Level::ERROR) => { + SerializableLevel(Level::ERROR) => { tracing::error!( - target: "server_logs", + target = %target.clone(), timestamp = %entry.timestamp, message = %entry.message, source = %entry.source, @@ -59,9 +69,9 @@ impl Logger { fields = ?entry.fields ); } - SerializableLevel(tracing::Level::WARN) => { + SerializableLevel(Level::WARN) => { tracing::warn!( - target: "server_logs", + target = %target.clone(), timestamp = %entry.timestamp, message = %entry.message, source = %entry.source, @@ -70,9 +80,9 @@ impl Logger { fields = ?entry.fields ); } - SerializableLevel(tracing::Level::INFO) => { + SerializableLevel(Level::INFO) => { tracing::info!( - target: "server_logs", + target = %target.clone(), timestamp = %entry.timestamp, message = %entry.message, source = %entry.source, @@ -81,9 +91,9 @@ impl Logger { fields = ?entry.fields ); } - SerializableLevel(tracing::Level::DEBUG) => { + SerializableLevel(Level::DEBUG) => { tracing::debug!( - target: "server_logs", + target = %target.clone(), timestamp = %entry.timestamp, message = %entry.message, source = %entry.source, @@ -92,9 +102,9 @@ impl Logger { fields = ?entry.fields ); } - SerializableLevel(tracing::Level::TRACE) => { + SerializableLevel(Level::TRACE) => { tracing::trace!( - target: "server_logs", + target = %target.clone(), timestamp = %entry.timestamp, message = %entry.message, source = %entry.source, @@ -111,102 +121,52 @@ impl Logger { Err(mpsc::error::TrySendError::Full(entry)) => { // Processing strategy when queue is full tracing::warn!("Log queue full, applying backpressure"); - match tokio::time::timeout( - std::time::Duration::from_millis(500), - self.sender.send(entry), - ) - .await - { + match tokio::time::timeout(std::time::Duration::from_millis(500), self.sender.send(entry)).await { Ok(Ok(_)) => Ok(()), Ok(Err(_)) => Err(LogError::SendFailed("Channel closed")), Err(_) => Err(LogError::Timeout("Queue backpressure timeout")), } } - Err(mpsc::error::TrySendError::Closed(_)) => { - Err(LogError::SendFailed("Logger channel closed")) - } + Err(mpsc::error::TrySendError::Closed(_)) => Err(LogError::SendFailed("Logger channel closed")), } } - // Add convenient methods to simplify logging - // Fix the info() method, replacing None with an empty vector instead of the Option type - pub async fn info(&self, message: &str, source: &str) -> Result<(), LogError> { - self.log(LogEntry::new( - tracing::Level::INFO, - message.to_string(), - source.to_string(), - None, - None, - Vec::new(), // 使用空向量代替 None - )) - .await - } - - /// Add warn() method - pub async fn error(&self, message: &str, source: &str) -> Result<(), LogError> { - self.log(LogEntry::new( - tracing::Level::ERROR, - message.to_string(), - source.to_string(), - None, - None, - Vec::new(), - )) - .await - } - - /// Add warn() method - pub async fn warn(&self, message: &str, source: &str) -> Result<(), LogError> { - self.log(LogEntry::new( - tracing::Level::WARN, - message.to_string(), - source.to_string(), - None, - None, - Vec::new(), - )) - .await - } - - /// Add debug() method - pub async fn debug(&self, message: &str, source: &str) -> Result<(), LogError> { - self.log(LogEntry::new( - tracing::Level::DEBUG, - message.to_string(), - source.to_string(), - None, - None, - Vec::new(), - )) - .await - } - - /// Add trace() method - pub async fn trace(&self, message: &str, source: &str) -> Result<(), LogError> { - self.log(LogEntry::new( - tracing::Level::TRACE, - message.to_string(), - source.to_string(), - None, - None, - Vec::new(), - )) - .await - } - - // Add extension methods with context information for more flexibility - pub async fn info_with_context( + /// Write log with context information + /// This function writes log messages with context information. + /// + /// # Parameters + /// - `message`: Message to be logged + /// - `source`: Source of the log + /// - `request_id`: Request ID + /// - `user_id`: User ID + /// - `fields`: Additional fields + /// + /// # Returns + /// Result indicating whether the operation was successful + /// + /// # Example + /// ``` + /// use tracing_core::Level; + /// use rustfs_obs::Logger; + /// + /// async fn example(logger: &Logger) { + /// let _ = logger.write_with_context("This is an information message", "example",Level::INFO, Some("target".to_string()),Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await; + /// } + pub async fn write_with_context( &self, message: &str, source: &str, + level: Level, + target: Option, request_id: Option, user_id: Option, fields: Vec<(String, String)>, ) -> Result<(), LogError> { self.log(LogEntry::new( - tracing::Level::INFO, + level, message.to_string(), source.to_string(), + target, request_id, user_id, fields, @@ -214,14 +174,69 @@ impl Logger { .await } - // Add elegant closing method + /// Write log + /// This function writes log messages. + /// # Parameters + /// - `message`: Message to be logged + /// - `source`: Source of the log + /// - `level`: Log level + /// + /// # Returns + /// Result indicating whether the operation was successful + /// + /// # Example + /// ``` + /// use rustfs_obs::Logger; + /// use tracing_core::Level; + /// + /// async fn example(logger: &Logger) { + /// let _ = logger.write("This is an information message", "example", Level::INFO).await; + /// } + /// ``` + pub async fn write(&self, message: &str, source: &str, level: Level) -> Result<(), LogError> { + self.log(LogEntry::new( + level, + message.to_string(), + source.to_string(), + None, + None, + None, + Vec::new(), + )) + .await + } + + /// Shutdown the logger + /// This function shuts down the logger. + /// + /// # Returns + /// Result indicating whether the operation was successful + /// + /// # Example + /// ``` + /// use rustfs_obs::Logger; + /// + /// async fn example(logger: Logger) { + /// let _ = logger.shutdown().await; + /// } + /// ``` pub async fn shutdown(self) -> Result<(), LogError> { drop(self.sender); //Close the sending end so that the receiver knows that there is no new message Ok(()) } } -// Define custom error type +/// Log error type +/// This enum defines the error types that can occur when logging. +/// It is used to provide more detailed error information. +/// # Example +/// ``` +/// use rustfs_obs::LogError; +/// use thiserror::Error; +/// +/// LogError::SendFailed("Failed to send log"); +/// LogError::Timeout("Operation timed out"); +/// ``` #[derive(Debug, thiserror::Error)] pub enum LogError { #[error("Failed to send log: {0}")] @@ -231,8 +246,245 @@ pub enum LogError { } /// Start the log module +/// This function starts the log module. +/// It initializes the logger and starts the worker to process logs. +/// # Parameters +/// - `config`: Configuration information +/// - `sinks`: A vector of Sink instances +/// # Returns +/// The global logger instance +/// # Example +/// ``` +/// use rustfs_obs::{AppConfig, start_logger}; +/// +/// let config = AppConfig::default(); +/// let sinks = vec![]; +/// let logger = start_logger(&config, sinks); +/// ``` pub fn start_logger(config: &AppConfig, sinks: Vec>) -> Logger { let (logger, receiver) = Logger::new(config); tokio::spawn(crate::worker::start_worker(receiver, sinks)); logger } + +/// Initialize the global logger instance +/// This function initializes the global logger instance and returns a reference to it. +/// If the logger has been initialized before, it will return the existing logger instance. +/// +/// # Parameters +/// - `config`: Configuration information +/// - `sinks`: A vector of Sink instances +/// +/// # Returns +/// A reference to the global logger instance +/// +/// # Example +/// ``` +/// use rustfs_obs::{AppConfig,init_global_logger}; +/// +/// let config = AppConfig::default(); +/// let sinks = vec![]; +/// let logger = init_global_logger(&config, sinks); +/// ``` +pub async fn init_global_logger(config: &AppConfig, sinks: Vec>) -> Arc> { + let logger = Arc::new(Mutex::new(start_logger(config, sinks))); + GLOBAL_LOGGER.set(logger.clone()).expect("Logger already initialized"); + logger +} + +/// Get the global logger instance +/// +/// This function returns a reference to the global logger instance. +/// +/// # Returns +/// A reference to the global logger instance +/// +/// # Example +/// ``` +/// use rustfs_obs::get_global_logger; +/// +/// let logger = get_global_logger(); +/// ``` +pub fn get_global_logger() -> &'static Arc> { + GLOBAL_LOGGER.get().expect("Logger not initialized") +} + +/// Get the global logger instance with a lock +/// This function returns a reference to the global logger instance with a lock. +/// It is used to ensure that the logger is thread-safe. +/// +/// # Returns +/// A reference to the global logger instance with a lock +/// +/// # Example +/// ``` +/// use rustfs_obs::locked_logger; +/// +/// async fn example() { +/// let logger = locked_logger().await; +/// } +/// ``` +pub async fn locked_logger() -> tokio::sync::MutexGuard<'static, Logger> { + get_global_logger().lock().await +} + +/// Initialize with default empty logger if needed (optional) +/// This function initializes the logger with a default empty logger if needed. +/// It is used to ensure that the logger is initialized before logging. +/// +/// # Returns +/// A reference to the global logger instance +/// +/// # Example +/// ``` +/// use rustfs_obs::ensure_logger_initialized; +/// +/// let logger = ensure_logger_initialized(); +/// ``` +pub fn ensure_logger_initialized() -> &'static Arc> { + if GLOBAL_LOGGER.get().is_none() { + let config = AppConfig::default(); + let sinks = vec![]; + let logger = Arc::new(Mutex::new(start_logger(&config, sinks))); + let _ = GLOBAL_LOGGER.set(logger); + } + GLOBAL_LOGGER.get().unwrap() +} + +/// Log information +/// This function logs information messages. +/// +/// # Parameters +/// - `message`: Message to be logged +/// - `source`: Source of the log +/// +/// # Returns +/// Result indicating whether the operation was successful +/// +/// # Example +/// ``` +/// use rustfs_obs::log_info; +/// +/// async fn example() { +/// let _ = log_info("This is an information message", "example").await; +/// } +/// ``` +pub async fn log_info(message: &str, source: &str) -> Result<(), LogError> { + get_global_logger().lock().await.write(message, source, Level::INFO).await +} + +/// Log error +/// This function logs error messages. +/// # Parameters +/// - `message`: Message to be logged +/// - `source`: Source of the log +/// # Returns +/// Result indicating whether the operation was successful +/// # Example +/// ``` +/// use rustfs_obs::log_error; +/// +/// async fn example() { +/// let _ = log_error("This is an error message", "example").await; +/// } +pub async fn log_error(message: &str, source: &str) -> Result<(), LogError> { + get_global_logger().lock().await.write(message, source, Level::ERROR).await +} + +/// Log warning +/// This function logs warning messages. +/// # Parameters +/// - `message`: Message to be logged +/// - `source`: Source of the log +/// # Returns +/// Result indicating whether the operation was successful +/// +/// # Example +/// ``` +/// use rustfs_obs::log_warn; +/// +/// async fn example() { +/// let _ = log_warn("This is a warning message", "example").await; +/// } +/// ``` +pub async fn log_warn(message: &str, source: &str) -> Result<(), LogError> { + get_global_logger().lock().await.write(message, source, Level::WARN).await +} + +/// Log debug +/// This function logs debug messages. +/// # Parameters +/// - `message`: Message to be logged +/// - `source`: Source of the log +/// # Returns +/// Result indicating whether the operation was successful +/// +/// # Example +/// ``` +/// use rustfs_obs::log_debug; +/// +/// async fn example() { +/// let _ = log_debug("This is a debug message", "example").await; +/// } +/// ``` +pub async fn log_debug(message: &str, source: &str) -> Result<(), LogError> { + get_global_logger().lock().await.write(message, source, Level::DEBUG).await +} + +/// Log trace +/// This function logs trace messages. +/// # Parameters +/// - `message`: Message to be logged +/// - `source`: Source of the log +/// +/// # Returns +/// Result indicating whether the operation was successful +/// +/// # Example +/// ``` +/// use rustfs_obs::log_trace; +/// +/// async fn example() { +/// let _ = log_trace("This is a trace message", "example").await; +/// } +/// ``` +pub async fn log_trace(message: &str, source: &str) -> Result<(), LogError> { + get_global_logger().lock().await.write(message, source, Level::TRACE).await +} + +/// Log with context information +/// This function logs messages with context information. +/// # Parameters +/// - `message`: Message to be logged +/// - `source`: Source of the log +/// - `level`: Log level +/// - `target`: Log target +/// - `request_id`: Request ID +/// - `user_id`: User ID +/// - `fields`: Additional fields +/// # Returns +/// Result indicating whether the operation was successful +/// # Example +/// ``` +/// use tracing_core::Level; +/// use rustfs_obs::log_with_context; +/// +/// async fn example() { +/// let _ = log_with_context("This is an information message", "example", Level::INFO, Some("target".to_string()), Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await; +/// } +/// ``` +pub async fn log_with_context( + message: &str, + source: &str, + level: Level, + target: Option, + request_id: Option, + user_id: Option, + fields: Vec<(String, String)>, +) -> Result<(), LogError> { + get_global_logger() + .lock() + .await + .write_with_context(message, source, level, target, request_id, user_id, fields) + .await +} diff --git a/packages/obs/src/sink.rs b/packages/obs/src/sink.rs index 37785cfba..2363a69dd 100644 --- a/packages/obs/src/sink.rs +++ b/packages/obs/src/sink.rs @@ -258,10 +258,10 @@ impl FileSink { buffer_size: usize, flush_interval_ms: u64, flush_threshold: usize, - ) -> Result { + ) -> Result { let file = OpenOptions::new().append(true).create(true).open(&path).await?; - let writer = tokio::io::BufWriter::with_capacity(buffer_size, file); + let writer = io::BufWriter::with_capacity(buffer_size, file); let now = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap() @@ -421,11 +421,10 @@ pub fn create_sinks(config: &AppConfig) -> Vec> { // Use synchronous file operations let file_result = std::fs::OpenOptions::new().append(true).create(true).open(&path); - match file_result { Ok(file) => { let buffer_size = config.sinks.file.buffer_size.unwrap_or(8192); - let writer = tokio::io::BufWriter::with_capacity(buffer_size, tokio::fs::File::from_std(file)); + let writer = io::BufWriter::with_capacity(buffer_size, tokio::fs::File::from_std(file)); let now = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index fb1111303..cafe5badc 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -13,6 +13,8 @@ use opentelemetry_semantic_conventions::{ attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_NAME, SERVICE_VERSION}, SCHEMA_URL, }; +use std::io::IsTerminal; +use tracing_error::ErrorLayer; use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer}; @@ -155,63 +157,72 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { let meter_provider = init_meter_provider(config); let tracer = tracer_provider.tracer(config.service_name.clone()); - let logger_provider = if config.endpoint.is_empty() { - SdkLoggerProvider::builder() - .with_resource(resource(config)) - .with_simple_exporter(opentelemetry_stdout::LogExporter::default()) - .build() - } else { - let exporter = opentelemetry_otlp::LogExporter::builder() - .with_tonic() - .with_endpoint(&config.endpoint) - .build() - .unwrap(); - SdkLoggerProvider::builder() - .with_resource(resource(config)) - .with_batch_exporter(exporter) - .with_batch_exporter(opentelemetry_stdout::LogExporter::default()) - .build() + // Initialize logger provider based on configuration + let logger_provider = { + let mut builder = SdkLoggerProvider::builder().with_resource(resource(config)); + + if config.endpoint.is_empty() { + // Use stdout exporter when no endpoint is configured + builder = builder.with_simple_exporter(opentelemetry_stdout::LogExporter::default()); + } else { + // Configure OTLP exporter when endpoint is provided + let exporter = opentelemetry_otlp::LogExporter::builder() + .with_tonic() + .with_endpoint(&config.endpoint) + .build() + .unwrap(); + + builder = builder.with_batch_exporter(exporter); + + // Add stdout exporter if requested + if config.use_stdout { + builder = builder.with_batch_exporter(opentelemetry_stdout::LogExporter::default()); + } + } + + builder.build() }; - let otel_layer = layer::OpenTelemetryTracingBridge::new(&logger_provider); - // For the OpenTelemetry layer, add a tracing filter to filter events from - // OpenTelemetry and its dependent crates (opentelemetry-otlp uses crates - // like reqwest/tonic etc.) from being sent back to OTel itself, thus - // preventing infinite telemetry generation. The filter levels are set as - // follows: - // - Allow `info` level and above by default. - // - Restrict `opentelemetry`, `hyper`, `tonic`, and `reqwest` completely. - // Note: This will also drop events from crates like `tonic` etc. even when - // they are used outside the OTLP Exporter. For more details, see: - // https://github.com/open-telemetry/opentelemetry-rust/issues/761 - let filter_otel = EnvFilter::new("info") - .add_directive("hyper=off".parse().unwrap()) - .add_directive("opentelemetry=off".parse().unwrap()) - .add_directive("tonic=off".parse().unwrap()) - .add_directive("h2=off".parse().unwrap()) - .add_directive("reqwest=off".parse().unwrap()); - let otel_layer = otel_layer.with_filter(filter_otel); + // Setup OpenTelemetryTracingBridge layer + let otel_layer = { + // Filter to prevent infinite telemetry loops + // This blocks events from OpenTelemetry and its dependent libraries (tonic, reqwest, etc.) + // from being sent back to OpenTelemetry itself + let filter_otel = EnvFilter::new("info") + .add_directive("hyper=off".parse().unwrap()) + .add_directive("opentelemetry=off".parse().unwrap()) + .add_directive("tonic=off".parse().unwrap()) + .add_directive("h2=off".parse().unwrap()) + .add_directive("reqwest=off".parse().unwrap()); + + layer::OpenTelemetryTracingBridge::new(&logger_provider).with_filter(filter_otel) + }; let registry = tracing_subscriber::registry() .with(tracing_subscriber::filter::LevelFilter::INFO) .with(OpenTelemetryLayer::new(tracer)) .with(MetricsLayer::new(meter_provider.clone())) .with(otel_layer); - if config.endpoint.is_empty() { - // Create a new tracing::Fmt layer to print the logs to stdout. It has a - // default filter of `info` level and above, and `debug` and above for logs - // from OpenTelemetry crates. The filter levels can be customized as needed. - let filter_fmt = EnvFilter::new("info").add_directive("opentelemetry=debug".parse().unwrap()); - let fmt_layer = tracing_subscriber::fmt::layer() - .with_thread_names(true) - .with_filter(filter_fmt); + // Configure formatting layer + let enable_color = std::io::stdout().is_terminal(); + let fmt_layer = tracing_subscriber::fmt::layer() + .with_ansi(enable_color) + .with_thread_names(true) + .with_file(true) + .with_line_number(true); - registry - .with(tracing_subscriber::fmt::layer().with_ansi(true)) - .with(fmt_layer) - .init(); + // Creating a formatting layer with explicit type to avoid type mismatches + let fmt_layer = if config.endpoint.is_empty() { + // Local debug mode: add filter to show OpenTelemetry debug logs + let filter_fmt = EnvFilter::new("info").add_directive("opentelemetry=debug".parse().unwrap()); + fmt_layer.with_filter(filter_fmt) } else { - registry.with(tracing_subscriber::fmt::layer().with_ansi(false)).init(); - println!("Logs and meter,tracer enabled"); + // Production mode: use default filter settings + fmt_layer.with_filter(EnvFilter::new("info").add_directive("opentelemetry=off".parse().unwrap())) + }; + + registry.with(ErrorLayer::default()).with(fmt_layer).init(); + if !config.endpoint.is_empty() { + tracing::info!("OpenTelemetry telemetry initialized with OTLP endpoint: {}", config.endpoint); } OtelGuard { diff --git a/packages/obs/src/worker.rs b/packages/obs/src/worker.rs index a04327945..1c40f47f5 100644 --- a/packages/obs/src/worker.rs +++ b/packages/obs/src/worker.rs @@ -1,4 +1,4 @@ -use crate::{entry::LogEntry, sink::Sink}; +use crate::{entry::log::LogEntry, sink::Sink}; use std::sync::Arc; use tokio::sync::mpsc::Receiver; diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index a39e121ee..b87b16ca3 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -35,6 +35,7 @@ use hyper_util::{ }; use iam::init_iam_sys; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; +use rustfs_obs::{init_obs, load_config}; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; use std::{io::IsTerminal, net::SocketAddr}; @@ -45,6 +46,7 @@ use tracing::{debug, error, info, warn}; use tracing_error::ErrorLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; +#[allow(dead_code)] fn setup_tracing() { use tracing_subscriber::EnvFilter; @@ -89,8 +91,10 @@ fn main() -> Result<()> { let opt = config::Opt::parse(); //设置 trace - setup_tracing(); - + // setup_tracing(); + let config = load_config(Some("packages/obs/examples/config".to_string())); + // Initialize the logger asynchronously + let (_logger, _guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); //运行参数 run(opt) } From bcdd204fa0ff4ec7e7809fc76882b82ccb0fc01f Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 17 Mar 2025 21:37:47 +0800 Subject: [PATCH 009/103] improve log struct --- packages/obs/examples/config.toml | 2 +- packages/obs/src/entry/audit.rs | 382 +++++++++++++++++++++++++++-- packages/obs/src/entry/base.rs | 390 +++++++++++++++++++++++++++++- packages/obs/src/entry/mod.rs | 2 +- packages/obs/src/lib.rs | 2 + 5 files changed, 756 insertions(+), 22 deletions(-) diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml index 2ceac4397..ddf376352 100644 --- a/packages/obs/examples/config.toml +++ b/packages/obs/examples/config.toml @@ -1,6 +1,6 @@ [observability] endpoint = "http://localhost:4317" -use_stdout = true +use_stdout = false sample_ratio = 0.5 meter_interval = 30 service_name = "rustfs_obs_service" diff --git a/packages/obs/src/entry/audit.rs b/packages/obs/src/entry/audit.rs index 4e5099857..8f8b1e34f 100644 --- a/packages/obs/src/entry/audit.rs +++ b/packages/obs/src/entry/audit.rs @@ -1,19 +1,11 @@ +use crate::ObjectVersion; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -/// ObjectVersion object version key/versionId -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ObjectVersion { - #[serde(rename = "objectName")] - pub object_name: String, - #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] - pub version_id: Option, -} - /// API details structure -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct ApiDetails { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -43,8 +35,107 @@ pub struct ApiDetails { pub time_to_response_in_ns: Option, } +impl ApiDetails { + /// Create a new `ApiDetails` with default values + pub fn new() -> Self { + ApiDetails { + name: None, + bucket: None, + object: None, + objects: Vec::new(), + status: None, + status_code: None, + input_bytes: 0, + output_bytes: 0, + header_bytes: None, + time_to_first_byte: None, + time_to_first_byte_in_ns: None, + time_to_response: None, + time_to_response_in_ns: None, + } + } + + /// Set the name + pub fn set_name(mut self, name: Option) -> Self { + self.name = name; + self + } + + /// Set the bucket + pub fn set_bucket(mut self, bucket: Option) -> Self { + self.bucket = bucket; + self + } + + /// Set the object + pub fn set_object(mut self, object: Option) -> Self { + self.object = object; + self + } + + /// Set the objects + pub fn set_objects(mut self, objects: Vec) -> Self { + self.objects = objects; + self + } + + /// Set the status + pub fn set_status(mut self, status: Option) -> Self { + self.status = status; + self + } + + /// Set the status code + pub fn set_status_code(mut self, status_code: Option) -> Self { + self.status_code = status_code; + self + } + + /// Set the input bytes + pub fn set_input_bytes(mut self, input_bytes: i64) -> Self { + self.input_bytes = input_bytes; + self + } + + /// Set the output bytes + pub fn set_output_bytes(mut self, output_bytes: i64) -> Self { + self.output_bytes = output_bytes; + self + } + + /// Set the header bytes + pub fn set_header_bytes(mut self, header_bytes: Option) -> Self { + self.header_bytes = header_bytes; + self + } + + /// Set the time to first byte + pub fn set_time_to_first_byte(mut self, time_to_first_byte: Option) -> Self { + self.time_to_first_byte = time_to_first_byte; + self + } + + /// Set the time to first byte in nanoseconds + pub fn set_time_to_first_byte_in_ns(mut self, time_to_first_byte_in_ns: Option) -> Self { + self.time_to_first_byte_in_ns = time_to_first_byte_in_ns; + self + } + + /// Set the time to response + pub fn set_time_to_response(mut self, time_to_response: Option) -> Self { + self.time_to_response = time_to_response; + self + } + + /// Set the time to response in nanoseconds + pub fn set_time_to_response_in_ns(mut self, time_to_response_in_ns: Option) -> Self { + self.time_to_response_in_ns = time_to_response_in_ns; + self + } +} + /// Entry - audit entry logs -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, Default)] pub struct AuditEntry { pub version: String, #[serde(rename = "deploymentid", skip_serializing_if = "Option::is_none")] @@ -55,9 +146,6 @@ pub struct AuditEntry { // Class of audit message - S3, admin ops, bucket management #[serde(rename = "type", skip_serializing_if = "Option::is_none")] pub entry_type: Option, - - // Deprecated, replaced by 'Event' - pub trigger: String, pub api: ApiDetails, #[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")] pub remote_host: Option, @@ -86,3 +174,269 @@ pub struct AuditEntry { #[serde(rename = "error", skip_serializing_if = "Option::is_none")] pub error: Option, } + +impl AuditEntry { + /// Create a new `AuditEntry` with default values + pub fn new() -> Self { + AuditEntry { + version: String::new(), + deployment_id: None, + time: Utc::now(), + event: String::new(), + entry_type: None, + api: ApiDetails::new(), + remote_host: None, + request_id: None, + user_agent: None, + req_path: None, + req_host: None, + req_claims: None, + req_query: None, + req_header: None, + resp_header: None, + tags: None, + access_key: None, + parent_user: None, + error: None, + } + } + + /// Create a new `AuditEntry` with version and time event and api details + /// # Arguments + /// * `version` - Version of the audit entry + /// * `time` - Time of the audit entry + /// * `event` - Event of the audit entry + /// * `api` - API details of the audit entry + /// # Returns + /// * `AuditEntry` with the given values + /// # Example + /// ``` + /// use chrono::Utc; + /// use rustfs_obs::{ApiDetails, AuditEntry}; + /// let entry = AuditEntry::new_with_values( + /// "v1".to_string(), + /// Utc::now(), + /// "event".to_string(), + /// ApiDetails::new(), + /// ); + /// ``` + /// # Remarks + /// This is a convenience method to create an `AuditEntry` with the given values + /// without having to set each field individually + /// This is useful when you want to create an `AuditEntry` with the given values + /// without having to set each field individually + pub fn new_with_values(version: String, time: DateTime, event: String, api: ApiDetails) -> Self { + AuditEntry { + version, + deployment_id: None, + time, + event, + entry_type: None, + api, + remote_host: None, + request_id: None, + user_agent: None, + req_path: None, + req_host: None, + req_claims: None, + req_query: None, + req_header: None, + resp_header: None, + tags: None, + access_key: None, + parent_user: None, + error: None, + } + } + + /// Set the version + pub fn set_version(mut self, version: String) -> Self { + self.version = version; + self + } + + /// Set the deployment ID + pub fn set_deployment_id(mut self, deployment_id: Option) -> Self { + self.deployment_id = deployment_id; + self + } + + /// Set the time + pub fn set_time(mut self, time: DateTime) -> Self { + self.time = time; + self + } + + /// Set the event + pub fn set_event(mut self, event: String) -> Self { + self.event = event; + self + } + + /// Set the entry type + pub fn set_entry_type(mut self, entry_type: Option) -> Self { + self.entry_type = entry_type; + self + } + + /// Set the API details + pub fn set_api(mut self, api: ApiDetails) -> Self { + self.api = api; + self + } + + /// Set the remote host + pub fn set_remote_host(mut self, remote_host: Option) -> Self { + self.remote_host = remote_host; + self + } + + /// Set the request ID + pub fn set_request_id(mut self, request_id: Option) -> Self { + self.request_id = request_id; + self + } + + /// Set the user agent + pub fn set_user_agent(mut self, user_agent: Option) -> Self { + self.user_agent = user_agent; + self + } + + /// Set the request path + pub fn set_req_path(mut self, req_path: Option) -> Self { + self.req_path = req_path; + self + } + + /// Set the request host + pub fn set_req_host(mut self, req_host: Option) -> Self { + self.req_host = req_host; + self + } + + /// Set the request claims + pub fn set_req_claims(mut self, req_claims: Option>) -> Self { + self.req_claims = req_claims; + self + } + + /// Set the request query + pub fn set_req_query(mut self, req_query: Option>) -> Self { + self.req_query = req_query; + self + } + + /// Set the request header + pub fn set_req_header(mut self, req_header: Option>) -> Self { + self.req_header = req_header; + self + } + + /// Set the response header + pub fn set_resp_header(mut self, resp_header: Option>) -> Self { + self.resp_header = resp_header; + self + } + + /// Set the tags + pub fn set_tags(mut self, tags: Option>) -> Self { + self.tags = tags; + self + } + + /// Set the access key + pub fn set_access_key(mut self, access_key: Option) -> Self { + self.access_key = access_key; + self + } + + /// Set the parent user + pub fn set_parent_user(mut self, parent_user: Option) -> Self { + self.parent_user = parent_user; + self + } + + /// Set the error + pub fn set_error(mut self, error: Option) -> Self { + self.error = error; + self + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_audit_entry() { + let entry = AuditEntry::new() + .set_version("v1".to_string()) + .set_deployment_id(Some("12345".to_string())) + .set_time(Utc::now()) + .set_event("event".to_string()) + .set_entry_type(Some("type".to_string())) + .set_api(ApiDetails::new()) + .set_remote_host(Some("localhost".to_string())) + .set_request_id(Some("req-12345".to_string())) + .set_user_agent(Some("user-agent".to_string())) + .set_req_path(Some("/path".to_string())) + .set_req_host(Some("localhost".to_string())) + .set_req_claims(Some(HashMap::new())) + .set_req_query(Some(HashMap::new())) + .set_req_header(Some(HashMap::new())) + .set_resp_header(Some(HashMap::new())) + .set_tags(Some(HashMap::new())) + .set_access_key(Some("access-key".to_string())) + .set_parent_user(Some("parent-user".to_string())) + .set_error(Some("error".to_string())); + + assert_eq!(entry.version, "v1"); + assert_eq!(entry.deployment_id, Some("12345".to_string())); + assert_eq!(entry.event, "event"); + assert_eq!(entry.entry_type, Some("type".to_string())); + assert_eq!(entry.remote_host, Some("localhost".to_string())); + assert_eq!(entry.request_id, Some("req-12345".to_string())); + assert_eq!(entry.user_agent, Some("user-agent".to_string())); + assert_eq!(entry.req_path, Some("/path".to_string())); + assert_eq!(entry.req_host, Some("localhost".to_string())); + assert_eq!(entry.access_key, Some("access-key".to_string())); + assert_eq!(entry.parent_user, Some("parent-user".to_string())); + assert_eq!(entry.error, Some("error".to_string())); + } + + #[test] + fn test_api_details() { + let api = ApiDetails::new() + .set_name(Some("name".to_string())) + .set_bucket(Some("bucket".to_string())) + .set_object(Some("object".to_string())) + .set_objects(vec![ObjectVersion { + object_name: "object".to_string(), + version_id: Some("12345".to_string()), + }]) + .set_status(Some("status".to_string())) + .set_status_code(Some(200)) + .set_input_bytes(100) + .set_output_bytes(200) + .set_header_bytes(Some(300)) + .set_time_to_first_byte(Some("100ms".to_string())) + .set_time_to_first_byte_in_ns(Some("100ns".to_string())) + .set_time_to_response(Some("200ms".to_string())) + .set_time_to_response_in_ns(Some("200ns".to_string())); + + assert_eq!(api.name, Some("name".to_string())); + assert_eq!(api.bucket, Some("bucket".to_string())); + assert_eq!(api.object, Some("object".to_string())); + assert_eq!(api.objects.len(), 1); + assert_eq!(api.status, Some("status".to_string())); + assert_eq!(api.status_code, Some(200)); + assert_eq!(api.input_bytes, 100); + assert_eq!(api.output_bytes, 200); + assert_eq!(api.header_bytes, Some(300)); + assert_eq!(api.time_to_first_byte, Some("100ms".to_string())); + assert_eq!(api.time_to_first_byte_in_ns, Some("100ns".to_string())); + assert_eq!(api.time_to_response, Some("200ms".to_string())); + assert_eq!(api.time_to_response_in_ns, Some("200ns".to_string())); + } +} diff --git a/packages/obs/src/entry/base.rs b/packages/obs/src/entry/base.rs index aa9d22ab7..c629c74d8 100644 --- a/packages/obs/src/entry/base.rs +++ b/packages/obs/src/entry/base.rs @@ -4,7 +4,7 @@ use serde_json::Value; use std::collections::HashMap; /// ObjectVersion object version key/versionId -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Default)] pub struct ObjectVersion { #[serde(rename = "objectName")] pub object_name: String, @@ -12,8 +12,37 @@ pub struct ObjectVersion { pub version_id: Option, } +impl ObjectVersion { + /// Create a new ObjectVersion object + pub fn new() -> Self { + ObjectVersion { + object_name: String::new(), + version_id: None, + } + } + + /// Create a new ObjectVersion object with object name + pub fn new_with_object_name(object_name: String) -> Self { + ObjectVersion { + object_name, + version_id: None, + } + } + /// Set the object name + pub fn set_object_name(mut self, object_name: String) -> Self { + self.object_name = object_name; + self + } + + /// Set the version ID + pub fn set_version_id(mut self, version_id: Option) -> Self { + self.version_id = version_id; + self + } +} + /// Args - defines the arguments for the API -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub struct Args { #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] pub bucket: Option, @@ -27,8 +56,51 @@ pub struct Args { pub metadata: Option>, } +impl Args { + /// Create a new Args object + pub fn new() -> Self { + Args { + bucket: None, + object: None, + version_id: None, + objects: None, + metadata: None, + } + } + + /// Set the bucket + pub fn set_bucket(mut self, bucket: Option) -> Self { + self.bucket = bucket; + self + } + + /// Set the object + pub fn set_object(mut self, object: Option) -> Self { + self.object = object; + self + } + + /// Set the version ID + pub fn set_version_id(mut self, version_id: Option) -> Self { + self.version_id = version_id; + self + } + + /// Set the objects + pub fn set_objects(mut self, objects: Option>) -> Self { + self.objects = objects; + self + } + + /// Set the metadata + pub fn set_metadata(mut self, metadata: Option>) -> Self { + self.metadata = metadata; + self + } +} + /// Trace - defines the trace -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub struct Trace { #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, @@ -38,8 +110,37 @@ pub struct Trace { pub variables: Option>, } +impl Trace { + /// Create a new Trace object + pub fn new() -> Self { + Trace { + message: None, + source: None, + variables: None, + } + } + + /// Set the message + pub fn set_message(mut self, message: Option) -> Self { + self.message = message; + self + } + + /// Set the source + pub fn set_source(mut self, source: Option>) -> Self { + self.source = source; + self + } + + /// Set the variables + pub fn set_variables(mut self, variables: Option>) -> Self { + self.variables = variables; + self + } +} + /// API - defines the api type and its args -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub struct API { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -47,8 +148,27 @@ pub struct API { pub args: Option, } +impl API { + /// Create a new API object + pub fn new() -> Self { + API { name: None, args: None } + } + + /// Set the name + pub fn set_name(mut self, name: Option) -> Self { + self.name = name; + self + } + + /// Set the args + pub fn set_args(mut self, args: Option) -> Self { + self.args = args; + self + } +} + /// Log kind/level enum -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum LogKind { #[serde(rename = "INFO")] Info, @@ -60,8 +180,14 @@ pub enum LogKind { Fatal, } +impl Default for LogKind { + fn default() -> Self { + LogKind::Info + } +} + /// Entry - defines fields and values of each log entry -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub struct Entry { #[serde(rename = "site", skip_serializing_if = "Option::is_none")] pub site: Option, @@ -98,6 +224,98 @@ pub struct Entry { pub trace: Option, } +impl Entry { + /// Create a new Entry object with default values + pub fn new() -> Self { + Entry { + site: None, + deployment_id: None, + level: LogKind::Info, + log_kind: None, + time: Utc::now(), + api: None, + remote_host: None, + host: None, + request_id: None, + user_agent: None, + message: None, + trace: None, + } + } + + /// Set the site + pub fn set_site(mut self, site: Option) -> Self { + self.site = site; + self + } + + /// Set the deployment ID + pub fn set_deployment_id(mut self, deployment_id: Option) -> Self { + self.deployment_id = deployment_id; + self + } + + /// Set the level + pub fn set_level(mut self, level: LogKind) -> Self { + self.level = level; + self + } + + /// Set the log kind + pub fn set_log_kind(mut self, log_kind: Option) -> Self { + self.log_kind = log_kind; + self + } + + /// Set the time + pub fn set_time(mut self, time: DateTime) -> Self { + self.time = time; + self + } + + /// Set the API + pub fn set_api(mut self, api: Option) -> Self { + self.api = api; + self + } + + /// Set the remote host + pub fn set_remote_host(mut self, remote_host: Option) -> Self { + self.remote_host = remote_host; + self + } + + /// Set the host + pub fn set_host(mut self, host: Option) -> Self { + self.host = host; + self + } + + /// Set the request ID + pub fn set_request_id(mut self, request_id: Option) -> Self { + self.request_id = request_id; + self + } + + /// Set the user agent + pub fn set_user_agent(mut self, user_agent: Option) -> Self { + self.user_agent = user_agent; + self + } + + /// Set the message + pub fn set_message(mut self, message: Option) -> Self { + self.message = message; + self + } + + /// Set the trace + pub fn set_trace(mut self, trace: Option) -> Self { + self.trace = trace; + self + } +} + /// Info holds console log messages #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Info { @@ -112,3 +330,163 @@ pub struct Info { #[serde(skip)] pub err: Option, } + +impl Info { + /// Create a new Info object with default values + pub fn new() -> Self { + Info { + entry: Entry::new(), + console_msg: String::new(), + node_name: String::new(), + err: None, + } + } + + /// Create a new Info object with console message and node name + pub fn new_with_console_msg(console_msg: String, node_name: String) -> Self { + Info { + entry: Entry::new(), + console_msg, + node_name, + err: None, + } + } + + /// Set the node name + pub fn set_node_name(&mut self, node_name: String) { + self.node_name = node_name; + } + + /// Set the entry + pub fn set_entry(&mut self, entry: Entry) { + self.entry = entry; + } + + /// Set the console message + pub fn set_console_msg(&mut self, console_msg: String) { + self.console_msg = console_msg; + } + + /// Set the error message + pub fn set_err(&mut self, err: Option) { + self.err = err; + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_object_version() { + let mut object_version = ObjectVersion::new(); + object_version = object_version.clone().set_object_name("object".to_string()); + object_version = object_version.clone().set_version_id(Some("version".to_string())); + assert_eq!(object_version.object_name, "object".to_string()); + assert_eq!(object_version.version_id, Some("version".to_string())); + } + + #[test] + fn test_object_version_with_object_name() { + let object_version = ObjectVersion::new_with_object_name("object".to_string()); + assert_eq!(object_version.object_name, "object".to_string()); + assert_eq!(object_version.version_id, None); + } + + #[test] + fn test_args() { + let mut obj = ObjectVersion::new(); + obj.object_name = "object".to_string(); + obj.version_id = Some("version".to_string()); + let objs = vec![obj]; + let args = Args::new() + .set_bucket(Some("bucket".to_string())) + .set_object(Some("object".to_string())) + .set_version_id(Some("version".to_string())) + .set_objects(Some(objs.clone())) + .set_metadata(Some(HashMap::new())); + + assert_eq!(args.bucket, Some("bucket".to_string())); + assert_eq!(args.object, Some("object".to_string())); + assert_eq!(args.version_id, Some("version".to_string())); + assert_eq!(args.objects, Some(objs)); + assert_eq!(args.metadata, Some(HashMap::new())); + } + + #[test] + fn test_trace() { + let trace = Trace::new() + .set_message(Some("message".to_string())) + .set_source(Some(vec!["source".to_string()])) + .set_variables(Some(HashMap::new())); + + assert_eq!(trace.message, Some("message".to_string())); + assert_eq!(trace.source, Some(vec!["source".to_string()])); + assert_eq!(trace.variables, Some(HashMap::new())); + } + + #[test] + fn test_api() { + let api = API::new().set_name(Some("name".to_string())).set_args(Some(Args::new())); + + assert_eq!(api.name, Some("name".to_string())); + assert_eq!(api.args, Some(Args::new())); + } + + #[test] + fn test_log_kind() { + assert_eq!(LogKind::default(), LogKind::Info); + } + + #[test] + fn test_entry() { + let entry = Entry::new() + .set_site(Some("site".to_string())) + .set_deployment_id(Some("deployment_id".to_string())) + .set_level(LogKind::Info) + .set_log_kind(Some(LogKind::Info)) + .set_time(Utc::now()) + .set_api(Some(API::new())) + .set_remote_host(Some("remote_host".to_string())) + .set_host(Some("host".to_string())) + .set_request_id(Some("request_id".to_string())) + .set_user_agent(Some("user_agent".to_string())) + .set_message(Some("message".to_string())) + .set_trace(Some(Trace::new())); + + assert_eq!(entry.site, Some("site".to_string())); + assert_eq!(entry.deployment_id, Some("deployment_id".to_string())); + assert_eq!(entry.level, LogKind::Info); + assert_eq!(entry.log_kind, Some(LogKind::Info)); + assert_eq!(entry.api, Some(API::new())); + assert_eq!(entry.remote_host, Some("remote_host".to_string())); + assert_eq!(entry.host, Some("host".to_string())); + assert_eq!(entry.request_id, Some("request_id".to_string())); + assert_eq!(entry.user_agent, Some("user_agent".to_string())); + assert_eq!(entry.message, Some("message".to_string())); + assert_eq!(entry.trace, Some(Trace::new())); + } + + #[test] + fn test_info() { + let mut info = Info::new(); + info.set_node_name("node_name".to_string()); + info.set_entry(Entry::new()); + info.set_console_msg("console_msg".to_string()); + info.set_err(Some("err".to_string())); + + assert_eq!(info.node_name, "node_name".to_string()); + // assert_eq!(info.entry, Entry::new()); + assert_eq!(info.console_msg, "console_msg".to_string()); + assert_eq!(info.err, Some("err".to_string())); + } + + #[test] + fn test_info_with_console_msg() { + let info = Info::new_with_console_msg("console_msg".to_string(), "node_name".to_string()); + + assert_eq!(info.node_name, "node_name".to_string()); + assert_eq!(info.console_msg, "console_msg".to_string()); + assert_eq!(info.err, None); + } +} diff --git a/packages/obs/src/entry/mod.rs b/packages/obs/src/entry/mod.rs index efc697e01..51ba15848 100644 --- a/packages/obs/src/entry/mod.rs +++ b/packages/obs/src/entry/mod.rs @@ -1,3 +1,3 @@ pub(crate) mod audit; -mod base; +pub(crate) mod base; pub(crate) mod log; diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index 079d9abfc..8d00c7b09 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -13,6 +13,8 @@ mod worker; pub use config::load_config; pub use config::{AppConfig, OtelConfig}; +pub use entry::audit::{ApiDetails, AuditEntry}; +pub use entry::base::{Args, Entry, Info, LogKind, ObjectVersion, Trace, API}; pub use entry::log::{LogEntry, SerializableLevel}; pub use logger::start_logger; pub use logger::{ From c3ecfeae6cd8a6ea2a3998122e30df513e7523f3 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 18 Mar 2025 16:36:23 +0800 Subject: [PATCH 010/103] improve logger entry for Observability --- .docker/observability/README.md | 0 .docker/observability/docker-compose.yml | 65 +++ .docker/observability/jaeger-config.yaml | 88 +++ .docker/observability/loki-config.yaml | 63 +++ .../observability/otel-collector-config.yaml | 57 ++ .docker/observability/prometheus.yml | 11 + config/obs.example.toml | 31 ++ packages/obs/examples/server.rs | 30 +- packages/obs/src/config.rs | 65 ++- packages/obs/src/entry/args.rs | 74 +++ packages/obs/src/entry/audit.rs | 275 ++++----- packages/obs/src/entry/base.rs | 526 +++--------------- packages/obs/src/entry/log.rs | 83 --- packages/obs/src/entry/mod.rs | 142 ++++- packages/obs/src/entry/unified.rs | 279 ++++++++++ packages/obs/src/lib.rs | 32 +- packages/obs/src/logger.rs | 177 +++--- packages/obs/src/sink.rs | 27 +- packages/obs/src/worker.rs | 4 +- 19 files changed, 1208 insertions(+), 821 deletions(-) create mode 100644 .docker/observability/README.md create mode 100644 .docker/observability/docker-compose.yml create mode 100644 .docker/observability/jaeger-config.yaml create mode 100644 .docker/observability/loki-config.yaml create mode 100644 .docker/observability/otel-collector-config.yaml create mode 100644 .docker/observability/prometheus.yml create mode 100644 config/obs.example.toml create mode 100644 packages/obs/src/entry/args.rs delete mode 100644 packages/obs/src/entry/log.rs create mode 100644 packages/obs/src/entry/unified.rs diff --git a/.docker/observability/README.md b/.docker/observability/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/.docker/observability/docker-compose.yml b/.docker/observability/docker-compose.yml new file mode 100644 index 000000000..d6bd19323 --- /dev/null +++ b/.docker/observability/docker-compose.yml @@ -0,0 +1,65 @@ +services: + otel-collector: + image: otel/opentelemetry-collector-contrib:0.120.0 + environment: + - TZ=Asia/Shanghai + volumes: + - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml + ports: + - 1888:1888 + - 8888:8888 + - 8889:8889 + - 13133:13133 + - 4317:4317 + - 4318:4318 + - 55679:55679 + networks: + - otel-network + jaeger: + image: jaegertracing/jaeger:2.3.0 + environment: + - TZ=Asia/Shanghai + ports: + - "16686:16686" + - "14317:4317" + - "14318:4318" + networks: + - otel-network + prometheus: + image: prom/prometheus:v3.2.0 + environment: + - TZ=Asia/Shanghai + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + ports: + - "9090:9090" + networks: + - otel-network + loki: + image: grafana/loki:3.4.2 + environment: + - TZ=Asia/Shanghai + volumes: + - ./loki-config.yaml:/etc/loki/local-config.yaml + ports: + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml + networks: + - otel-network + grafana: + image: grafana/grafana:11.5.2 + ports: + - "3000:3000" # Web UI + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + - TZ=Asia/Shanghai + networks: + - otel-network + + +networks: + otel-network: + driver: bridge + name: "network_otel_config" + driver_opts: + com.docker.network.enable_ipv6: "true" diff --git a/.docker/observability/jaeger-config.yaml b/.docker/observability/jaeger-config.yaml new file mode 100644 index 000000000..31b5a9d6d --- /dev/null +++ b/.docker/observability/jaeger-config.yaml @@ -0,0 +1,88 @@ + +service: + extensions: [jaeger_storage, jaeger_query, remote_sampling, healthcheckv2] + pipelines: + traces: + receivers: [otlp, jaeger, zipkin] + processors: [batch, adaptive_sampling] + exporters: [jaeger_storage_exporter] + telemetry: + resource: + service.name: jaeger + metrics: + level: detailed + readers: + - pull: + exporter: + prometheus: + host: 0.0.0.0 + port: 8888 + logs: + level: debug + # TODO Initialize telemetry tracer once OTEL released new feature. + # https://github.com/open-telemetry/opentelemetry-collector/issues/10663 + +extensions: + healthcheckv2: + use_v2: true + http: + + # pprof: + # endpoint: 0.0.0.0:1777 + # zpages: + # endpoint: 0.0.0.0:55679 + + jaeger_query: + storage: + traces: some_store + traces_archive: another_store + ui: + config_file: ./cmd/jaeger/config-ui.json + # The maximum duration that is considered for clock skew adjustments. + # Defaults to 0 seconds, which means it's disabled. + max_clock_skew_adjust: 0s + + jaeger_storage: + backends: + some_store: + memory: + max_traces: 100000 + another_store: + memory: + max_traces: 100000 + + remote_sampling: + # You can either use file or adaptive sampling strategy in remote_sampling + # file: + # path: ./cmd/jaeger/sampling-strategies.json + adaptive: + sampling_store: some_store + initial_sampling_probability: 0.1 + http: + grpc: + +receivers: + otlp: + protocols: + grpc: + http: + + jaeger: + protocols: + grpc: + thrift_binary: + thrift_compact: + thrift_http: + + zipkin: + +processors: + batch: + # Adaptive Sampling Processor is required to support adaptive sampling. + # It expects remote_sampling extension with `adaptive:` config to be enabled. + adaptive_sampling: + +exporters: + jaeger_storage_exporter: + trace_storage: some_store + diff --git a/.docker/observability/loki-config.yaml b/.docker/observability/loki-config.yaml new file mode 100644 index 000000000..4aff8772a --- /dev/null +++ b/.docker/observability/loki-config.yaml @@ -0,0 +1,63 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + grpc_listen_port: 9096 + log_level: debug + grpc_server_max_concurrent_streams: 1000 + +common: + instance_addr: 127.0.0.1 + path_prefix: /tmp/loki + storage: + filesystem: + chunks_directory: /tmp/loki/chunks + rules_directory: /tmp/loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +query_range: + results_cache: + cache: + embedded_cache: + enabled: true + max_size_mb: 100 + +limits_config: + metric_aggregation_enabled: true + +schema_config: + configs: + - from: 2020-10-24 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +pattern_ingester: + enabled: true + metric_aggregation: + loki_address: localhost:3100 + +ruler: + alertmanager_url: http://localhost:9093 + +frontend: + encoding: protobuf + +# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration +# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/ +# +# Statistics help us better understand how Loki is used, and they show us performance +# levels for most users. This helps us prioritize features and documentation. +# For more information on what's sent, look at +# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go +# Refer to the buildReport method to see what goes into a report. +# +# If you would like to disable reporting, uncomment the following lines: +#analytics: +# reporting_enabled: false diff --git a/.docker/observability/otel-collector-config.yaml b/.docker/observability/otel-collector-config.yaml new file mode 100644 index 000000000..9e27c4e22 --- /dev/null +++ b/.docker/observability/otel-collector-config.yaml @@ -0,0 +1,57 @@ +receivers: + otlp: + protocols: + grpc: # OTLP gRPC 接收器 + endpoint: 0.0.0.0:4317 + http: # OTLP HTTP 接收器 + endpoint: 0.0.0.0:4318 + +processors: + batch: # 批处理处理器,提升吞吐量 + timeout: 5s + send_batch_size: 1000 + memory_limiter: + check_interval: 1s + limit_mib: 512 + +exporters: + otlp/traces: # OTLP 导出器,用于跟踪数据 + endpoint: "jaeger:4317" # Jaeger 的 OTLP gRPC 端点 + tls: + insecure: true # 开发环境禁用 TLS,生产环境需配置证书 + prometheus: # Prometheus 导出器,用于指标数据 + endpoint: "0.0.0.0:8889" # Prometheus 刮取端点 + namespace: "otel" # 指标前缀 + send_timestamps: true # 发送时间戳 + # enable_open_metrics: true + loki: # Loki 导出器,用于日志数据 + # endpoint: "http://loki:3100/otlp/v1/logs" + endpoint: "http://loki:3100/loki/api/v1/push" + tls: + insecure: true +extensions: + health_check: + pprof: + zpages: +service: + extensions: [health_check, pprof, zpages] # 启用扩展 + pipelines: + traces: + receivers: [otlp] + processors: [memory_limiter,batch] + exporters: [otlp/traces] + metrics: + receivers: [otlp] + processors: [batch] + exporters: [prometheus] + logs: + receivers: [otlp] + processors: [batch] + exporters: [loki] + telemetry: + logs: + level: "info" # Collector 日志级别 + metrics: + address: "0.0.0.0:8888" # Collector 自身指标暴露 + + diff --git a/.docker/observability/prometheus.yml b/.docker/observability/prometheus.yml new file mode 100644 index 000000000..8d3a031ef --- /dev/null +++ b/.docker/observability/prometheus.yml @@ -0,0 +1,11 @@ +global: + scrape_interval: 5s # 刮取间隔 + +scrape_configs: + - job_name: 'otel-collector' + static_configs: + - targets: ['otel-collector:8888'] # 从 Collector 刮取指标 + - job_name: 'otel-metrics' + static_configs: + - targets: ['otel-collector:8889'] # 应用指标 + diff --git a/config/obs.example.toml b/config/obs.example.toml new file mode 100644 index 000000000..59bd0f344 --- /dev/null +++ b/config/obs.example.toml @@ -0,0 +1,31 @@ +[observability] +endpoint = "" # Default is "http://localhost:4317" if not specified +use_stdout = false +sample_ratio = 0.5 +meter_interval = 30 +service_name = "rustfs_obs_service" +service_version = "0.1.0" +deployment_environment = "develop" + +[sinks] +[sinks.kafka] # Kafka sink is disabled by default +enabled = false +bootstrap_servers = "localhost:9092" +topic = "logs" +batch_size = 100 # Default is 100 if not specified +batch_timeout_ms = 1000 # Default is 1000ms if not specified + +[sinks.webhook] +enabled = false +url = "http://localhost:8080/webhook" +batch_size = 100 # Default is 3 if not specified +batch_timeout_ms = 1000 # Default is 100ms if not specified + +[sinks.file] +enabled = true +path = "logs/app.log" +batch_size = 100 +batch_timeout_ms = 1000 # Default is 8192 bytes if not specified + +[logger] +queue_capacity = 10000 \ No newline at end of file diff --git a/packages/obs/examples/server.rs b/packages/obs/examples/server.rs index 60b275de2..2d35c8d4f 100644 --- a/packages/obs/examples/server.rs +++ b/packages/obs/examples/server.rs @@ -1,12 +1,13 @@ use opentelemetry::global; -use rustfs_obs::{get_logger, init_obs, load_config, log_info, LogEntry}; +use rustfs_obs::{get_logger, init_obs, load_config, log_info, ServerLogEntry}; use std::time::{Duration, SystemTime}; use tracing::{info, instrument}; use tracing_core::Level; #[tokio::main] async fn main() { - let config = load_config(Some("packages/obs/examples/config".to_string())); + let obs_conf = Some("packages/obs/examples/config.toml".to_string()); + let config = load_config(obs_conf); let (_logger, _guard) = init_obs(config.clone()).await; // Simulate the operation tokio::time::sleep(Duration::from_millis(100)).await; @@ -33,24 +34,13 @@ async fn run(bucket: String, object: String, user: String, service_name: String) &[opentelemetry::KeyValue::new("operation", "run")], ); - let result = get_logger() - .lock() - .await - .log(LogEntry::new( - Level::INFO, - "Process user requests".to_string(), - "api_handler".to_string(), - Some("demo-audit".to_string()), - Some("req-12345".to_string()), - Some(user), - vec![ - ("endpoint".to_string(), "/api/v1/data".to_string()), - ("method".to_string(), "GET".to_string()), - ("bucket".to_string(), bucket), - ("object-length".to_string(), object.len().to_string()), - ], - )) - .await; + let server_entry = ServerLogEntry::new(Level::INFO, "api_handler".to_string()) + .user_id(Some(user.clone())) + .add_field("operation".to_string(), "login".to_string()) + .add_field("bucket".to_string(), bucket.clone()) + .add_field("object".to_string(), object.clone()); + + let result = get_logger().lock().await.log_server_entry(server_entry).await; info!("Logging is completed {:?}", result); put_object("bucket".to_string(), "object".to_string(), "user".to_string()).await; info!("Logging is completed"); diff --git a/packages/obs/src/config.rs b/packages/obs/src/config.rs index c6e57c421..744c0ec16 100644 --- a/packages/obs/src/config.rs +++ b/packages/obs/src/config.rs @@ -3,6 +3,11 @@ use serde::Deserialize; use std::env; /// OpenTelemetry Configuration +/// Add service name, service version, deployment environment +/// Add interval time for metric collection +/// Add sample ratio for trace sampling +/// Add endpoint for metric collection +/// Add use_stdout for output to stdout #[derive(Debug, Deserialize, Clone, Default)] pub struct OtelConfig { pub endpoint: String, @@ -58,6 +63,19 @@ pub struct LoggerConfig { } /// Overall application configuration +/// Add observability, sinks, and logger configuration +/// +/// Observability: OpenTelemetry configuration +/// Sinks: Kafka, Webhook, File sink configuration +/// Logger: Logger configuration +/// +/// # Example +/// ``` +/// use rustfs_obs::AppConfig; +/// use rustfs_obs::load_config; +/// +/// let config = load_config(None); +/// ``` #[derive(Debug, Deserialize, Clone, Default)] pub struct AppConfig { pub observability: OtelConfig, @@ -65,19 +83,48 @@ pub struct AppConfig { pub logger: LoggerConfig, } +const DEFAULT_CONFIG_FILE: &str = "obs"; + /// Loading the configuration file /// Supports TOML, YAML and .env formats, read in order by priority +/// +/// # Parameters +/// - `config_dir`: Configuration file path +/// +/// # Returns +/// Configuration information +/// +/// # Example +/// ``` +/// use rustfs_obs::AppConfig; +/// use rustfs_obs::load_config; +/// +/// let config = load_config(None); +/// ``` pub fn load_config(config_dir: Option) -> AppConfig { - let config_dir = config_dir.unwrap_or_else(|| { - env::current_dir() - .map(|path| path.to_string_lossy().to_string()) - .unwrap_or_else(|_| { - eprintln!("Warning: Failed to get current directory, using empty path"); - String::new() - }) - }); + let config_dir = if let Some(path) = config_dir { + // Use the provided path + let path = std::path::Path::new(&path); + if path.extension().is_some() { + // If path has extension, use it as is (extension will be added by Config::builder) + path.with_extension("").to_string_lossy().into_owned() + } else { + // If path is a directory, append the default config file name + path.to_string_lossy().into_owned() + } + } else { + // If no path provided, use current directory + default config file + match env::current_dir() { + Ok(dir) => dir.join(DEFAULT_CONFIG_FILE).to_string_lossy().into_owned(), + Err(_) => { + eprintln!("Warning: Failed to get current directory, using default config file"); + DEFAULT_CONFIG_FILE.to_string() + } + } + }; - println!("config_dir: {}", config_dir); + // Log using proper logging instead of println when possible + println!("Using config file base: {}", config_dir); let config = Config::builder() .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Toml)) diff --git a/packages/obs/src/entry/args.rs b/packages/obs/src/entry/args.rs new file mode 100644 index 000000000..1099398ac --- /dev/null +++ b/packages/obs/src/entry/args.rs @@ -0,0 +1,74 @@ +use crate::entry::ObjectVersion; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; + +/// Args - defines the arguments for API operations +/// Args is used to define the arguments for API operations. +/// +/// # Example +/// ``` +/// use rustfs_obs::Args; +/// use std::collections::HashMap; +/// +/// let args = Args::new() +/// .set_bucket(Some("my-bucket".to_string())) +/// .set_object(Some("my-object".to_string())) +/// .set_version_id(Some("123".to_string())) +/// .set_metadata(Some(HashMap::new())); +/// ``` +#[derive(Debug, Clone, Serialize, Deserialize, Default, Eq, PartialEq)] +pub struct Args { + #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] + pub bucket: Option, + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] + pub version_id: Option, + #[serde(rename = "objects", skip_serializing_if = "Option::is_none")] + pub objects: Option>, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl Args { + /// Create a new Args object + pub fn new() -> Self { + Args { + bucket: None, + object: None, + version_id: None, + objects: None, + metadata: None, + } + } + + /// Set the bucket + pub fn set_bucket(mut self, bucket: Option) -> Self { + self.bucket = bucket; + self + } + + /// Set the object + pub fn set_object(mut self, object: Option) -> Self { + self.object = object; + self + } + + /// Set the version ID + pub fn set_version_id(mut self, version_id: Option) -> Self { + self.version_id = version_id; + self + } + + /// Set the objects + pub fn set_objects(mut self, objects: Option>) -> Self { + self.objects = objects; + self + } + + /// Set the metadata + pub fn set_metadata(mut self, metadata: Option>) -> Self { + self.metadata = metadata; + self + } +} diff --git a/packages/obs/src/entry/audit.rs b/packages/obs/src/entry/audit.rs index 8f8b1e34f..0aba2bac3 100644 --- a/packages/obs/src/entry/audit.rs +++ b/packages/obs/src/entry/audit.rs @@ -1,11 +1,64 @@ -use crate::ObjectVersion; +use crate::{BaseLogEntry, LogRecord, ObjectVersion}; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; /// API details structure -#[derive(Debug, Serialize, Deserialize, Clone, Default)] +/// ApiDetails is used to define the details of an API operation +/// +/// The `ApiDetails` structure contains the following fields: +/// - `name` - the name of the API operation +/// - `bucket` - the bucket name +/// - `object` - the object name +/// - `objects` - the list of objects +/// - `status` - the status of the API operation +/// - `status_code` - the status code of the API operation +/// - `input_bytes` - the input bytes +/// - `output_bytes` - the output bytes +/// - `header_bytes` - the header bytes +/// - `time_to_first_byte` - the time to first byte +/// - `time_to_first_byte_in_ns` - the time to first byte in nanoseconds +/// - `time_to_response` - the time to response +/// - `time_to_response_in_ns` - the time to response in nanoseconds +/// +/// The `ApiDetails` structure contains the following methods: +/// - `new` - create a new `ApiDetails` with default values +/// - `set_name` - set the name +/// - `set_bucket` - set the bucket +/// - `set_object` - set the object +/// - `set_objects` - set the objects +/// - `set_status` - set the status +/// - `set_status_code` - set the status code +/// - `set_input_bytes` - set the input bytes +/// - `set_output_bytes` - set the output bytes +/// - `set_header_bytes` - set the header bytes +/// - `set_time_to_first_byte` - set the time to first byte +/// - `set_time_to_first_byte_in_ns` - set the time to first byte in nanoseconds +/// - `set_time_to_response` - set the time to response +/// - `set_time_to_response_in_ns` - set the time to response in nanoseconds +/// +/// # Example +/// ``` +/// use rustfs_obs::ApiDetails; +/// use rustfs_obs::ObjectVersion; +/// +/// let api = ApiDetails::new() +/// .set_name(Some("GET".to_string())) +/// .set_bucket(Some("my-bucket".to_string())) +/// .set_object(Some("my-object".to_string())) +/// .set_objects(vec![ObjectVersion::new_with_object_name("my-object".to_string())]) +/// .set_status(Some("OK".to_string())) +/// .set_status_code(Some(200)) +/// .set_input_bytes(100) +/// .set_output_bytes(200) +/// .set_header_bytes(Some(50)) +/// .set_time_to_first_byte(Some("100ms".to_string())) +/// .set_time_to_first_byte_in_ns(Some("100000000ns".to_string())) +/// .set_time_to_response(Some("200ms".to_string())) +/// .set_time_to_response_in_ns(Some("200000000ns".to_string())); +/// ``` +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq)] pub struct ApiDetails { #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, @@ -135,22 +188,85 @@ impl ApiDetails { } /// Entry - audit entry logs +/// AuditLogEntry is used to define the structure of an audit log entry +/// +/// The `AuditLogEntry` structure contains the following fields: +/// - `base` - the base log entry +/// - `version` - the version of the audit log entry +/// - `deployment_id` - the deployment ID +/// - `event` - the event +/// - `entry_type` - the type of audit message +/// - `api` - the API details +/// - `remote_host` - the remote host +/// - `user_agent` - the user agent +/// - `req_path` - the request path +/// - `req_host` - the request host +/// - `req_claims` - the request claims +/// - `req_query` - the request query +/// - `req_header` - the request header +/// - `resp_header` - the response header +/// - `access_key` - the access key +/// - `parent_user` - the parent user +/// - `error` - the error +/// +/// The `AuditLogEntry` structure contains the following methods: +/// - `new` - create a new `AuditEntry` with default values +/// - `new_with_values` - create a new `AuditEntry` with version, time, event and api details +/// - `with_base` - set the base log entry +/// - `set_version` - set the version +/// - `set_deployment_id` - set the deployment ID +/// - `set_event` - set the event +/// - `set_entry_type` - set the entry type +/// - `set_api` - set the API details +/// - `set_remote_host` - set the remote host +/// - `set_user_agent` - set the user agent +/// - `set_req_path` - set the request path +/// - `set_req_host` - set the request host +/// - `set_req_claims` - set the request claims +/// - `set_req_query` - set the request query +/// - `set_req_header` - set the request header +/// - `set_resp_header` - set the response header +/// - `set_access_key` - set the access key +/// - `set_parent_user` - set the parent user +/// - `set_error` - set the error +/// +/// # Example +/// ``` +/// use rustfs_obs::AuditLogEntry; +/// use rustfs_obs::ApiDetails; +/// use std::collections::HashMap; +/// +/// let entry = AuditLogEntry::new() +/// .set_version("1.0".to_string()) +/// .set_deployment_id(Some("123".to_string())) +/// .set_event("event".to_string()) +/// .set_entry_type(Some("type".to_string())) +/// .set_api(ApiDetails::new()) +/// .set_remote_host(Some("remote-host".to_string())) +/// .set_user_agent(Some("user-agent".to_string())) +/// .set_req_path(Some("req-path".to_string())) +/// .set_req_host(Some("req-host".to_string())) +/// .set_req_claims(Some(HashMap::new())) +/// .set_req_query(Some(HashMap::new())) +/// .set_req_header(Some(HashMap::new())) +/// .set_resp_header(Some(HashMap::new())) +/// .set_access_key(Some("access-key".to_string())) +/// .set_parent_user(Some("parent-user".to_string())) +/// .set_error(Some("error".to_string())); #[derive(Debug, Serialize, Deserialize, Clone, Default)] -pub struct AuditEntry { +pub struct AuditLogEntry { + #[serde(flatten)] + pub base: BaseLogEntry, pub version: String, #[serde(rename = "deploymentid", skip_serializing_if = "Option::is_none")] pub deployment_id: Option, - pub time: DateTime, pub event: String, - // Class of audit message - S3, admin ops, bucket management #[serde(rename = "type", skip_serializing_if = "Option::is_none")] pub entry_type: Option, pub api: ApiDetails, #[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")] pub remote_host: Option, - #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")] - pub request_id: Option, #[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")] pub user_agent: Option, #[serde(rename = "requestPath", skip_serializing_if = "Option::is_none")] @@ -165,8 +281,6 @@ pub struct AuditEntry { pub req_header: Option>, #[serde(rename = "responseHeader", skip_serializing_if = "Option::is_none")] pub resp_header: Option>, - #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] - pub tags: Option>, #[serde(rename = "accessKey", skip_serializing_if = "Option::is_none")] pub access_key: Option, #[serde(rename = "parentUser", skip_serializing_if = "Option::is_none")] @@ -175,18 +289,17 @@ pub struct AuditEntry { pub error: Option, } -impl AuditEntry { +impl AuditLogEntry { /// Create a new `AuditEntry` with default values pub fn new() -> Self { - AuditEntry { + AuditLogEntry { + base: BaseLogEntry::new(), version: String::new(), deployment_id: None, - time: Utc::now(), event: String::new(), entry_type: None, api: ApiDetails::new(), remote_host: None, - request_id: None, user_agent: None, req_path: None, req_host: None, @@ -194,47 +307,25 @@ impl AuditEntry { req_query: None, req_header: None, resp_header: None, - tags: None, access_key: None, parent_user: None, error: None, } } - /// Create a new `AuditEntry` with version and time event and api details - /// # Arguments - /// * `version` - Version of the audit entry - /// * `time` - Time of the audit entry - /// * `event` - Event of the audit entry - /// * `api` - API details of the audit entry - /// # Returns - /// * `AuditEntry` with the given values - /// # Example - /// ``` - /// use chrono::Utc; - /// use rustfs_obs::{ApiDetails, AuditEntry}; - /// let entry = AuditEntry::new_with_values( - /// "v1".to_string(), - /// Utc::now(), - /// "event".to_string(), - /// ApiDetails::new(), - /// ); - /// ``` - /// # Remarks - /// This is a convenience method to create an `AuditEntry` with the given values - /// without having to set each field individually - /// This is useful when you want to create an `AuditEntry` with the given values - /// without having to set each field individually + /// Create a new `AuditEntry` with version, time, event and api details pub fn new_with_values(version: String, time: DateTime, event: String, api: ApiDetails) -> Self { - AuditEntry { + let mut base = BaseLogEntry::new(); + base.timestamp = time; + + AuditLogEntry { + base, version, deployment_id: None, - time, event, entry_type: None, api, remote_host: None, - request_id: None, user_agent: None, req_path: None, req_host: None, @@ -242,13 +333,18 @@ impl AuditEntry { req_query: None, req_header: None, resp_header: None, - tags: None, access_key: None, parent_user: None, error: None, } } + /// Set the base log entry + pub fn with_base(mut self, base: BaseLogEntry) -> Self { + self.base = base; + self + } + /// Set the version pub fn set_version(mut self, version: String) -> Self { self.version = version; @@ -261,12 +357,6 @@ impl AuditEntry { self } - /// Set the time - pub fn set_time(mut self, time: DateTime) -> Self { - self.time = time; - self - } - /// Set the event pub fn set_event(mut self, event: String) -> Self { self.event = event; @@ -291,12 +381,6 @@ impl AuditEntry { self } - /// Set the request ID - pub fn set_request_id(mut self, request_id: Option) -> Self { - self.request_id = request_id; - self - } - /// Set the user agent pub fn set_user_agent(mut self, user_agent: Option) -> Self { self.user_agent = user_agent; @@ -339,12 +423,6 @@ impl AuditEntry { self } - /// Set the tags - pub fn set_tags(mut self, tags: Option>) -> Self { - self.tags = tags; - self - } - /// Set the access key pub fn set_access_key(mut self, access_key: Option) -> Self { self.access_key = access_key; @@ -364,79 +442,12 @@ impl AuditEntry { } } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_audit_entry() { - let entry = AuditEntry::new() - .set_version("v1".to_string()) - .set_deployment_id(Some("12345".to_string())) - .set_time(Utc::now()) - .set_event("event".to_string()) - .set_entry_type(Some("type".to_string())) - .set_api(ApiDetails::new()) - .set_remote_host(Some("localhost".to_string())) - .set_request_id(Some("req-12345".to_string())) - .set_user_agent(Some("user-agent".to_string())) - .set_req_path(Some("/path".to_string())) - .set_req_host(Some("localhost".to_string())) - .set_req_claims(Some(HashMap::new())) - .set_req_query(Some(HashMap::new())) - .set_req_header(Some(HashMap::new())) - .set_resp_header(Some(HashMap::new())) - .set_tags(Some(HashMap::new())) - .set_access_key(Some("access-key".to_string())) - .set_parent_user(Some("parent-user".to_string())) - .set_error(Some("error".to_string())); - - assert_eq!(entry.version, "v1"); - assert_eq!(entry.deployment_id, Some("12345".to_string())); - assert_eq!(entry.event, "event"); - assert_eq!(entry.entry_type, Some("type".to_string())); - assert_eq!(entry.remote_host, Some("localhost".to_string())); - assert_eq!(entry.request_id, Some("req-12345".to_string())); - assert_eq!(entry.user_agent, Some("user-agent".to_string())); - assert_eq!(entry.req_path, Some("/path".to_string())); - assert_eq!(entry.req_host, Some("localhost".to_string())); - assert_eq!(entry.access_key, Some("access-key".to_string())); - assert_eq!(entry.parent_user, Some("parent-user".to_string())); - assert_eq!(entry.error, Some("error".to_string())); +impl LogRecord for AuditLogEntry { + fn to_json(&self) -> String { + serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) } - #[test] - fn test_api_details() { - let api = ApiDetails::new() - .set_name(Some("name".to_string())) - .set_bucket(Some("bucket".to_string())) - .set_object(Some("object".to_string())) - .set_objects(vec![ObjectVersion { - object_name: "object".to_string(), - version_id: Some("12345".to_string()), - }]) - .set_status(Some("status".to_string())) - .set_status_code(Some(200)) - .set_input_bytes(100) - .set_output_bytes(200) - .set_header_bytes(Some(300)) - .set_time_to_first_byte(Some("100ms".to_string())) - .set_time_to_first_byte_in_ns(Some("100ns".to_string())) - .set_time_to_response(Some("200ms".to_string())) - .set_time_to_response_in_ns(Some("200ns".to_string())); - - assert_eq!(api.name, Some("name".to_string())); - assert_eq!(api.bucket, Some("bucket".to_string())); - assert_eq!(api.object, Some("object".to_string())); - assert_eq!(api.objects.len(), 1); - assert_eq!(api.status, Some("status".to_string())); - assert_eq!(api.status_code, Some(200)); - assert_eq!(api.input_bytes, 100); - assert_eq!(api.output_bytes, 200); - assert_eq!(api.header_bytes, Some(300)); - assert_eq!(api.time_to_first_byte, Some("100ms".to_string())); - assert_eq!(api.time_to_first_byte_in_ns, Some("100ns".to_string())); - assert_eq!(api.time_to_response, Some("200ms".to_string())); - assert_eq!(api.time_to_response_in_ns, Some("200ns".to_string())); + fn get_timestamp(&self) -> DateTime { + self.base.timestamp } } diff --git a/packages/obs/src/entry/base.rs b/packages/obs/src/entry/base.rs index c629c74d8..422646e09 100644 --- a/packages/obs/src/entry/base.rs +++ b/packages/obs/src/entry/base.rs @@ -3,490 +3,90 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -/// ObjectVersion object version key/versionId +/// Base log entry structure shared by all log types +/// This structure is used to serialize log entries to JSON +/// and send them to the log sinks +/// This structure is also used to deserialize log entries from JSON +/// This structure is also used to store log entries in the database +/// This structure is also used to query log entries from the database +/// +/// The `BaseLogEntry` structure contains the following fields: +/// - `timestamp` - the timestamp of the log entry +/// - `request_id` - the request ID of the log entry +/// - `message` - the message of the log entry +/// - `tags` - the tags of the log entry +/// +/// The `BaseLogEntry` structure contains the following methods: +/// - `new` - create a new `BaseLogEntry` with default values +/// - `message` - set the message +/// - `request_id` - set the request ID +/// - `tags` - set the tags +/// - `timestamp` - set the timestamp +/// +/// # Example +/// ``` +/// use rustfs_obs::BaseLogEntry; +/// use chrono::{DateTime, Utc}; +/// use std::collections::HashMap; +/// +/// let timestamp = Utc::now(); +/// let request = Some("req-123".to_string()); +/// let message = Some("This is a log message".to_string()); +/// let tags = Some(HashMap::new()); +/// +/// let entry = BaseLogEntry::new() +/// .timestamp(timestamp) +/// .request_id(request) +/// .message(message) +/// .tags(tags); +/// ``` #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Default)] -pub struct ObjectVersion { - #[serde(rename = "objectName")] - pub object_name: String, - #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] - pub version_id: Option, -} - -impl ObjectVersion { - /// Create a new ObjectVersion object - pub fn new() -> Self { - ObjectVersion { - object_name: String::new(), - version_id: None, - } - } - - /// Create a new ObjectVersion object with object name - pub fn new_with_object_name(object_name: String) -> Self { - ObjectVersion { - object_name, - version_id: None, - } - } - /// Set the object name - pub fn set_object_name(mut self, object_name: String) -> Self { - self.object_name = object_name; - self - } - - /// Set the version ID - pub fn set_version_id(mut self, version_id: Option) -> Self { - self.version_id = version_id; - self - } -} - -/// Args - defines the arguments for the API -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -pub struct Args { - #[serde(rename = "bucket", skip_serializing_if = "Option::is_none")] - pub bucket: Option, - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] - pub version_id: Option, - #[serde(rename = "objects", skip_serializing_if = "Option::is_none")] - pub objects: Option>, - #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option>, -} - -impl Args { - /// Create a new Args object - pub fn new() -> Self { - Args { - bucket: None, - object: None, - version_id: None, - objects: None, - metadata: None, - } - } - - /// Set the bucket - pub fn set_bucket(mut self, bucket: Option) -> Self { - self.bucket = bucket; - self - } - - /// Set the object - pub fn set_object(mut self, object: Option) -> Self { - self.object = object; - self - } - - /// Set the version ID - pub fn set_version_id(mut self, version_id: Option) -> Self { - self.version_id = version_id; - self - } - - /// Set the objects - pub fn set_objects(mut self, objects: Option>) -> Self { - self.objects = objects; - self - } - - /// Set the metadata - pub fn set_metadata(mut self, metadata: Option>) -> Self { - self.metadata = metadata; - self - } -} - -/// Trace - defines the trace -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -pub struct Trace { - #[serde(rename = "message", skip_serializing_if = "Option::is_none")] - pub message: Option, - #[serde(rename = "source", skip_serializing_if = "Option::is_none")] - pub source: Option>, - #[serde(rename = "variables", skip_serializing_if = "Option::is_none")] - pub variables: Option>, -} - -impl Trace { - /// Create a new Trace object - pub fn new() -> Self { - Trace { - message: None, - source: None, - variables: None, - } - } - - /// Set the message - pub fn set_message(mut self, message: Option) -> Self { - self.message = message; - self - } - - /// Set the source - pub fn set_source(mut self, source: Option>) -> Self { - self.source = source; - self - } - - /// Set the variables - pub fn set_variables(mut self, variables: Option>) -> Self { - self.variables = variables; - self - } -} - -/// API - defines the api type and its args -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -pub struct API { - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - pub name: Option, - #[serde(rename = "args", skip_serializing_if = "Option::is_none")] - pub args: Option, -} - -impl API { - /// Create a new API object - pub fn new() -> Self { - API { name: None, args: None } - } - - /// Set the name - pub fn set_name(mut self, name: Option) -> Self { - self.name = name; - self - } - - /// Set the args - pub fn set_args(mut self, args: Option) -> Self { - self.args = args; - self - } -} - -/// Log kind/level enum -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub enum LogKind { - #[serde(rename = "INFO")] - Info, - #[serde(rename = "WARNING")] - Warning, - #[serde(rename = "ERROR")] - Error, - #[serde(rename = "FATAL")] - Fatal, -} - -impl Default for LogKind { - fn default() -> Self { - LogKind::Info - } -} - -/// Entry - defines fields and values of each log entry -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -pub struct Entry { - #[serde(rename = "site", skip_serializing_if = "Option::is_none")] - pub site: Option, - - #[serde(rename = "deploymentid", skip_serializing_if = "Option::is_none")] - pub deployment_id: Option, - - pub level: LogKind, - - #[serde(rename = "errKind", skip_serializing_if = "Option::is_none")] - pub log_kind: Option, // Deprecated Jan 2024 - - pub time: DateTime, - - #[serde(rename = "api", skip_serializing_if = "Option::is_none")] - pub api: Option, - - #[serde(rename = "remotehost", skip_serializing_if = "Option::is_none")] - pub remote_host: Option, - - #[serde(rename = "host", skip_serializing_if = "Option::is_none")] - pub host: Option, +pub struct BaseLogEntry { + #[serde(rename = "time")] + pub timestamp: DateTime, #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")] pub request_id: Option, - #[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")] - pub user_agent: Option, - #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, - #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub trace: Option, + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, } -impl Entry { - /// Create a new Entry object with default values +impl BaseLogEntry { + /// Create a new BaseLogEntry with default values pub fn new() -> Self { - Entry { - site: None, - deployment_id: None, - level: LogKind::Info, - log_kind: None, - time: Utc::now(), - api: None, - remote_host: None, - host: None, + BaseLogEntry { + timestamp: Utc::now(), request_id: None, - user_agent: None, message: None, - trace: None, + tags: None, } } - /// Set the site - pub fn set_site(mut self, site: Option) -> Self { - self.site = site; - self - } - - /// Set the deployment ID - pub fn set_deployment_id(mut self, deployment_id: Option) -> Self { - self.deployment_id = deployment_id; - self - } - - /// Set the level - pub fn set_level(mut self, level: LogKind) -> Self { - self.level = level; - self - } - - /// Set the log kind - pub fn set_log_kind(mut self, log_kind: Option) -> Self { - self.log_kind = log_kind; - self - } - - /// Set the time - pub fn set_time(mut self, time: DateTime) -> Self { - self.time = time; - self - } - - /// Set the API - pub fn set_api(mut self, api: Option) -> Self { - self.api = api; - self - } - - /// Set the remote host - pub fn set_remote_host(mut self, remote_host: Option) -> Self { - self.remote_host = remote_host; - self - } - - /// Set the host - pub fn set_host(mut self, host: Option) -> Self { - self.host = host; - self - } - - /// Set the request ID - pub fn set_request_id(mut self, request_id: Option) -> Self { - self.request_id = request_id; - self - } - - /// Set the user agent - pub fn set_user_agent(mut self, user_agent: Option) -> Self { - self.user_agent = user_agent; - self - } - /// Set the message - pub fn set_message(mut self, message: Option) -> Self { + pub fn message(mut self, message: Option) -> Self { self.message = message; self } - /// Set the trace - pub fn set_trace(mut self, trace: Option) -> Self { - self.trace = trace; + /// Set the request ID + pub fn request_id(mut self, request_id: Option) -> Self { + self.request_id = request_id; + self + } + + /// Set the tags + pub fn tags(mut self, tags: Option>) -> Self { + self.tags = tags; + self + } + + /// Set the timestamp + pub fn timestamp(mut self, timestamp: DateTime) -> Self { + self.timestamp = timestamp; self } } - -/// Info holds console log messages -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Info { - #[serde(flatten)] - pub entry: Entry, - - pub console_msg: String, - - #[serde(rename = "node")] - pub node_name: String, - - #[serde(skip)] - pub err: Option, -} - -impl Info { - /// Create a new Info object with default values - pub fn new() -> Self { - Info { - entry: Entry::new(), - console_msg: String::new(), - node_name: String::new(), - err: None, - } - } - - /// Create a new Info object with console message and node name - pub fn new_with_console_msg(console_msg: String, node_name: String) -> Self { - Info { - entry: Entry::new(), - console_msg, - node_name, - err: None, - } - } - - /// Set the node name - pub fn set_node_name(&mut self, node_name: String) { - self.node_name = node_name; - } - - /// Set the entry - pub fn set_entry(&mut self, entry: Entry) { - self.entry = entry; - } - - /// Set the console message - pub fn set_console_msg(&mut self, console_msg: String) { - self.console_msg = console_msg; - } - - /// Set the error message - pub fn set_err(&mut self, err: Option) { - self.err = err; - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_object_version() { - let mut object_version = ObjectVersion::new(); - object_version = object_version.clone().set_object_name("object".to_string()); - object_version = object_version.clone().set_version_id(Some("version".to_string())); - assert_eq!(object_version.object_name, "object".to_string()); - assert_eq!(object_version.version_id, Some("version".to_string())); - } - - #[test] - fn test_object_version_with_object_name() { - let object_version = ObjectVersion::new_with_object_name("object".to_string()); - assert_eq!(object_version.object_name, "object".to_string()); - assert_eq!(object_version.version_id, None); - } - - #[test] - fn test_args() { - let mut obj = ObjectVersion::new(); - obj.object_name = "object".to_string(); - obj.version_id = Some("version".to_string()); - let objs = vec![obj]; - let args = Args::new() - .set_bucket(Some("bucket".to_string())) - .set_object(Some("object".to_string())) - .set_version_id(Some("version".to_string())) - .set_objects(Some(objs.clone())) - .set_metadata(Some(HashMap::new())); - - assert_eq!(args.bucket, Some("bucket".to_string())); - assert_eq!(args.object, Some("object".to_string())); - assert_eq!(args.version_id, Some("version".to_string())); - assert_eq!(args.objects, Some(objs)); - assert_eq!(args.metadata, Some(HashMap::new())); - } - - #[test] - fn test_trace() { - let trace = Trace::new() - .set_message(Some("message".to_string())) - .set_source(Some(vec!["source".to_string()])) - .set_variables(Some(HashMap::new())); - - assert_eq!(trace.message, Some("message".to_string())); - assert_eq!(trace.source, Some(vec!["source".to_string()])); - assert_eq!(trace.variables, Some(HashMap::new())); - } - - #[test] - fn test_api() { - let api = API::new().set_name(Some("name".to_string())).set_args(Some(Args::new())); - - assert_eq!(api.name, Some("name".to_string())); - assert_eq!(api.args, Some(Args::new())); - } - - #[test] - fn test_log_kind() { - assert_eq!(LogKind::default(), LogKind::Info); - } - - #[test] - fn test_entry() { - let entry = Entry::new() - .set_site(Some("site".to_string())) - .set_deployment_id(Some("deployment_id".to_string())) - .set_level(LogKind::Info) - .set_log_kind(Some(LogKind::Info)) - .set_time(Utc::now()) - .set_api(Some(API::new())) - .set_remote_host(Some("remote_host".to_string())) - .set_host(Some("host".to_string())) - .set_request_id(Some("request_id".to_string())) - .set_user_agent(Some("user_agent".to_string())) - .set_message(Some("message".to_string())) - .set_trace(Some(Trace::new())); - - assert_eq!(entry.site, Some("site".to_string())); - assert_eq!(entry.deployment_id, Some("deployment_id".to_string())); - assert_eq!(entry.level, LogKind::Info); - assert_eq!(entry.log_kind, Some(LogKind::Info)); - assert_eq!(entry.api, Some(API::new())); - assert_eq!(entry.remote_host, Some("remote_host".to_string())); - assert_eq!(entry.host, Some("host".to_string())); - assert_eq!(entry.request_id, Some("request_id".to_string())); - assert_eq!(entry.user_agent, Some("user_agent".to_string())); - assert_eq!(entry.message, Some("message".to_string())); - assert_eq!(entry.trace, Some(Trace::new())); - } - - #[test] - fn test_info() { - let mut info = Info::new(); - info.set_node_name("node_name".to_string()); - info.set_entry(Entry::new()); - info.set_console_msg("console_msg".to_string()); - info.set_err(Some("err".to_string())); - - assert_eq!(info.node_name, "node_name".to_string()); - // assert_eq!(info.entry, Entry::new()); - assert_eq!(info.console_msg, "console_msg".to_string()); - assert_eq!(info.err, Some("err".to_string())); - } - - #[test] - fn test_info_with_console_msg() { - let info = Info::new_with_console_msg("console_msg".to_string(), "node_name".to_string()); - - assert_eq!(info.node_name, "node_name".to_string()); - assert_eq!(info.console_msg, "console_msg".to_string()); - assert_eq!(info.err, None); - } -} diff --git a/packages/obs/src/entry/log.rs b/packages/obs/src/entry/log.rs deleted file mode 100644 index 6960fef21..000000000 --- a/packages/obs/src/entry/log.rs +++ /dev/null @@ -1,83 +0,0 @@ -use chrono::{DateTime, Utc}; -use serde::de::Error; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use tracing_core::Level; - -/// Wrapper for `tracing_core::Level` to implement `Serialize` and `Deserialize` -#[derive(Debug, Clone)] -pub struct SerializableLevel(pub Level); - -impl From for SerializableLevel { - fn from(level: Level) -> Self { - SerializableLevel(level) - } -} - -impl From for Level { - fn from(serializable_level: SerializableLevel) -> Self { - serializable_level.0 - } -} - -impl Serialize for SerializableLevel { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(self.0.as_str()) - } -} - -impl<'de> Deserialize<'de> for SerializableLevel { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let s = String::deserialize(deserializer)?; - match s.as_str() { - "TRACE" => Ok(SerializableLevel(Level::TRACE)), - "DEBUG" => Ok(SerializableLevel(Level::DEBUG)), - "INFO" => Ok(SerializableLevel(Level::INFO)), - "WARN" => Ok(SerializableLevel(Level::WARN)), - "ERROR" => Ok(SerializableLevel(Level::ERROR)), - _ => Err(D::Error::custom("unknown log level")), - } - } -} - -/// Server log entry structure -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct LogEntry { - pub timestamp: DateTime, // Log timestamp - pub level: SerializableLevel, // Log Level - pub message: String, // Log messages - pub source: String, // Log source (such as module name) - pub target: Option, // Log target - pub request_id: Option, // Request ID (Common Server Fields) - pub user_id: Option, // User ID (Common Server Fields) - pub fields: Vec<(String, String)>, // Attached fields (key value pairs) -} - -impl LogEntry { - /// Create a new LogEntry - pub fn new( - level: Level, - message: String, - source: String, - target: Option, - request_id: Option, - user_id: Option, - fields: Vec<(String, String)>, - ) -> Self { - LogEntry { - timestamp: Utc::now(), - level: SerializableLevel::from(level), - message, - source, - target, - request_id, - user_id, - fields, - } - } -} diff --git a/packages/obs/src/entry/mod.rs b/packages/obs/src/entry/mod.rs index 51ba15848..72dae2611 100644 --- a/packages/obs/src/entry/mod.rs +++ b/packages/obs/src/entry/mod.rs @@ -1,3 +1,143 @@ +pub(crate) mod args; pub(crate) mod audit; pub(crate) mod base; -pub(crate) mod log; +pub(crate) mod unified; + +use serde::de::Error; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use tracing_core::Level; + +/// ObjectVersion is used across multiple modules +#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] +pub struct ObjectVersion { + #[serde(rename = "name")] + pub object_name: String, + #[serde(rename = "versionId", skip_serializing_if = "Option::is_none")] + pub version_id: Option, +} + +impl ObjectVersion { + /// Create a new ObjectVersion object + pub fn new() -> Self { + ObjectVersion { + object_name: String::new(), + version_id: None, + } + } + + /// Create a new ObjectVersion with object name + pub fn new_with_object_name(object_name: String) -> Self { + ObjectVersion { + object_name, + version_id: None, + } + } + + /// Set the object name + pub fn set_object_name(mut self, object_name: String) -> Self { + self.object_name = object_name; + self + } + + /// Set the version ID + pub fn set_version_id(mut self, version_id: Option) -> Self { + self.version_id = version_id; + self + } +} + +/// Log kind/level enum +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub enum LogKind { + #[serde(rename = "INFO")] + Info, + #[serde(rename = "WARNING")] + Warning, + #[serde(rename = "ERROR")] + Error, + #[serde(rename = "FATAL")] + Fatal, +} + +impl Default for LogKind { + fn default() -> Self { + LogKind::Info + } +} + +/// Trait for types that can be serialized to JSON and have a timestamp +/// This trait is used by `ServerLogEntry` to convert the log entry to JSON +/// and get the timestamp of the log entry +/// This trait is implemented by `ServerLogEntry` +/// +/// # Example +/// ``` +/// use rustfs_obs::LogRecord; +/// use chrono::{DateTime, Utc}; +/// use rustfs_obs::ServerLogEntry; +/// use tracing_core::Level; +/// +/// let log_entry = ServerLogEntry::new(Level::INFO, "api_handler".to_string()); +/// let json = log_entry.to_json(); +/// let timestamp = log_entry.get_timestamp(); +/// ``` +pub trait LogRecord { + fn to_json(&self) -> String; + fn get_timestamp(&self) -> chrono::DateTime; +} + +/// Wrapper for `tracing_core::Level` to implement `Serialize` and `Deserialize` +/// for `ServerLogEntry` +/// This is necessary because `tracing_core::Level` does not implement `Serialize` +/// and `Deserialize` +/// This is a workaround to allow `ServerLogEntry` to be serialized and deserialized +/// using `serde` +/// +/// # Example +/// ``` +/// use rustfs_obs::SerializableLevel; +/// use tracing_core::Level; +/// +/// let level = Level::INFO; +/// let serializable_level = SerializableLevel::from(level); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct SerializableLevel(pub Level); + +impl From for SerializableLevel { + fn from(level: Level) -> Self { + SerializableLevel(level) + } +} + +impl From for Level { + fn from(serializable_level: SerializableLevel) -> Self { + serializable_level.0 + } +} + +impl Serialize for SerializableLevel { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(self.0.as_str()) + } +} + +impl<'de> Deserialize<'de> for SerializableLevel { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + match s.as_str() { + "TRACE" => Ok(SerializableLevel(Level::TRACE)), + "DEBUG" => Ok(SerializableLevel(Level::DEBUG)), + "INFO" => Ok(SerializableLevel(Level::INFO)), + "WARN" => Ok(SerializableLevel(Level::WARN)), + "ERROR" => Ok(SerializableLevel(Level::ERROR)), + _ => Err(D::Error::custom("unknown log level")), + } + } +} diff --git a/packages/obs/src/entry/unified.rs b/packages/obs/src/entry/unified.rs new file mode 100644 index 000000000..598ebe792 --- /dev/null +++ b/packages/obs/src/entry/unified.rs @@ -0,0 +1,279 @@ +use crate::{AuditLogEntry, BaseLogEntry, LogKind, LogRecord, SerializableLevel}; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use tracing_core::Level; + +/// Server log entry with structured fields +/// ServerLogEntry is used to log structured log entries from the server +/// +/// The `ServerLogEntry` structure contains the following fields: +/// - `base` - the base log entry +/// - `level` - the log level +/// - `source` - the source of the log entry +/// - `user_id` - the user ID +/// - `fields` - the structured fields of the log entry +/// +/// The `ServerLogEntry` structure contains the following methods: +/// - `new` - create a new `ServerLogEntry` with specified level and source +/// - `with_base` - set the base log entry +/// - `user_id` - set the user ID +/// - `fields` - set the fields +/// - `add_field` - add a field +/// +/// # Example +/// ``` +/// use rustfs_obs::ServerLogEntry; +/// use tracing_core::Level; +/// +/// let entry = ServerLogEntry::new(Level::INFO, "test_module".to_string()) +/// .user_id(Some("user-456".to_string())) +/// .add_field("operation".to_string(), "login".to_string()); +/// ``` +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct ServerLogEntry { + #[serde(flatten)] + pub base: BaseLogEntry, + + pub level: SerializableLevel, + pub source: String, + + #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] + pub user_id: Option, + + #[serde(skip_serializing_if = "Vec::is_empty", default)] + pub fields: Vec<(String, String)>, +} + +impl ServerLogEntry { + /// Create a new ServerLogEntry with specified level and source + pub fn new(level: Level, source: String) -> Self { + ServerLogEntry { + base: BaseLogEntry::new(), + level: SerializableLevel(level), + source, + user_id: None, + fields: Vec::new(), + } + } + + /// Set the base log entry + pub fn with_base(mut self, base: BaseLogEntry) -> Self { + self.base = base; + self + } + + /// Set the user ID + pub fn user_id(mut self, user_id: Option) -> Self { + self.user_id = user_id; + self + } + + /// Set fields + pub fn fields(mut self, fields: Vec<(String, String)>) -> Self { + self.fields = fields; + self + } + + /// Add a field + pub fn add_field(mut self, key: String, value: String) -> Self { + self.fields.push((key, value)); + self + } +} + +impl LogRecord for ServerLogEntry { + fn to_json(&self) -> String { + serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) + } + + fn get_timestamp(&self) -> DateTime { + self.base.timestamp + } +} + +/// Console log entry structure +/// ConsoleLogEntry is used to log console log entries +/// The `ConsoleLogEntry` structure contains the following fields: +/// - `base` - the base log entry +/// - `level` - the log level +/// - `console_msg` - the console message +/// - `node_name` - the node name +/// - `err` - the error message +/// The `ConsoleLogEntry` structure contains the following methods: +/// - `new` - create a new `ConsoleLogEntry` +/// - `new_with_console_msg` - create a new `ConsoleLogEntry` with console message and node name +/// - `with_base` - set the base log entry +/// - `set_level` - set the log level +/// - `set_node_name` - set the node name +/// - `set_console_msg` - set the console message +/// - `set_err` - set the error message +/// # Example +/// ``` +/// use rustfs_obs::ConsoleLogEntry; +/// +/// let entry = ConsoleLogEntry::new_with_console_msg("Test message".to_string(), "node-123".to_string()); +/// ``` +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ConsoleLogEntry { + #[serde(flatten)] + pub base: BaseLogEntry, + + pub level: LogKind, + pub console_msg: String, + pub node_name: String, + + #[serde(skip)] + pub err: Option, +} + +impl ConsoleLogEntry { + /// Create a new ConsoleLogEntry + pub fn new() -> Self { + ConsoleLogEntry { + base: BaseLogEntry::new(), + level: LogKind::Info, + console_msg: String::new(), + node_name: String::new(), + err: None, + } + } + + /// Create a new ConsoleLogEntry with console message and node name + pub fn new_with_console_msg(console_msg: String, node_name: String) -> Self { + ConsoleLogEntry { + base: BaseLogEntry::new(), + level: LogKind::Info, + console_msg, + node_name, + err: None, + } + } + + /// Set the base log entry + pub fn with_base(mut self, base: BaseLogEntry) -> Self { + self.base = base; + self + } + + /// Set the log level + pub fn set_level(mut self, level: LogKind) -> Self { + self.level = level; + self + } + + /// Set the node name + pub fn set_node_name(mut self, node_name: String) -> Self { + self.node_name = node_name; + self + } + + /// Set the console message + pub fn set_console_msg(mut self, console_msg: String) -> Self { + self.console_msg = console_msg; + self + } + + /// Set the error message + pub fn set_err(mut self, err: Option) -> Self { + self.err = err; + self + } +} + +impl LogRecord for ConsoleLogEntry { + fn to_json(&self) -> String { + serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) + } + + fn get_timestamp(&self) -> DateTime { + self.base.timestamp + } +} + +/// Unified log entry type +/// UnifiedLogEntry is used to log different types of log entries +/// +/// The `UnifiedLogEntry` enum contains the following variants: +/// - `Server` - a server log entry +/// - `Audit` - an audit log entry +/// - `Console` - a console log entry +/// +/// The `UnifiedLogEntry` enum contains the following methods: +/// - `to_json` - convert the log entry to JSON +/// - `get_timestamp` - get the timestamp of the log entry +/// +/// # Example +/// ``` +/// use rustfs_obs::{UnifiedLogEntry, ServerLogEntry}; +/// use tracing_core::Level; +/// +/// let server_entry = ServerLogEntry::new(Level::INFO, "test_module".to_string()); +/// let unified = UnifiedLogEntry::Server(server_entry); +/// ``` +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "type")] +pub enum UnifiedLogEntry { + #[serde(rename = "server")] + Server(ServerLogEntry), + + #[serde(rename = "audit")] + Audit(AuditLogEntry), + + #[serde(rename = "console")] + Console(ConsoleLogEntry), +} + +impl LogRecord for UnifiedLogEntry { + fn to_json(&self) -> String { + match self { + UnifiedLogEntry::Server(entry) => entry.to_json(), + UnifiedLogEntry::Audit(entry) => entry.to_json(), + UnifiedLogEntry::Console(entry) => entry.to_json(), + } + } + + fn get_timestamp(&self) -> DateTime { + match self { + UnifiedLogEntry::Server(entry) => entry.get_timestamp(), + UnifiedLogEntry::Audit(entry) => entry.get_timestamp(), + UnifiedLogEntry::Console(entry) => entry.get_timestamp(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_base_log_entry() { + let base = BaseLogEntry::new() + .request_id(Some("req-123".to_string())) + .message(Some("Test message".to_string())); + + assert_eq!(base.request_id, Some("req-123".to_string())); + assert_eq!(base.message, Some("Test message".to_string())); + } + + #[test] + fn test_server_log_entry() { + let entry = ServerLogEntry::new(Level::INFO, "test_module".to_string()) + .user_id(Some("user-456".to_string())) + .add_field("operation".to_string(), "login".to_string()); + + assert_eq!(entry.level.0, Level::INFO); + assert_eq!(entry.source, "test_module"); + assert_eq!(entry.user_id, Some("user-456".to_string())); + assert_eq!(entry.fields.len(), 1); + assert_eq!(entry.fields[0], ("operation".to_string(), "login".to_string())); + } + + #[test] + fn test_unified_log_entry_json() { + let server_entry = ServerLogEntry::new(Level::INFO, "test_source".to_string()); + let unified = UnifiedLogEntry::Server(server_entry); + + let json = unified.to_json(); + assert!(json.contains("test_source")); + } +} diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index 8d00c7b09..0db02853f 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -3,6 +3,30 @@ /// `obs` is a logging and observability library for Rust. /// It provides a simple and easy-to-use interface for logging and observability. /// It is built on top of the `log` crate and `opentelemetry` crate. +/// +/// ## Features +/// - Structured logging +/// - Distributed tracing +/// - Metrics collection +/// - Log processing worker +/// - Multiple sinks +/// - Configuration-based setup +/// - Telemetry guard +/// - Global logger +/// - Log levels +/// - Log entry types +/// - Log record +/// - Object version +/// - Local IP address +/// +/// ## Usage +/// +/// ```rust +/// use rustfs_obs::{AppConfig, init_obs}; +/// +/// let config = AppConfig::default(); +/// let (logger, guard) = init_obs(config); +/// ``` mod config; mod entry; mod logger; @@ -13,9 +37,11 @@ mod worker; pub use config::load_config; pub use config::{AppConfig, OtelConfig}; -pub use entry::audit::{ApiDetails, AuditEntry}; -pub use entry::base::{Args, Entry, Info, LogKind, ObjectVersion, Trace, API}; -pub use entry::log::{LogEntry, SerializableLevel}; +pub use entry::args::Args; +pub use entry::audit::{ApiDetails, AuditLogEntry}; +pub use entry::base::BaseLogEntry; +pub use entry::unified::{ConsoleLogEntry, ServerLogEntry, UnifiedLogEntry}; +pub use entry::{LogKind, LogRecord, ObjectVersion, SerializableLevel}; pub use logger::start_logger; pub use logger::{ ensure_logger_initialized, get_global_logger, init_global_logger, locked_logger, log_debug, log_error, log_info, log_trace, diff --git a/packages/obs/src/logger.rs b/packages/obs/src/logger.rs index a3848cc3b..22914a666 100644 --- a/packages/obs/src/logger.rs +++ b/packages/obs/src/logger.rs @@ -1,4 +1,4 @@ -use crate::{AppConfig, LogEntry, SerializableLevel, Sink}; +use crate::{AppConfig, AuditLogEntry, BaseLogEntry, ConsoleLogEntry, ServerLogEntry, Sink, UnifiedLogEntry}; use std::sync::Arc; use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio::sync::{Mutex, OnceCell}; @@ -10,14 +10,14 @@ static GLOBAL_LOGGER: OnceCell>> = OnceCell::const_new(); /// Server log processor #[derive(Debug)] pub struct Logger { - sender: Sender, // Log sending channel + sender: Sender, // Log sending channel queue_capacity: usize, } impl Logger { /// Create a new Logger instance /// Returns Logger and corresponding Receiver - pub fn new(config: &AppConfig) -> (Self, Receiver) { + pub fn new(config: &AppConfig) -> (Self, Receiver) { // Get queue capacity from configuration, or use default values 10000 let queue_capacity = config.logger.queue_capacity.unwrap_or(10000); let (sender, receiver) = mpsc::channel(queue_capacity); @@ -39,83 +39,80 @@ impl Logger { self.queue_capacity } - /// Asynchronous logging of server logs - /// Attach the log to the current Span and generate a separate Tracing Event - #[tracing::instrument(skip(self), fields(log_source = "logger"))] - pub async fn log(&self, entry: LogEntry) -> Result<(), LogError> { - // Log messages to the current Span - tracing::Span::current() - .record("log_message", &entry.message) - .record("source", &entry.source); - println!("target start is {:?}", &entry.target); - let target = if let Some(target) = &entry.target { - target.clone() - } else { - "server_logs".to_string() - }; + /// Log a server entry + #[tracing::instrument(skip(self), fields(log_source = "logger_server"))] + pub async fn log_server_entry(&self, entry: ServerLogEntry) -> Result<(), LogError> { + self.log_entry(UnifiedLogEntry::Server(entry)).await + } - println!("target end is {:?}", target); - // Generate independent Tracing Events with full LogEntry information - // Generate corresponding events according to level - match entry.level { - SerializableLevel(Level::ERROR) => { - tracing::error!( - target = %target.clone(), - timestamp = %entry.timestamp, - message = %entry.message, - source = %entry.source, - request_id = ?entry.request_id, - user_id = ?entry.user_id, - fields = ?entry.fields - ); + /// Log an audit entry + #[tracing::instrument(skip(self), fields(log_source = "logger_audit"))] + pub async fn log_audit_entry(&self, entry: AuditLogEntry) -> Result<(), LogError> { + self.log_entry(UnifiedLogEntry::Audit(entry)).await + } + + /// Log a console entry + #[tracing::instrument(skip(self), fields(log_source = "logger_console"))] + pub async fn log_console_entry(&self, entry: ConsoleLogEntry) -> Result<(), LogError> { + self.log_entry(UnifiedLogEntry::Console(entry)).await + } + + /// Asynchronous logging of unified log entries + #[tracing::instrument(skip(self), fields(log_source = "logger"))] + pub async fn log_entry(&self, entry: UnifiedLogEntry) -> Result<(), LogError> { + // Extract information for tracing based on entry type + match &entry { + UnifiedLogEntry::Server(server) => { + tracing::Span::current() + .record("log_level", &server.level.0.as_str()) + .record("log_message", &server.base.message.as_deref().unwrap_or("")) + .record("source", &server.source); + + // Generate tracing event based on log level + match server.level.0 { + Level::ERROR => { + tracing::error!(target: "server_logs", message = %server.base.message.as_deref().unwrap_or("")); + } + Level::WARN => { + tracing::warn!(target: "server_logs", message = %server.base.message.as_deref().unwrap_or("")); + } + Level::INFO => { + tracing::info!(target: "server_logs", message = %server.base.message.as_deref().unwrap_or("")); + } + Level::DEBUG => { + tracing::debug!(target: "server_logs", message = %server.base.message.as_deref().unwrap_or("")); + } + Level::TRACE => { + tracing::trace!(target: "server_logs", message = %server.base.message.as_deref().unwrap_or("")); + } + } } - SerializableLevel(Level::WARN) => { - tracing::warn!( - target = %target.clone(), - timestamp = %entry.timestamp, - message = %entry.message, - source = %entry.source, - request_id = ?entry.request_id, - user_id = ?entry.user_id, - fields = ?entry.fields - ); - } - SerializableLevel(Level::INFO) => { + UnifiedLogEntry::Audit(audit) => { tracing::info!( - target = %target.clone(), - timestamp = %entry.timestamp, - message = %entry.message, - source = %entry.source, - request_id = ?entry.request_id, - user_id = ?entry.user_id, - fields = ?entry.fields + target: "audit_logs", + event = %audit.event, + api = %audit.api.name.as_deref().unwrap_or("unknown"), + message = %audit.base.message.as_deref().unwrap_or("") ); } - SerializableLevel(Level::DEBUG) => { - tracing::debug!( - target = %target.clone(), - timestamp = %entry.timestamp, - message = %entry.message, - source = %entry.source, - request_id = ?entry.request_id, - user_id = ?entry.user_id, - fields = ?entry.fields - ); - } - SerializableLevel(Level::TRACE) => { - tracing::trace!( - target = %target.clone(), - timestamp = %entry.timestamp, - message = %entry.message, - source = %entry.source, - request_id = ?entry.request_id, - user_id = ?entry.user_id, - fields = ?entry.fields + UnifiedLogEntry::Console(console) => { + let level_str = match console.level { + crate::LogKind::Info => "INFO", + crate::LogKind::Warning => "WARN", + crate::LogKind::Error => "ERROR", + crate::LogKind::Fatal => "FATAL", + }; + + tracing::info!( + target: "console_logs", + level = %level_str, + node = %console.node_name, + message = %console.console_msg ); } } - // Send logs to asynchronous queues to improve error handling + // Send logs to async queue with improved error handling match self.sender.try_send(entry) { Ok(_) => Ok(()), Err(mpsc::error::TrySendError::Full(entry)) => { @@ -150,28 +147,25 @@ impl Logger { /// use rustfs_obs::Logger; /// /// async fn example(logger: &Logger) { - /// let _ = logger.write_with_context("This is an information message", "example",Level::INFO, Some("target".to_string()),Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await; + /// let _ = logger.write_with_context("This is an information message", "example",Level::INFO, Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await; /// } pub async fn write_with_context( &self, message: &str, source: &str, level: Level, - target: Option, request_id: Option, user_id: Option, fields: Vec<(String, String)>, ) -> Result<(), LogError> { - self.log(LogEntry::new( - level, - message.to_string(), - source.to_string(), - target, - request_id, - user_id, - fields, - )) - .await + let base = BaseLogEntry::new().message(Some(message.to_string())).request_id(request_id); + + let server_entry = ServerLogEntry::new(level, source.to_string()) + .user_id(user_id) + .fields(fields) + .with_base(base); + + self.log_server_entry(server_entry).await } /// Write log @@ -194,16 +188,7 @@ impl Logger { /// } /// ``` pub async fn write(&self, message: &str, source: &str, level: Level) -> Result<(), LogError> { - self.log(LogEntry::new( - level, - message.to_string(), - source.to_string(), - None, - None, - None, - Vec::new(), - )) - .await + self.write_with_context(message, source, level, None, None, Vec::new()).await } /// Shutdown the logger @@ -458,7 +443,6 @@ pub async fn log_trace(message: &str, source: &str) -> Result<(), LogError> { /// - `message`: Message to be logged /// - `source`: Source of the log /// - `level`: Log level -/// - `target`: Log target /// - `request_id`: Request ID /// - `user_id`: User ID /// - `fields`: Additional fields @@ -470,14 +454,13 @@ pub async fn log_trace(message: &str, source: &str) -> Result<(), LogError> { /// use rustfs_obs::log_with_context; /// /// async fn example() { -/// let _ = log_with_context("This is an information message", "example", Level::INFO, Some("target".to_string()), Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await; +/// let _ = log_with_context("This is an information message", "example", Level::INFO, Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await; /// } /// ``` pub async fn log_with_context( message: &str, source: &str, level: Level, - target: Option, request_id: Option, user_id: Option, fields: Vec<(String, String)>, @@ -485,6 +468,6 @@ pub async fn log_with_context( get_global_logger() .lock() .await - .write_with_context(message, source, level, target, request_id, user_id, fields) + .write_with_context(message, source, level, request_id, user_id, fields) .await } diff --git a/packages/obs/src/sink.rs b/packages/obs/src/sink.rs index 2363a69dd..8eb1830d7 100644 --- a/packages/obs/src/sink.rs +++ b/packages/obs/src/sink.rs @@ -1,4 +1,4 @@ -use crate::{AppConfig, LogEntry}; +use crate::{AppConfig, LogRecord, UnifiedLogEntry}; use async_trait::async_trait; use std::sync::Arc; use tokio::fs::OpenOptions; @@ -8,7 +8,7 @@ use tokio::io::AsyncWriteExt; /// Sink Trait definition, asynchronously write logs #[async_trait] pub trait Sink: Send + Sync { - async fn write(&self, entry: &LogEntry); + async fn write(&self, entry: &UnifiedLogEntry); } #[cfg(feature = "kafka")] @@ -18,7 +18,7 @@ pub struct KafkaSink { topic: String, batch_size: usize, batch_timeout_ms: u64, - entries: Arc>>, + entries: Arc>>, last_flush: Arc, } @@ -64,7 +64,7 @@ impl KafkaSink { async fn periodic_flush( producer: rdkafka::producer::FutureProducer, topic: String, - entries: Arc>>, + entries: Arc>>, last_flush: Arc, timeout_ms: u64, ) { @@ -88,7 +88,7 @@ impl KafkaSink { } } - async fn send_batch(producer: &rdkafka::producer::FutureProducer, topic: &str, entries: Vec) { + async fn send_batch(producer: &rdkafka::producer::FutureProducer, topic: &str, entries: Vec) { for entry in entries { let payload = match serde_json::to_string(&entry) { Ok(p) => p, @@ -98,7 +98,7 @@ impl KafkaSink { } }; - let span_id = entry.timestamp.to_rfc3339(); + let span_id = entry.get_timestamp().to_rfc3339(); let _ = producer .send( @@ -113,7 +113,7 @@ impl KafkaSink { #[cfg(feature = "kafka")] #[async_trait] impl Sink for KafkaSink { - async fn write(&self, entry: &LogEntry) { + async fn write(&self, entry: &UnifiedLogEntry) { let mut batch = self.entries.lock().await; batch.push(entry.clone()); @@ -129,7 +129,7 @@ impl Sink for KafkaSink { if should_flush_by_size || should_flush_by_time { // Existing flush logic - let entries_to_send: Vec = batch.drain(..).collect(); + let entries_to_send: Vec = batch.drain(..).collect(); let producer = self.producer.clone(); let topic = self.topic.clone(); @@ -203,7 +203,7 @@ impl WebhookSink { #[cfg(feature = "webhook")] #[async_trait] impl Sink for WebhookSink { - async fn write(&self, entry: &LogEntry) { + async fn write(&self, entry: &UnifiedLogEntry) { let mut retries = 0; let url = self.url.clone(); let entry_clone = entry.clone(); @@ -327,12 +327,17 @@ impl FileSink { #[cfg(feature = "file")] #[async_trait] impl Sink for FileSink { - async fn write(&self, entry: &LogEntry) { + async fn write(&self, entry: &UnifiedLogEntry) { let line = format!("{:?}\n", entry); let mut writer = self.writer.lock().await; if let Err(e) = writer.write_all(line.as_bytes()).await { - eprintln!("Failed to write log to file {}: {}", self.path, e); + eprintln!( + "Failed to write log to file {}: {},entry timestamp:{:?}", + self.path, + e, + entry.get_timestamp() + ); return; } diff --git a/packages/obs/src/worker.rs b/packages/obs/src/worker.rs index 1c40f47f5..2d7ee2e14 100644 --- a/packages/obs/src/worker.rs +++ b/packages/obs/src/worker.rs @@ -1,9 +1,9 @@ -use crate::{entry::log::LogEntry, sink::Sink}; +use crate::{sink::Sink, UnifiedLogEntry}; use std::sync::Arc; use tokio::sync::mpsc::Receiver; /// Start the log processing worker thread -pub async fn start_worker(receiver: Receiver, sinks: Vec>) { +pub async fn start_worker(receiver: Receiver, sinks: Vec>) { let mut receiver = receiver; while let Some(entry) = receiver.recv().await { for sink in &sinks { From 4795638763f97da6e59c0d0370c7797493b9bbef Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 18 Mar 2025 16:39:18 +0800 Subject: [PATCH 011/103] feat(observability): add obs_config option and document stdout export - Add obs_config parameter to config struct with default path - Document how to modify use_stdout value in README.md - Support configuring observability via file or environment variables This change helps users configure telemetry output destination for better observability options in different deployment scenarios. --- .docker/observability/README.md | 101 ++++++++++++++++++++++++++++++++ README.md | 45 ++++++++++++++ rustfs/src/config/mod.rs | 28 ++++++++- rustfs/src/main.rs | 9 +-- 4 files changed, 178 insertions(+), 5 deletions(-) diff --git a/.docker/observability/README.md b/.docker/observability/README.md index e69de29bb..f0bd03fcb 100644 --- a/.docker/observability/README.md +++ b/.docker/observability/README.md @@ -0,0 +1,101 @@ +# Observability + +This directory contains the observability stack for the application. The stack is composed of the following components: + +- Prometheus +- Grafana +- Loki +- Jaeger +- Otel Collector + +## Prometheus + +Prometheus is a monitoring and alerting toolkit. It scrapes metrics from instrumented jobs, either directly or via an +intermediary push gateway for short-lived jobs. It stores all scraped samples locally and runs rules over this data to +either aggregate and record new time series from existing data or generate alerts. Grafana or other API consumers can be +used to visualize the collected data. + +## Grafana + +Grafana is a multi-platform open-source analytics and interactive visualization web application. It provides charts, +graphs, and alerts for the web when connected to supported data sources. + +## Loki + +Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. It is +designed to be very cost-effective and easy to operate. It does not index the contents of the logs, but rather a set of +labels for each log stream. + +## Jaeger + +Jaeger is a distributed tracing system released as open source by Uber Technologies. It is used for monitoring and +troubleshooting microservices-based distributed systems, including: + +- Distributed context propagation +- Distributed transaction monitoring +- Root cause analysis +- Service dependency analysis +- Performance / latency optimization + +## Otel Collector + +The OpenTelemetry Collector offers a vendor-agnostic implementation on how to receive, process, and export telemetry +data. It removes the need to run, operate, and maintain multiple agents/collectors in order to support open-source +observability data formats (e.g. Jaeger, Prometheus, etc.) sending to one or more open-source or commercial back-ends. + +## How to use + +To deploy the observability stack, run the following command: + +```bash +docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d +``` + +To access the Grafana dashboard, navigate to `http://localhost:3000` in your browser. The default username and password +are `admin` and `admin`, respectively. + +To access the Jaeger dashboard, navigate to `http://localhost:16686` in your browser. + +To access the Prometheus dashboard, navigate to `http://localhost:9090` in your browser. + +## How to stop + +To stop the observability stack, run the following command: + +```bash +docker-compose -f docker-compose.yml -f docker-compose.override.yml down +``` + +## How to remove data + +To remove the data generated by the observability stack, run the following command: + +```bash +docker-compose -f docker-compose.yml -f docker-compose.override.yml down -v +``` + +## How to configure + +To configure the observability stack, modify the `docker-compose.override.yml` file. The file contains the following + +```yaml +services: + prometheus: + environment: + - PROMETHEUS_CONFIG_FILE=/etc/prometheus/prometheus.yml + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + + grafana: + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + volumes: + - ./grafana/provisioning:/etc/grafana/provisioning +``` + +The `prometheus` service mounts the `prometheus.yml` file to `/etc/prometheus/prometheus.yml`. The `grafana` service +mounts the `grafana/provisioning` directory to `/etc/grafana/provisioning`. You can modify these files to configure the +observability stack. + + + diff --git a/README.md b/README.md index dbb7e9f6e..217ab3c14 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ export RUSTFS_VOLUMES="./target/volume/test" export RUSTFS_ADDRESS="0.0.0.0:9000" export RUSTFS_CONSOLE_ENABLE=true export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9001" +export RUSTFS_OBS_CONFIG="config/obs.toml" ``` You need replace your real data folder: @@ -47,3 +48,47 @@ You need replace your real data folder: ``` ./rustfs /data/rustfs ``` + +## How to deploy the observability stack + +The OpenTelemetry Collector offers a vendor-agnostic implementation on how to receive, process, and export telemetry +data. It removes the need to run, operate, and maintain multiple agents/collectors in order to support open-source +observability data formats (e.g. Jaeger, Prometheus, etc.) sending to one or more open-source or commercial back-ends. + +1. Enter the `.docker/observability` directory, +2. Run the following command: + +```bash +docker-compose -f docker-compose.yml up -d +``` + +3. Access the Grafana dashboard by navigating to `http://localhost:3000` in your browser. The default username and + password are `admin` and `admin`, respectively. + +4. Access the Jaeger dashboard by navigating to `http://localhost:16686` in your browser. + +5. Access the Prometheus dashboard by navigating to `http://localhost:9090` in your browser. + +## Create a new Observability configuration file + +#### 1. Enter the `config` directory, + +#### 2. Copy `obs.toml.example` to `obs.toml` + +#### 3. Modify the `obs.toml` configuration file + +##### 3.1. Modify the `endpoint` value to the address of the OpenTelemetry Collector + +##### 3.2. Modify the `service_name` value to the name of the service + +##### 3.3. Modify the `service_version` value to the version of the service + +##### 3.4. Modify the `deployment_environment` value to the environment of the service + +##### 3.5. Modify the `meter_interval` value to export interval + +##### 3.6. Modify the `sample_ratio` value to the sample ratio + +##### 3.7. Modify the `use_stdout` value to export to stdout + + diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index cd8f238fd..d6552af83 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -1,11 +1,32 @@ use clap::Parser; use const_str::concat; use ecstore::global::DEFAULT_PORT; +use std::string::ToString; shadow_rs::shadow!(build); +/// Default Access Key +/// Default value: rustfsadmin +/// Environment variable: RUSTFS_ACCESS_KEY +/// Command line argument: --access-key +/// Example: RUSTFS_ACCESS_KEY=rustfsadmin +/// Example: --access-key rustfsadmin pub const DEFAULT_ACCESS_KEY: &str = "rustfsadmin"; +/// Default Secret Key +/// Default value: rustfsadmin +/// Environment variable: RUSTFS_SECRET_KEY +/// Command line argument: --secret-key +/// Example: RUSTFS_SECRET_KEY=rustfsadmin +/// Example: --secret-key rustfsadmin pub const DEFAULT_SECRET_KEY: &str = "rustfsadmin"; +/// Default configuration file for observability +/// Default value: config/obs.toml +/// Environment variable: RUSTFS_OBS_CONFIG +/// Command line argument: --obs-config +/// Example: RUSTFS_OBS_CONFIG=config/obs.toml +/// Example: --obs-config config/obs.toml +/// Example: --obs-config /etc/rustfs/obs.toml +pub const DEFAULT_OBS_CONFIG: &str = "config/obs.toml"; #[allow(clippy::const_is_empty)] const SHORT_VERSION: &str = { @@ -31,7 +52,7 @@ const LONG_VERSION: &str = concat!( concat!("git status :\n", build::GIT_STATUS_FILE), ); -#[derive(Debug, Parser)] +#[derive(Debug, Parser, Clone)] #[command(version = SHORT_VERSION, long_version = LONG_VERSION)] pub struct Opt { /// DIR points to a directory on a filesystem. @@ -62,4 +83,9 @@ pub struct Opt { #[arg(long, default_value_t = format!("127.0.0.1:{}", 9002), env = "RUSTFS_CONSOLE_ADDRESS")] pub console_address: String, + + /// Observability configuration file + /// Default value: config/obs.toml + #[arg(long, default_value_t = DEFAULT_OBS_CONFIG.to_string(), env = "RUSTFS_OBS_CONFIG")] + pub obs_config: String, } diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index b87b16ca3..1c1351768 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -92,9 +92,7 @@ fn main() -> Result<()> { //设置 trace // setup_tracing(); - let config = load_config(Some("packages/obs/examples/config".to_string())); - // Initialize the logger asynchronously - let (_logger, _guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); + //运行参数 run(opt) } @@ -102,6 +100,9 @@ fn main() -> Result<()> { #[tokio::main] async fn run(opt: config::Opt) -> Result<()> { debug!("opt: {:?}", &opt); + let config = load_config(Some(opt.clone().obs_config)); + // Initialize Observability + init_obs(config).await; let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap(); @@ -277,7 +278,7 @@ async fn run(opt: config::Opt) -> Result<()> { init_iam_sys(store.clone()).await.unwrap(); new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| { - error!("new_global_notification_sys faild {:?}", &err); + error!("new_global_notification_sys failed {:?}", &err); Error::from_string(err.to_string()) })?; From f1c6f276e6874ffcd16ca6295feb022dd85be331 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 18 Mar 2025 19:04:00 +0800 Subject: [PATCH 012/103] improve code for main --- rustfs/src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 0dcf4094c..480b5db98 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -93,6 +93,10 @@ fn main() -> Result<()> { //设置 trace // setup_tracing(); + let config = load_config(Some(opt.clone().obs_config)); + // Initialize Observability + let (_logger, _guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); + //运行参数 run(opt) } @@ -100,9 +104,9 @@ fn main() -> Result<()> { #[tokio::main] async fn run(opt: config::Opt) -> Result<()> { debug!("opt: {:?}", &opt); - let config = load_config(Some(opt.clone().obs_config)); + // let config = load_config(Some(opt.clone().obs_config)); // Initialize Observability - init_obs(config).await; + // let (_logger, _guard) = init_obs(config).await; let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap(); From 197ae72e9315f4a62f67e9080addd83bcbd1a06a Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 18 Mar 2025 22:57:26 +0800 Subject: [PATCH 013/103] improve code for observability --- Cargo.lock | 1 + Cargo.toml | 1 + packages/obs/examples/config.toml | 2 +- packages/obs/examples/server.rs | 10 +++++++++- rustfs/Cargo.toml | 1 + rustfs/src/main.rs | 31 ++++++++++++++++++++++++------- 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4c5b173e..ef3176efb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5633,6 +5633,7 @@ dependencies = [ "mime", "mime_guess", "netif", + "once_cell", "pin-project-lite", "prost", "prost-build", diff --git a/Cargo.toml b/Cargo.toml index 989e7c4e2..e45251674 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ lazy_static = "1.5.0" local-ip-address = "0.6.3" mime = "0.3.17" netif = "0.1.6" +once_cell = "1.21.1" opentelemetry = { version = "0.28" } opentelemetry-appender-tracing = { version = "0.28.1", features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { version = "0.28" } diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml index ddf376352..2ceac4397 100644 --- a/packages/obs/examples/config.toml +++ b/packages/obs/examples/config.toml @@ -1,6 +1,6 @@ [observability] endpoint = "http://localhost:4317" -use_stdout = false +use_stdout = true sample_ratio = 0.5 meter_interval = 30 service_name = "rustfs_obs_service" diff --git a/packages/obs/examples/server.rs b/packages/obs/examples/server.rs index 2d35c8d4f..15a64c8be 100644 --- a/packages/obs/examples/server.rs +++ b/packages/obs/examples/server.rs @@ -1,5 +1,6 @@ use opentelemetry::global; -use rustfs_obs::{get_logger, init_obs, load_config, log_info, ServerLogEntry}; +use rustfs_obs::{get_logger, init_obs, load_config, log_info, BaseLogEntry, ServerLogEntry}; +use std::collections::HashMap; use std::time::{Duration, SystemTime}; use tracing::{info, instrument}; use tracing_core::Level; @@ -34,7 +35,14 @@ async fn run(bucket: String, object: String, user: String, service_name: String) &[opentelemetry::KeyValue::new("operation", "run")], ); + let base_entry = BaseLogEntry::new() + .message(Some("run logger api_handler info".to_string())) + .request_id(Some("request_id".to_string())) + .timestamp(chrono::DateTime::from(start_time)) + .tags(Some(HashMap::default())); + let server_entry = ServerLogEntry::new(Level::INFO, "api_handler".to_string()) + .with_base(base_entry) .user_id(Some(user.clone())) .add_field("operation".to_string(), "login".to_string()) .add_field("bucket".to_string(), bucket.clone()) diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 73e53c0bb..530cc57ae 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -33,6 +33,7 @@ http-body.workspace = true lock.workspace = true mime.workspace = true netif.workspace = true +once_cell.workspace = true pin-project-lite.workspace = true prost.workspace = true prost-types.workspace = true diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 480b5db98..6f4fee1ee 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -34,6 +34,7 @@ use hyper_util::{ service::TowerToHyperService, }; use iam::init_iam_sys; +use once_cell::sync::OnceCell; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; use rustfs_obs::{init_obs, load_config}; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; @@ -46,6 +47,20 @@ use tracing::{debug, error, info, warn}; use tracing_error::ErrorLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; +/// Guard that holds a reference to the global observability subsystem. +/// This struct ensures that tracing/logging components remain alive for the +/// application's lifetime. The underlying guard is dropped when this struct +/// is dropped, which may flush logs or perform cleanup operations. +#[allow(dead_code)] +struct TracingGuard(Box); + +impl Drop for TracingGuard { + fn drop(&mut self) { + debug!("Dropping global tracing guard, flushing logs"); + } +} +static GLOBAL_GUARD: OnceCell = OnceCell::new(); + #[allow(dead_code)] fn setup_tracing() { use tracing_subscriber::EnvFilter; @@ -87,26 +102,28 @@ fn print_server_info() { } fn main() -> Result<()> { - //解析获得到的参数 + // Parse the obtained parameters let opt = config::Opt::parse(); - //设置 trace + // 设置 trace // setup_tracing(); let config = load_config(Some(opt.clone().obs_config)); // Initialize Observability - let (_logger, _guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); + let (_logger, guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); - //运行参数 + // Pack and store the guard + GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| { + error!("Unable to set global tracing guard"); + }); + + // Run parameters run(opt) } #[tokio::main] async fn run(opt: config::Opt) -> Result<()> { debug!("opt: {:?}", &opt); - // let config = load_config(Some(opt.clone().obs_config)); - // Initialize Observability - // let (_logger, _guard) = init_obs(config).await; let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap(); From 28a4a917d4b4bfed2bf042db977b15f107e2d56e Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 19 Mar 2025 22:34:26 +0800 Subject: [PATCH 014/103] replace log to tracing --- Cargo.lock | 3 +-- ecstore/src/endpoints.rs | 7 +++--- ecstore/src/global.rs | 2 +- iam/src/lib.rs | 3 ++- packages/obs/Cargo.toml | 14 +++++------ packages/obs/examples/config.toml | 4 +-- packages/obs/src/telemetry.rs | 2 +- rustfs/Cargo.toml | 5 ++-- rustfs/src/main.rs | 41 ++++++++++++++++++++++--------- rustfs/src/storage/ecfs.rs | 4 +-- 10 files changed, 52 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef3176efb..f833d5ceb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5617,7 +5617,6 @@ dependencies = [ "flatbuffers", "futures", "futures-util", - "h2", "http", "http-body", "hyper", @@ -5627,7 +5626,6 @@ dependencies = [ "lazy_static", "local-ip-address", "lock", - "log", "madmin", "matchit 0.8.6", "mime", @@ -5658,6 +5656,7 @@ dependencies = [ "tower 0.5.2", "tower-http", "tracing", + "tracing-core", "tracing-error", "tracing-subscriber", "transform-stream", diff --git a/ecstore/src/endpoints.rs b/ecstore/src/endpoints.rs index 8dbee9928..3bca94804 100644 --- a/ecstore/src/endpoints.rs +++ b/ecstore/src/endpoints.rs @@ -1,4 +1,4 @@ -use tracing::warn; +use tracing::{instrument, warn}; use crate::{ disk::endpoint::{Endpoint, EndpointType}, @@ -407,7 +407,7 @@ pub struct PoolEndpoints { pub platform: String, } -/// list of list of endpoints +/// list of endpoints #[derive(Debug, Clone, Default)] pub struct EndpointServerPools(pub Vec); @@ -532,6 +532,8 @@ impl EndpointServerPools { nodes } + + #[instrument] pub fn hosts_sorted(&self) -> Vec> { let (mut peers, local) = self.peers(); @@ -604,7 +606,6 @@ impl EndpointServerPools { #[cfg(test)] mod test { - use super::*; use std::path::Path; diff --git a/ecstore/src/global.rs b/ecstore/src/global.rs index 8735249c9..f6fc4bdb8 100644 --- a/ecstore/src/global.rs +++ b/ecstore/src/global.rs @@ -61,7 +61,7 @@ pub fn get_global_deployment_id() -> Option { pub fn set_global_endpoints(eps: Vec) { GLOBAL_Endpoints .set(EndpointServerPools::from(eps)) - .expect("GLOBAL_Endpoints set faild") + .expect("GLOBAL_Endpoints set failed") } pub fn get_global_endpoints() -> EndpointServerPools { diff --git a/iam/src/lib.rs b/iam/src/lib.rs index 65484724c..364627a29 100644 --- a/iam/src/lib.rs +++ b/iam/src/lib.rs @@ -2,11 +2,11 @@ use auth::Credentials; use ecstore::error::{Error, Result}; use ecstore::store::ECStore; use error::Error as IamError; -use log::debug; use manager::IamCache; use std::sync::{Arc, OnceLock}; use store::object::ObjectStore; use sys::IamSys; +use tracing::{debug, instrument}; pub mod cache; mod format; @@ -58,6 +58,7 @@ pub fn get_global_action_cred() -> Option { GLOBAL_ACTIVE_CRED.get().cloned() } +#[instrument] pub async fn init_iam_sys(ecstore: Arc) -> Result<()> { debug!("init iam system"); let s = IamCache::new(ObjectStore::new(ecstore)).await; diff --git a/packages/obs/Cargo.toml b/packages/obs/Cargo.toml index 86a9fb6c4..af3e3480d 100644 --- a/packages/obs/Cargo.toml +++ b/packages/obs/Cargo.toml @@ -23,14 +23,14 @@ opentelemetry = { workspace = true } opentelemetry-appender-tracing = { workspace = true, features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } opentelemetry-stdout = { workspace = true } -opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "metrics"] } +opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "gzip-tonic"] } opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] } serde = { workspace = true } -tracing = { workspace = true } +tracing = { workspace = true, features = ["std", "attributes"] } tracing-core = { workspace = true } tracing-error = { workspace = true } tracing-opentelemetry = { workspace = true } -tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } +tracing-subscriber = { workspace = true, features = ["registry", "std", "fmt", "env-filter", "tracing-log", "time", "local-time", "json"] } tokio = { workspace = true, features = ["sync", "fs", "rt-multi-thread"] } rdkafka = { workspace = true, features = ["tokio"], optional = true } reqwest = { workspace = true, optional = true, default-features = false } @@ -41,10 +41,10 @@ local-ip-address = { workspace = true } [dev-dependencies] chrono = { workspace = true } -opentelemetry = { workspace = true, features = ["trace", "metrics"] } -opentelemetry_sdk = { workspace = true, features = ["trace", "rt-tokio"] } -opentelemetry-stdout = { workspace = true, features = ["trace", "metrics"] } -opentelemetry-otlp = { workspace = true, features = ["metrics", "grpc-tonic"] } +opentelemetry = { workspace = true } +opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } +opentelemetry-stdout = { workspace = true } +opentelemetry-otlp = { workspace = true, features = ["grpc-tonic"] } opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true, features = ["std", "attributes"] } diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml index 2ceac4397..135dd39ac 100644 --- a/packages/obs/examples/config.toml +++ b/packages/obs/examples/config.toml @@ -1,9 +1,9 @@ [observability] endpoint = "http://localhost:4317" use_stdout = true -sample_ratio = 0.5 +sample_ratio = 1 meter_interval = 30 -service_name = "rustfs_obs_service" +service_name = "rustfs_obs" service_version = "0.1.0" deployment_environment = "develop" diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index cafe5badc..914071903 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -129,7 +129,7 @@ fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { let tracer_provider = if config.endpoint.is_empty() { builder - .with_simple_exporter(opentelemetry_stdout::SpanExporter::default()) + .with_batch_exporter(opentelemetry_stdout::SpanExporter::default()) .build() } else { let exporter = opentelemetry_otlp::SpanExporter::builder() diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 530cc57ae..640baea76 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -16,7 +16,7 @@ workspace = true [dependencies] madmin.workspace = true -log.workspace = true +#log.workspace = true async-trait.workspace = true bytes.workspace = true clap.workspace = true @@ -25,7 +25,7 @@ ecstore.workspace = true flatbuffers.workspace = true futures.workspace = true futures-util.workspace = true -h2 = "0.4.7" +#h2 = "0.4.7" hyper.workspace = true hyper-util.workspace = true http.workspace = true @@ -57,6 +57,7 @@ tokio-stream.workspace = true tonic = { version = "0.12.3", features = ["gzip"] } tonic-reflection.workspace = true tower.workspace = true +tracing-core = { workspace = true } tracing-error.workspace = true tracing-subscriber.workspace = true transform-stream.workspace = true diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 6f4fee1ee..787ee8c99 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -36,14 +36,16 @@ use hyper_util::{ use iam::init_iam_sys; use once_cell::sync::OnceCell; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; -use rustfs_obs::{init_obs, load_config}; +use rustfs_obs::{init_obs, load_config, BaseLogEntry, ServerLogEntry}; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; +use std::time::SystemTime; use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; -use tracing::{debug, error, info, warn}; +use tracing::{debug, error, info, info_span, warn}; +use tracing_core::Level; use tracing_error::ErrorLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -101,28 +103,43 @@ fn print_server_info() { info!("Docs: {}", cfg.doc()); } -fn main() -> Result<()> { +#[tokio::main] +async fn main() -> Result<()> { // Parse the obtained parameters let opt = config::Opt::parse(); - + println!("config: {:?}", &opt); // 设置 trace // setup_tracing(); let config = load_config(Some(opt.clone().obs_config)); // Initialize Observability - let (_logger, guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); - + let (logger, guard) = init_obs(config).await; + // let (logger, guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); + // let _rr = tokio::runtime::Runtime::new()?.block_on(async { + let start_time = SystemTime::now(); + let base_entry = BaseLogEntry::new() + .timestamp(chrono::DateTime::from(start_time)) + .message(Some("main init obs end".to_string())) + .request_id(Some("main".to_string())); + let server_entry = ServerLogEntry::new(Level::INFO, "main_server_entry".to_string()) + .with_base(base_entry) + .user_id(Some("user_id".to_string())); + let _r = logger.lock().await.log_server_entry(server_entry).await; + // }); // Pack and store the guard GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| { error!("Unable to set global tracing guard"); }); // Run parameters - run(opt) + run(opt).await } - -#[tokio::main] +// +// #[tokio::main] async fn run(opt: config::Opt) -> Result<()> { + let span = info_span!("trace-main-run"); + let _enter = span.enter(); + debug!("opt: {:?}", &opt); let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap(); @@ -259,7 +276,7 @@ async fn run(opt: config::Opt) -> Result<()> { match res { Ok(conn) => conn, Err(err) => { - tracing::error!("error accepting connection: {err}"); + error!("error accepting connection: {err}"); continue; } } @@ -278,10 +295,10 @@ async fn run(opt: config::Opt) -> Result<()> { tokio::select! { () = graceful.shutdown() => { - tracing::debug!("Gracefully shutdown!"); + debug!("Gracefully shutdown!"); }, () = tokio::time::sleep(std::time::Duration::from_secs(10)) => { - tracing::debug!("Waited 10 seconds for graceful shutdown, aborting..."); + debug!("Waited 10 seconds for graceful shutdown, aborting..."); } } }); diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index edb936dc3..7dfcb46c1 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -42,7 +42,6 @@ use http::HeaderMap; use iam::policy::action::Action; use iam::policy::action::S3Action; use lazy_static::lazy_static; -use log::warn; use s3s::dto::*; use s3s::s3_error; use s3s::S3Error; @@ -57,6 +56,7 @@ use tokio_util::io::StreamReader; use tracing::debug; use tracing::error; use tracing::info; +use tracing::warn; use transform_stream::AsyncTryStream; use uuid::Uuid; @@ -217,7 +217,7 @@ impl S3 for FS { #[tracing::instrument(level = "debug", skip(self, req))] async fn delete_bucket(&self, req: S3Request) -> S3Result> { let input = req.input; - // TODO: DeleteBucketInput 没有force参数? + // TODO: DeleteBucketInput 没有 force 参数? let Some(store) = new_object_layer_fn() else { return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string())); }; From aeb696687b07e9616c581cb77d2ed47ba9bc6bd2 Mon Sep 17 00:00:00 2001 From: houseme Date: Sat, 22 Mar 2025 21:30:10 +0800 Subject: [PATCH 015/103] update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 83b9ef43c..7017949a1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ .devcontainer rustfs/static/* vendor -cli/rustfs-gui/embedded-rustfs/rustfs \ No newline at end of file +cli/rustfs-gui/embedded-rustfs/rustfs +config/obs.toml \ No newline at end of file From 2b57af75ea8067fce5b469dbf320469a1b42242b Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 25 Mar 2025 19:02:52 +0800 Subject: [PATCH 016/103] upgrade opentelemetry create from 0.28.0 to 0.29.0 --- .docker/observability/jaeger-config.yaml | 9 ++-- .../observability/otel-collector-config.yaml | 34 +++++++-------- Cargo.lock | 43 ++++++++----------- Cargo.toml | 14 +++--- config/obs.example.toml | 2 +- packages/obs/examples/server.rs | 9 ++-- rustfs/src/main.rs | 22 +++++----- 7 files changed, 65 insertions(+), 68 deletions(-) diff --git a/.docker/observability/jaeger-config.yaml b/.docker/observability/jaeger-config.yaml index 31b5a9d6d..0df35f836 100644 --- a/.docker/observability/jaeger-config.yaml +++ b/.docker/observability/jaeger-config.yaml @@ -1,11 +1,10 @@ - service: - extensions: [jaeger_storage, jaeger_query, remote_sampling, healthcheckv2] + extensions: [ jaeger_storage, jaeger_query, remote_sampling, healthcheckv2 ] pipelines: traces: - receivers: [otlp, jaeger, zipkin] - processors: [batch, adaptive_sampling] - exporters: [jaeger_storage_exporter] + receivers: [ otlp, jaeger, zipkin ] + processors: [ batch, adaptive_sampling ] + exporters: [ jaeger_storage_exporter ] telemetry: resource: service.name: jaeger diff --git a/.docker/observability/otel-collector-config.yaml b/.docker/observability/otel-collector-config.yaml index 9e27c4e22..24d67dc3c 100644 --- a/.docker/observability/otel-collector-config.yaml +++ b/.docker/observability/otel-collector-config.yaml @@ -1,13 +1,13 @@ receivers: otlp: protocols: - grpc: # OTLP gRPC 接收器 + grpc: # OTLP gRPC 接收器 endpoint: 0.0.0.0:4317 - http: # OTLP HTTP 接收器 + http: # OTLP HTTP 接收器 endpoint: 0.0.0.0:4318 processors: - batch: # 批处理处理器,提升吞吐量 + batch: # 批处理处理器,提升吞吐量 timeout: 5s send_batch_size: 1000 memory_limiter: @@ -15,16 +15,16 @@ processors: limit_mib: 512 exporters: - otlp/traces: # OTLP 导出器,用于跟踪数据 + otlp/traces: # OTLP 导出器,用于跟踪数据 endpoint: "jaeger:4317" # Jaeger 的 OTLP gRPC 端点 tls: insecure: true # 开发环境禁用 TLS,生产环境需配置证书 - prometheus: # Prometheus 导出器,用于指标数据 + prometheus: # Prometheus 导出器,用于指标数据 endpoint: "0.0.0.0:8889" # Prometheus 刮取端点 - namespace: "otel" # 指标前缀 + namespace: "rustfs" # 指标前缀 send_timestamps: true # 发送时间戳 # enable_open_metrics: true - loki: # Loki 导出器,用于日志数据 + loki: # Loki 导出器,用于日志数据 # endpoint: "http://loki:3100/otlp/v1/logs" endpoint: "http://loki:3100/loki/api/v1/push" tls: @@ -34,20 +34,20 @@ extensions: pprof: zpages: service: - extensions: [health_check, pprof, zpages] # 启用扩展 + extensions: [ health_check, pprof, zpages ] # 启用扩展 pipelines: traces: - receivers: [otlp] - processors: [memory_limiter,batch] - exporters: [otlp/traces] + receivers: [ otlp ] + processors: [ memory_limiter,batch ] + exporters: [ otlp/traces ] metrics: - receivers: [otlp] - processors: [batch] - exporters: [prometheus] + receivers: [ otlp ] + processors: [ batch ] + exporters: [ prometheus ] logs: - receivers: [otlp] - processors: [batch] - exporters: [loki] + receivers: [ otlp ] + processors: [ batch ] + exporters: [ loki ] telemetry: logs: level: "info" # Collector 日志级别 diff --git a/Cargo.lock b/Cargo.lock index f833d5ceb..460ba8e12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4273,9 +4273,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "opentelemetry" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236e667b670a5cdf90c258f5a55794ec5ac5027e960c224bff8367a59e1e6426" +checksum = "768ee97dc5cd695a4dd4a69a0678fb42789666b5a89e8c0af48bb06c6e427120" dependencies = [ "futures-core", "futures-sink", @@ -4287,9 +4287,9 @@ dependencies = [ [[package]] name = "opentelemetry-appender-tracing" -version = "0.28.1" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c513c7af3bec30113f3d4620134ff923295f1e9c580fda2b8abe0831f925ddc0" +checksum = "e716f864eb23007bdd9dc4aec381e188a1cee28eecf22066772b5fd822b9727d" dependencies = [ "opentelemetry", "tracing", @@ -4301,9 +4301,9 @@ dependencies = [ [[package]] name = "opentelemetry-http" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8863faf2910030d139fb48715ad5ff2f35029fc5f244f6d5f689ddcf4d26253" +checksum = "46d7ab32b827b5b495bd90fa95a6cb65ccc293555dcc3199ae2937d2d237c8ed" dependencies = [ "async-trait", "bytes", @@ -4315,11 +4315,10 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bef114c6d41bea83d6dc60eb41720eedd0261a67af57b66dd2b84ac46c01d91" +checksum = "d899720fe06916ccba71c01d04ecd77312734e2de3467fd30d9d580c8ce85656" dependencies = [ - "async-trait", "futures-core", "http", "opentelemetry", @@ -4336,9 +4335,9 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f8870d3024727e99212eb3bb1762ec16e255e3e6f58eeb3dc8db1aa226746d" +checksum = "8c40da242381435e18570d5b9d50aca2a4f4f4d8e146231adb4e7768023309b3" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -4348,39 +4347,35 @@ dependencies = [ [[package]] name = "opentelemetry-semantic-conventions" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fb3a2f78c2d55362cd6c313b8abedfbc0142ab3c2676822068fd2ab7d51f9b7" +checksum = "84b29a9f89f1a954936d5aa92f19b2feec3c8f3971d3e96206640db7f9706ae3" [[package]] name = "opentelemetry-stdout" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb0e5a5132e4b80bf037a78e3e12c8402535199f5de490d0c38f7eac71bc831" +checksum = "a7e27d446dabd68610ef0b77d07b102ecde827a4596ea9c01a4d3811e945b286" dependencies = [ - "async-trait", "chrono", "futures-util", "opentelemetry", "opentelemetry_sdk", - "serde", - "thiserror 2.0.12", ] [[package]] name = "opentelemetry_sdk" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84dfad6042089c7fc1f6118b7040dc2eb4ab520abbf410b79dc481032af39570" +checksum = "afdefb21d1d47394abc1ba6c57363ab141be19e27cc70d0e422b7f303e4d290b" dependencies = [ - "async-trait", "futures-channel", "futures-executor", "futures-util", "glob", "opentelemetry", "percent-encoding", - "rand 0.8.5", + "rand 0.9.0", "serde_json", "thiserror 2.0.12", "tokio", @@ -7032,9 +7027,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721f2d2569dce9f3dfbbddee5906941e953bfcdf736a62da3377f5751650cc36" +checksum = "fd8e764bd6f5813fd8bebc3117875190c5b0415be8f7f8059bffb6ecd979c444" dependencies = [ "js-sys", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index e45251674..150a0e937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,12 +61,12 @@ local-ip-address = "0.6.3" mime = "0.3.17" netif = "0.1.6" once_cell = "1.21.1" -opentelemetry = { version = "0.28" } -opentelemetry-appender-tracing = { version = "0.28.1", features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } -opentelemetry_sdk = { version = "0.28" } -opentelemetry-stdout = { version = "0.28.0" } -opentelemetry-otlp = { version = "0.28" } -opentelemetry-semantic-conventions = { version = "0.28.0", features = ["semconv_experimental"] } +opentelemetry = { version = "0.29" } +opentelemetry-appender-tracing = { version = "0.29.1", features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } +opentelemetry_sdk = { version = "0.29" } +opentelemetry-stdout = { version = "0.29.0" } +opentelemetry-otlp = { version = "0.29" } +opentelemetry-semantic-conventions = { version = "0.29.0", features = ["semconv_experimental"] } pin-project-lite = "0.2" # pin-utils = "0.1.0" prost = "0.13.4" @@ -110,7 +110,7 @@ tracing-core = "0.1.33" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "time"] } tracing-appender = "0.2.3" -tracing-opentelemetry = "0.29" +tracing-opentelemetry = "0.30" transform-stream = "0.3.1" url = "2.5.4" uuid = { version = "1.15.1", features = [ diff --git a/config/obs.example.toml b/config/obs.example.toml index 59bd0f344..50d4ae757 100644 --- a/config/obs.example.toml +++ b/config/obs.example.toml @@ -3,7 +3,7 @@ endpoint = "" # Default is "http://localhost:4317" if not specified use_stdout = false sample_ratio = 0.5 meter_interval = 30 -service_name = "rustfs_obs_service" +service_name = "rustfs" service_version = "0.1.0" deployment_environment = "develop" diff --git a/packages/obs/examples/server.rs b/packages/obs/examples/server.rs index 15a64c8be..0af2fcd02 100644 --- a/packages/obs/examples/server.rs +++ b/packages/obs/examples/server.rs @@ -10,6 +10,9 @@ async fn main() { let obs_conf = Some("packages/obs/examples/config.toml".to_string()); let config = load_config(obs_conf); let (_logger, _guard) = init_obs(config.clone()).await; + let span = tracing::span!(Level::INFO, "main"); + let _enter = span.enter(); + info!("Program starts"); // Simulate the operation tokio::time::sleep(Duration::from_millis(100)).await; run( @@ -28,7 +31,7 @@ async fn run(bucket: String, object: String, user: String, service_name: String) info!("Log module initialization is completed service_name: {:?}", service_name); // Record Metrics - let meter = global::meter("rustfs.rs"); + let meter = global::meter("rustfs"); let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); request_duration.record( start_time.elapsed().unwrap().as_secs_f64(), @@ -59,9 +62,9 @@ async fn run(bucket: String, object: String, user: String, service_name: String) #[instrument(fields(bucket, object, user))] async fn put_object(bucket: String, object: String, user: String) { let start_time = SystemTime::now(); - info!("Starting put_object operation"); + info!("Starting put_object operation time: {:?}", start_time); - let meter = global::meter("rustfs.rs"); + let meter = global::meter("rustfs"); let request_duration = meter.f64_histogram("s3_request_duration_seconds").build(); request_duration.record( start_time.elapsed().unwrap().as_secs_f64(), diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 787ee8c99..08e10859b 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -107,29 +107,29 @@ fn print_server_info() { async fn main() -> Result<()> { // Parse the obtained parameters let opt = config::Opt::parse(); - println!("config: {:?}", &opt); - // 设置 trace - // setup_tracing(); + // println!("config: {:?}", &opt); + // Load the configuration file let config = load_config(Some(opt.clone().obs_config)); + // Initialize Observability let (logger, guard) = init_obs(config).await; - // let (logger, guard) = tokio::runtime::Runtime::new()?.block_on(async { init_obs(config).await }); - // let _rr = tokio::runtime::Runtime::new()?.block_on(async { + + // Pack and store the guard + GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| { + error!("Unable to set global tracing guard"); + }); + + // Initialize the logger let start_time = SystemTime::now(); let base_entry = BaseLogEntry::new() .timestamp(chrono::DateTime::from(start_time)) - .message(Some("main init obs end".to_string())) + .message(Some("main init obs start".to_string())) .request_id(Some("main".to_string())); let server_entry = ServerLogEntry::new(Level::INFO, "main_server_entry".to_string()) .with_base(base_entry) .user_id(Some("user_id".to_string())); let _r = logger.lock().await.log_server_entry(server_entry).await; - // }); - // Pack and store the guard - GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| { - error!("Unable to set global tracing guard"); - }); // Run parameters run(opt).await From 23ead0ea999730d9cad28a2f498fd4471da23fec Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 26 Mar 2025 15:18:23 +0800 Subject: [PATCH 017/103] add prometheus --- Cargo.lock | 41 +++++++++++++++++++++++++++++++++-- Cargo.toml | 2 ++ packages/obs/Cargo.toml | 2 ++ packages/obs/src/telemetry.rs | 22 +++++++++++++++---- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 460ba8e12..213aeb0ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4333,6 +4333,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "opentelemetry-prometheus" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ac8c4fc7bd450bcb5b1cbc7325755e86d9f82f1fd80ad8b3441887b715f6a2d" +dependencies = [ + "once_cell", + "opentelemetry", + "opentelemetry_sdk", + "prometheus", + "protobuf 2.28.0", + "tracing", +] + [[package]] name = "opentelemetry-proto" version = "0.29.0" @@ -4961,6 +4975,21 @@ dependencies = [ "version_check", ] +[[package]] +name = "prometheus" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "memchr", + "parking_lot 0.12.3", + "protobuf 2.28.0", + "thiserror 1.0.69", +] + [[package]] name = "prost" version = "0.13.5" @@ -5013,6 +5042,12 @@ dependencies = [ "prost", ] +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" + [[package]] name = "protobuf" version = "3.7.2" @@ -5041,7 +5076,7 @@ dependencies = [ "flatbuffers", "prost", "prost-build", - "protobuf", + "protobuf 3.7.2", "tokio", "tonic", "tonic-build", @@ -5631,7 +5666,7 @@ dependencies = [ "prost", "prost-build", "prost-types", - "protobuf", + "protobuf 3.7.2", "protos", "rmp-serde", "rust-embed", @@ -5691,9 +5726,11 @@ dependencies = [ "opentelemetry", "opentelemetry-appender-tracing", "opentelemetry-otlp", + "opentelemetry-prometheus", "opentelemetry-semantic-conventions", "opentelemetry-stdout", "opentelemetry_sdk", + "prometheus", "rdkafka", "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 150a0e937..4977bc9d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,8 +66,10 @@ opentelemetry-appender-tracing = { version = "0.29.1", features = ["experimental opentelemetry_sdk = { version = "0.29" } opentelemetry-stdout = { version = "0.29.0" } opentelemetry-otlp = { version = "0.29" } +opentelemetry-prometheus = { version = "0.29" } opentelemetry-semantic-conventions = { version = "0.29.0", features = ["semconv_experimental"] } pin-project-lite = "0.2" +prometheus = "0.13.4" # pin-utils = "0.1.0" prost = "0.13.4" prost-build = "0.13.4" diff --git a/packages/obs/Cargo.toml b/packages/obs/Cargo.toml index af3e3480d..4290b76b3 100644 --- a/packages/obs/Cargo.toml +++ b/packages/obs/Cargo.toml @@ -24,7 +24,9 @@ opentelemetry-appender-tracing = { workspace = true, features = ["experimental_u opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] } opentelemetry-stdout = { workspace = true } opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "gzip-tonic"] } +opentelemetry-prometheus = { workspace = true } opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] } +prometheus = { workspace = true } serde = { workspace = true } tracing = { workspace = true, features = ["std", "attributes"] } tracing-core = { workspace = true } diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index 914071903..7d931b922 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -13,6 +13,7 @@ use opentelemetry_semantic_conventions::{ attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_NAME, SERVICE_VERSION}, SCHEMA_URL, }; +use prometheus::Registry; use std::io::IsTerminal; use tracing_error::ErrorLayer; use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; @@ -45,6 +46,13 @@ pub struct OtelGuard { tracer_provider: SdkTracerProvider, meter_provider: SdkMeterProvider, logger_provider: SdkLoggerProvider, + registry: Registry, +} + +impl OtelGuard { + pub fn get_registry(&self) -> &Registry { + &self.registry + } } impl Drop for OtelGuard { @@ -78,7 +86,7 @@ fn resource(config: &OtelConfig) -> Resource { } /// Initialize Meter Provider -fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { +fn init_meter_provider(config: &OtelConfig) -> (SdkMeterProvider, Registry) { let mut builder = MeterProviderBuilder::default().with_resource(resource(config)); // If endpoint is empty, use stdout output if config.endpoint.is_empty() { @@ -109,10 +117,15 @@ fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { ); } } + let registry = Registry::new(); + let prometheus_exporter = opentelemetry_prometheus::exporter() + .with_registry(registry.clone()) + .build() + .unwrap(); - let meter_provider = builder.build(); + let meter_provider = builder.with_reader(prometheus_exporter).build(); global::set_meter_provider(meter_provider.clone()); - meter_provider + (meter_provider, registry) } /// Initialize Tracer Provider @@ -154,7 +167,7 @@ fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { /// Initialize Telemetry pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { let tracer_provider = init_tracer_provider(config); - let meter_provider = init_meter_provider(config); + let (meter_provider, prometheus_registry) = init_meter_provider(config); let tracer = tracer_provider.tracer(config.service_name.clone()); // Initialize logger provider based on configuration @@ -229,5 +242,6 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { tracer_provider, meter_provider, logger_provider, + registry: prometheus_registry, } } From 64d87faaf3f5a287b194f784196f7a0c4a89f60d Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 26 Mar 2025 16:59:34 +0800 Subject: [PATCH 018/103] feat: add metrics_handler --- packages/obs/src/lib.rs | 3 +- packages/obs/src/telemetry.rs | 82 +++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 19 deletions(-) diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index 0db02853f..576edf93e 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -50,7 +50,7 @@ pub use logger::{ pub use logger::{LogError, Logger}; pub use sink::Sink; use std::sync::Arc; -pub use telemetry::init_telemetry; +pub use telemetry::{get_global_registry, init_telemetry, metrics_handler}; use tokio::sync::Mutex; pub use utils::{get_local_ip, get_local_ip_with_default}; pub use worker::start_worker; @@ -86,6 +86,7 @@ pub async fn init_obs(config: AppConfig) -> (Arc>, telemetry::Otel /// # Example /// ``` /// use rustfs_obs::get_logger; +/// /// let logger = get_logger(); /// ``` pub fn get_logger() -> &'static Arc> { diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index 7d931b922..8df3bbf98 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -13,8 +13,11 @@ use opentelemetry_semantic_conventions::{ attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_NAME, SERVICE_VERSION}, SCHEMA_URL, }; -use prometheus::Registry; +use prometheus::{Encoder, Registry, TextEncoder}; use std::io::IsTerminal; +use std::sync::Arc; +use tokio::sync::{Mutex, OnceCell}; +use tracing::{info, warn}; use tracing_error::ErrorLayer; use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer}; @@ -46,13 +49,6 @@ pub struct OtelGuard { tracer_provider: SdkTracerProvider, meter_provider: SdkMeterProvider, logger_provider: SdkLoggerProvider, - registry: Registry, -} - -impl OtelGuard { - pub fn get_registry(&self) -> &Registry { - &self.registry - } } impl Drop for OtelGuard { @@ -69,6 +65,57 @@ impl Drop for OtelGuard { } } +/// Global registry for Prometheus metrics +static GLOBAL_REGISTRY: OnceCell>> = OnceCell::const_new(); + +/// Get the global registry instance +/// This function returns a reference to the global registry instance. +/// +/// # Returns +/// A reference to the global registry instance +/// +/// # Example +/// ``` +/// use rustfs_obs::get_global_registry; +/// +/// let registry = get_global_registry(); +/// ``` +pub fn get_global_registry() -> Arc> { + GLOBAL_REGISTRY.get().unwrap().clone() +} + +/// Prometheus metric endpoints +/// This function returns a string containing the Prometheus metrics. +/// The metrics are collected from the global registry. +/// The function is used to expose the metrics via an HTTP endpoint. +/// +/// # Returns +/// A string containing the Prometheus metrics +/// +/// # Example +/// ``` +/// use rustfs_obs::metrics_handler; +/// +/// async fn main() { +/// let metrics = metrics_handler().await; +/// println!("{}", metrics); +/// } +/// ``` +pub async fn metrics_handler() -> String { + let encoder = TextEncoder::new(); + // Get a reference to the registry for reading metrics + let registry = get_global_registry().lock().await.to_owned(); + let metric_families = registry.gather(); + if metric_families.is_empty() { + warn!("No metrics available in Prometheus registry"); + } else { + info!("Metrics collected: {} families", metric_families.len()); + } + let mut buffer = Vec::new(); + encoder.encode(&metric_families, &mut buffer).unwrap(); + String::from_utf8(buffer).unwrap_or_else(|_| "Error encoding metrics".to_string()) +} + /// create OpenTelemetry Resource fn resource(config: &OtelConfig) -> Resource { Resource::builder() @@ -86,7 +133,7 @@ fn resource(config: &OtelConfig) -> Resource { } /// Initialize Meter Provider -fn init_meter_provider(config: &OtelConfig) -> (SdkMeterProvider, Registry) { +fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { let mut builder = MeterProviderBuilder::default().with_resource(resource(config)); // If endpoint is empty, use stdout output if config.endpoint.is_empty() { @@ -118,14 +165,14 @@ fn init_meter_provider(config: &OtelConfig) -> (SdkMeterProvider, Registry) { } } let registry = Registry::new(); - let prometheus_exporter = opentelemetry_prometheus::exporter() - .with_registry(registry.clone()) - .build() - .unwrap(); - + // Set global registry + GLOBAL_REGISTRY.set(Arc::new(Mutex::new(registry.clone()))).unwrap(); + // Create Prometheus exporter + let prometheus_exporter = opentelemetry_prometheus::exporter().with_registry(registry).build().unwrap(); + // Build meter provider let meter_provider = builder.with_reader(prometheus_exporter).build(); global::set_meter_provider(meter_provider.clone()); - (meter_provider, registry) + meter_provider } /// Initialize Tracer Provider @@ -167,7 +214,7 @@ fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { /// Initialize Telemetry pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { let tracer_provider = init_tracer_provider(config); - let (meter_provider, prometheus_registry) = init_meter_provider(config); + let meter_provider = init_meter_provider(config); let tracer = tracer_provider.tracer(config.service_name.clone()); // Initialize logger provider based on configuration @@ -235,13 +282,12 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { registry.with(ErrorLayer::default()).with(fmt_layer).init(); if !config.endpoint.is_empty() { - tracing::info!("OpenTelemetry telemetry initialized with OTLP endpoint: {}", config.endpoint); + info!("OpenTelemetry telemetry initialized with OTLP endpoint: {}", config.endpoint); } OtelGuard { tracer_provider, meter_provider, logger_provider, - registry: prometheus_registry, } } From 6f706c102e04683d5bcdaef69930453b6ba75634 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 26 Mar 2025 17:26:34 +0800 Subject: [PATCH 019/103] merge main --- rustfs/src/storage/ecfs.rs | 83 ++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 92f32769f..345493059 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -4,10 +4,6 @@ use super::options::extract_metadata; use super::options::put_opts; use crate::auth::get_condition_values; use crate::storage::access::ReqInfo; -use crate::storage::error::to_s3_error; -use crate::storage::options::copy_dst_opts; -use crate::storage::options::copy_src_opts; -use crate::storage::options::{extract_metadata_from_mime, get_opts}; use bytes::Bytes; use common::error::Result; use ecstore::bucket::error::BucketMetadataError; @@ -44,7 +40,12 @@ use futures::pin_mut; use futures::{Stream, StreamExt}; use http::HeaderMap; use lazy_static::lazy_static; +use policy::auth; +use policy::policy::action::Action; +use policy::policy::action::S3Action; use policy::policy::BucketPolicy; +use policy::policy::BucketPolicyArgs; +use policy::policy::Validator; use s3s::dto::*; use s3s::s3_error; use s3s::S3Error; @@ -56,10 +57,18 @@ use std::fmt::Debug; use std::str::FromStr; use tokio_util::io::ReaderStream; use tokio_util::io::StreamReader; -use tracing::{debug, error, info, warn}; +use tracing::debug; +use tracing::error; +use tracing::info; +use tracing::warn; use transform_stream::AsyncTryStream; use uuid::Uuid; +use crate::storage::error::to_s3_error; +use crate::storage::options::copy_dst_opts; +use crate::storage::options::copy_src_opts; +use crate::storage::options::{extract_metadata_from_mime, get_opts}; + macro_rules! try_ { ($result:expr) => { match $result { @@ -554,7 +563,7 @@ impl S3 for FS { let mut req = req; - if authorize_request(&mut req, vec![Action::S3Action(S3Action::ListAllMyBucketsAction)]) + if authorize_request(&mut req, Action::S3Action(S3Action::ListAllMyBucketsAction)) .await .is_err() { @@ -564,10 +573,10 @@ impl S3 for FS { req_info.bucket = Some(info.name.clone()); futures::executor::block_on(async { - authorize_request(&mut req, vec![Action::S3Action(S3Action::ListBucketAction)]) + authorize_request(&mut req, Action::S3Action(S3Action::ListBucketAction)) .await .is_ok() - || authorize_request(&mut req, vec![Action::S3Action(S3Action::GetBucketLocationAction)]) + || authorize_request(&mut req, Action::S3Action(S3Action::GetBucketLocationAction)) .await .is_ok() }) @@ -1214,9 +1223,52 @@ impl S3 for FS { async fn get_bucket_policy_status( &self, - _req: S3Request, + req: S3Request, ) -> S3Result> { - Err(s3_error!(NotImplemented, "GetBucketPolicyStatus is not implemented yet")) + let GetBucketPolicyStatusInput { bucket, .. } = req.input; + + let Some(store) = new_object_layer_fn() else { + return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string())); + }; + + store + .get_bucket_info(&bucket, &BucketOptions::default()) + .await + .map_err(to_s3_error)?; + + let conditions = get_condition_values(&req.headers, &auth::Credentials::default()); + + let read_olny = PolicySys::is_allowed(&BucketPolicyArgs { + bucket: &bucket, + action: Action::S3Action(S3Action::ListBucketAction), + is_owner: false, + account: "", + groups: &None, + conditions: &conditions, + object: "", + }) + .await; + + let write_olny = PolicySys::is_allowed(&BucketPolicyArgs { + bucket: &bucket, + action: Action::S3Action(S3Action::PutObjectAction), + is_owner: false, + account: "", + groups: &None, + conditions: &conditions, + object: "", + }) + .await; + + let is_public = read_olny && write_olny; + + let output = GetBucketPolicyStatusOutput { + policy_status: Some(PolicyStatus { + is_public: Some(is_public), + }), + }; + + Ok(S3Response::new(output)) } async fn get_bucket_policy(&self, req: S3Request) -> S3Result> { @@ -1260,18 +1312,17 @@ impl S3 for FS { // warn!("input policy {}", &policy); - let cfg = BucketPolicy::unmarshal(policy.as_bytes()).map_err(to_s3_error)?; + let cfg: BucketPolicy = + serde_json::from_str(&policy).map_err(|e| s3_error!(InvalidArgument, "parse policy faild {:?}", e))?; - // warn!("parse policy {:?}", &cfg); - - if let Err(err) = cfg.validate(&bucket) { + if let Err(err) = cfg.is_valid() { warn!("put_bucket_policy err input {:?}, {:?}", &policy, err); return Err(s3_error!(InvalidPolicyDocument)); } - let data = cfg.marshal_msg().map_err(to_s3_error)?; + let data = serde_json::to_vec(&cfg).map_err(|e| s3_error!(InternalError, "parse policy faild {:?}", e))?; - metadata_sys::update(&bucket, BUCKET_POLICY_CONFIG, data.into()) + metadata_sys::update(&bucket, BUCKET_POLICY_CONFIG, data) .await .map_err(to_s3_error)?; From c4c6d439bcfabb581cd619da9c131c9e60603195 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 27 Mar 2025 18:03:47 +0800 Subject: [PATCH 020/103] feat(obs): enhance OpenTelemetry configuration and logging Improve observability setup with the following changes: - Replace static OnceCell with tokio::sync::OnceCell for guard management - Add logger_level to OtelConfig for configurable tracing verbosity - Improve telemetry initialization with better error handling - Enhance logging filters and span configuration Breaking Changes: - Configuration now requires logger_level field - Global guard management uses async-safe primitives Example config: observability: endpoint: "http://localhost:4317" logger_level: "debug" # New required field --- config/obs.example.toml | 3 +- packages/obs/src/config.rs | 58 +++++++++++++++---- packages/obs/src/global.rs | 89 ++++++++++++++++++++++++++++ packages/obs/src/lib.rs | 14 ++--- packages/obs/src/logger.rs | 63 +++++++++++++++++++- packages/obs/src/telemetry.rs | 105 +++++++++++++++++++++------------- rustfs/src/main.rs | 47 +++------------ 7 files changed, 281 insertions(+), 98 deletions(-) create mode 100644 packages/obs/src/global.rs diff --git a/config/obs.example.toml b/config/obs.example.toml index 50d4ae757..57f454441 100644 --- a/config/obs.example.toml +++ b/config/obs.example.toml @@ -5,7 +5,8 @@ sample_ratio = 0.5 meter_interval = 30 service_name = "rustfs" service_version = "0.1.0" -deployment_environment = "develop" +environment = "develop" +looger_level = "info" [sinks] [sinks.kafka] # Kafka sink is disabled by default diff --git a/packages/obs/src/config.rs b/packages/obs/src/config.rs index 744c0ec16..3acc2efdb 100644 --- a/packages/obs/src/config.rs +++ b/packages/obs/src/config.rs @@ -1,22 +1,40 @@ +use crate::global::{ENVIRONMENT, LOGGER_LEVEL, METER_INTERVAL, SAMPLE_RATIO, SERVICE_NAME, SERVICE_VERSION}; use config::{Config, File, FileFormat}; use serde::Deserialize; use std::env; /// OpenTelemetry Configuration -/// Add service name, service version, deployment environment +/// Add service name, service version, environment /// Add interval time for metric collection /// Add sample ratio for trace sampling /// Add endpoint for metric collection /// Add use_stdout for output to stdout -#[derive(Debug, Deserialize, Clone, Default)] +/// Add logger level for log level +#[derive(Debug, Deserialize, Clone)] pub struct OtelConfig { pub endpoint: String, - pub use_stdout: bool, - pub sample_ratio: f64, - pub meter_interval: u64, - pub service_name: String, - pub service_version: String, - pub deployment_environment: String, + pub use_stdout: Option, + pub sample_ratio: Option, + pub meter_interval: Option, + pub service_name: Option, + pub service_version: Option, + pub environment: Option, + pub logger_level: Option, +} + +impl Default for OtelConfig { + fn default() -> Self { + OtelConfig { + endpoint: "".to_string(), + use_stdout: Some(true), + sample_ratio: Some(SAMPLE_RATIO), + meter_interval: Some(METER_INTERVAL), + service_name: Some(SERVICE_NAME.to_string()), + service_version: Some(SERVICE_VERSION.to_string()), + environment: Some(ENVIRONMENT.to_string()), + logger_level: Some(LOGGER_LEVEL.to_string()), + } + } } /// Kafka Sink Configuration - Add batch parameters @@ -39,7 +57,7 @@ pub struct WebhookSinkConfig { } /// File Sink Configuration - Add buffering parameters -#[derive(Debug, Deserialize, Clone, Default)] +#[derive(Debug, Deserialize, Clone)] pub struct FileSinkConfig { pub enabled: bool, pub path: String, @@ -48,6 +66,18 @@ pub struct FileSinkConfig { pub flush_threshold: Option, // Refresh threshold, default 100 logs } +impl Default for FileSinkConfig { + fn default() -> Self { + FileSinkConfig { + enabled: true, + path: "logs/app.log".to_string(), + buffer_size: Some(8192), + flush_interval_ms: Some(1000), + flush_threshold: Some(100), + } + } +} + /// Sink configuration collection #[derive(Debug, Deserialize, Clone, Default)] pub struct SinkConfig { @@ -57,11 +87,19 @@ pub struct SinkConfig { } ///Logger Configuration -#[derive(Debug, Deserialize, Clone, Default)] +#[derive(Debug, Deserialize, Clone)] pub struct LoggerConfig { pub queue_capacity: Option, } +impl Default for LoggerConfig { + fn default() -> Self { + LoggerConfig { + queue_capacity: Some(1000), + } + } +} + /// Overall application configuration /// Add observability, sinks, and logger configuration /// diff --git a/packages/obs/src/global.rs b/packages/obs/src/global.rs new file mode 100644 index 000000000..86297b8b4 --- /dev/null +++ b/packages/obs/src/global.rs @@ -0,0 +1,89 @@ +use crate::telemetry::OtelGuard; +use std::sync::{Arc, Mutex}; +use tokio::sync::{OnceCell, SetError}; +use tracing::{error, info}; + +pub(crate) const USE_STDOUT: bool = true; +pub(crate) const SERVICE_NAME: &str = "RustFS"; +pub(crate) const SAMPLE_RATIO: f64 = 1.0; +pub(crate) const METER_INTERVAL: u64 = 60; +pub(crate) const SERVICE_VERSION: &str = "0.1.0"; +pub(crate) const ENVIRONMENT: &str = "development"; +pub(crate) const LOGGER_LEVEL: &str = "info"; + +/// Global guard for OpenTelemetry tracing +static GLOBAL_GUARD: OnceCell>> = OnceCell::const_new(); + +/// Error type for global guard operations +#[derive(Debug, thiserror::Error)] +pub enum GuardError { + #[error("Failed to set global guard: {0}")] + SetError(#[from] SetError>>), + #[error("Global guard not initialized")] + NotInitialized, +} + +/// Set the global guard for OpenTelemetry +/// +/// # Arguments +/// * `guard` - The OtelGuard instance to set globally +/// +/// # Returns +/// * `Ok(())` if successful +/// * `Err(GuardError)` if setting fails +/// +/// # Example +/// ```rust +/// use rustfs_obs::{init_telemetry, load_config, set_global_guard}; +/// +/// async fn init() -> Result<(), Box> { +/// let config = load_config(None); +/// let guard = init_telemetry(&config.observability).await?; +/// set_global_guard(guard)?; +/// Ok(()) +/// } +/// ``` +pub fn set_global_guard(guard: OtelGuard) -> Result<(), GuardError> { + info!("Initializing global OpenTelemetry guard"); + GLOBAL_GUARD.set(Arc::new(Mutex::new(guard))).map_err(GuardError::SetError) +} + +/// Get the global guard for OpenTelemetry +/// +/// # Returns +/// * `Ok(Arc>)` if guard exists +/// * `Err(GuardError)` if guard not initialized +/// +/// # Example +/// ```rust +/// use rustfs_obs::get_global_guard; +/// +/// async fn trace_operation() -> Result<(), Box> { +/// let guard = get_global_guard()?; +/// let _lock = guard.lock().unwrap(); +/// // Perform traced operation +/// Ok(()) +/// } +/// ``` +pub fn get_global_guard() -> Result>, GuardError> { + GLOBAL_GUARD.get().cloned().ok_or(GuardError::NotInitialized) +} + +/// Try to get the global guard for OpenTelemetry +/// +/// # Returns +/// * `Some(Arc>)` if guard exists +/// * `None` if guard not initialized +pub fn try_get_global_guard() -> Option>> { + GLOBAL_GUARD.get().cloned() +} + +#[cfg(test)] +mod tests { + use super::*; + #[tokio::test] + async fn test_get_uninitialized_guard() { + let result = get_global_guard(); + assert!(matches!(result, Err(GuardError::NotInitialized))); + } +} diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index 576edf93e..07c5749e2 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -29,12 +29,12 @@ /// ``` mod config; mod entry; +mod global; mod logger; mod sink; mod telemetry; mod utils; mod worker; - pub use config::load_config; pub use config::{AppConfig, OtelConfig}; pub use entry::args::Args; @@ -42,15 +42,15 @@ pub use entry::audit::{ApiDetails, AuditLogEntry}; pub use entry::base::BaseLogEntry; pub use entry::unified::{ConsoleLogEntry, ServerLogEntry, UnifiedLogEntry}; pub use entry::{LogKind, LogRecord, ObjectVersion, SerializableLevel}; -pub use logger::start_logger; -pub use logger::{ - ensure_logger_initialized, get_global_logger, init_global_logger, locked_logger, log_debug, log_error, log_info, log_trace, - log_warn, log_with_context, -}; +pub use global::{get_global_guard, set_global_guard, try_get_global_guard, GuardError}; +pub use logger::{ensure_logger_initialized, log_debug, log_error, log_info, log_trace, log_warn, log_with_context}; +pub use logger::{get_global_logger, init_global_logger, locked_logger, start_logger}; +pub use logger::{log_init_state, InitLogStatus}; pub use logger::{LogError, Logger}; pub use sink::Sink; use std::sync::Arc; -pub use telemetry::{get_global_registry, init_telemetry, metrics_handler}; +pub use telemetry::init_telemetry; +pub use telemetry::{get_global_registry, metrics}; use tokio::sync::Mutex; pub use utils::{get_local_ip, get_local_ip_with_default}; pub use worker::start_worker; diff --git a/packages/obs/src/logger.rs b/packages/obs/src/logger.rs index 22914a666..77862a942 100644 --- a/packages/obs/src/logger.rs +++ b/packages/obs/src/logger.rs @@ -1,5 +1,7 @@ -use crate::{AppConfig, AuditLogEntry, BaseLogEntry, ConsoleLogEntry, ServerLogEntry, Sink, UnifiedLogEntry}; +use crate::global::{ENVIRONMENT, SERVICE_NAME, SERVICE_VERSION}; +use crate::{AppConfig, AuditLogEntry, BaseLogEntry, ConsoleLogEntry, OtelConfig, ServerLogEntry, Sink, UnifiedLogEntry}; use std::sync::Arc; +use std::time::SystemTime; use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio::sync::{Mutex, OnceCell}; use tracing_core::Level; @@ -471,3 +473,62 @@ pub async fn log_with_context( .write_with_context(message, source, level, request_id, user_id, fields) .await } + +/// Log initialization status +#[derive(Debug)] +pub struct InitLogStatus { + pub timestamp: SystemTime, + pub service_name: String, + pub version: String, + pub environment: String, +} + +impl Default for InitLogStatus { + fn default() -> Self { + Self { + timestamp: SystemTime::now(), + service_name: String::from(SERVICE_NAME), + version: SERVICE_VERSION.to_string(), + environment: ENVIRONMENT.to_string(), + } + } +} + +impl InitLogStatus { + pub fn new_config(config: &OtelConfig) -> Self { + let config = config.clone(); + let environment = config.environment.unwrap_or(ENVIRONMENT.to_string()); + let version = config.service_version.unwrap_or(SERVICE_VERSION.to_string()); + Self { + timestamp: SystemTime::now(), + service_name: String::from(SERVICE_NAME), + version, + environment, + } + } + + pub async fn init_start_log(config: &OtelConfig) -> Result<(), LogError> { + let status = Self::new_config(config); + log_init_state(Some(status)).await + } +} + +/// Log initialization details during system startup +pub async fn log_init_state(status: Option) -> Result<(), LogError> { + let status = status.unwrap_or_default(); + + let base_entry = BaseLogEntry::new() + .timestamp(chrono::DateTime::from(status.timestamp)) + .message(Some(format!( + "Service initialization started - {} v{} in {}", + status.service_name, status.version, status.environment + ))) + .request_id(Some("system_init".to_string())); + + let server_entry = ServerLogEntry::new(Level::INFO, "system_initialization".to_string()) + .with_base(base_entry) + .user_id(Some("system".to_string())); + + get_global_logger().lock().await.log_server_entry(server_entry).await?; + Ok(()) +} diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index 8df3bbf98..f73d9b879 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -1,3 +1,4 @@ +use crate::global::{ENVIRONMENT, LOGGER_LEVEL, METER_INTERVAL, SAMPLE_RATIO, SERVICE_NAME, SERVICE_VERSION, USE_STDOUT}; use crate::{get_local_ip_with_default, OtelConfig}; use opentelemetry::trace::TracerProvider; use opentelemetry::{global, KeyValue}; @@ -10,7 +11,7 @@ use opentelemetry_sdk::{ Resource, }; use opentelemetry_semantic_conventions::{ - attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_NAME, SERVICE_VERSION}, + attribute::{DEPLOYMENT_ENVIRONMENT_NAME, NETWORK_LOCAL_ADDRESS, SERVICE_VERSION as OTEL_SERVICE_VERSION}, SCHEMA_URL, }; use prometheus::{Encoder, Registry, TextEncoder}; @@ -45,6 +46,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilte /// // When it's dropped, all telemetry components are properly shut down /// drop(otel_guard); /// ``` +#[derive(Debug)] pub struct OtelGuard { tracer_provider: SdkTracerProvider, meter_provider: SdkMeterProvider, @@ -94,14 +96,14 @@ pub fn get_global_registry() -> Arc> { /// /// # Example /// ``` -/// use rustfs_obs::metrics_handler; +/// use rustfs_obs::metrics; /// /// async fn main() { -/// let metrics = metrics_handler().await; +/// let metrics = metrics().await; /// println!("{}", metrics); /// } /// ``` -pub async fn metrics_handler() -> String { +pub async fn metrics() -> String { let encoder = TextEncoder::new(); // Get a reference to the registry for reading metrics let registry = get_global_registry().lock().await.to_owned(); @@ -118,13 +120,13 @@ pub async fn metrics_handler() -> String { /// create OpenTelemetry Resource fn resource(config: &OtelConfig) -> Resource { + let config = config.clone(); Resource::builder() - .with_service_name(config.service_name.clone()) + .with_service_name(config.service_name.unwrap_or(SERVICE_NAME.to_string())) .with_schema_url( [ - KeyValue::new(SERVICE_NAME, config.service_name.clone()), - KeyValue::new(SERVICE_VERSION, config.service_version.clone()), - KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, config.deployment_environment.clone()), + KeyValue::new(OTEL_SERVICE_VERSION, config.service_version.unwrap_or(SERVICE_VERSION.to_string())), + KeyValue::new(DEPLOYMENT_ENVIRONMENT_NAME, config.environment.unwrap_or(ENVIRONMENT.to_string())), KeyValue::new(NETWORK_LOCAL_ADDRESS, get_local_ip_with_default()), ], SCHEMA_URL, @@ -132,16 +134,19 @@ fn resource(config: &OtelConfig) -> Resource { .build() } +/// Creates a periodic reader for stdout metrics +fn create_periodic_reader(interval: u64) -> PeriodicReader { + PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()) + .with_interval(std::time::Duration::from_secs(interval)) + .build() +} + /// Initialize Meter Provider fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { let mut builder = MeterProviderBuilder::default().with_resource(resource(config)); // If endpoint is empty, use stdout output if config.endpoint.is_empty() { - builder = builder.with_reader( - PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()) - .with_interval(std::time::Duration::from_secs(config.meter_interval)) - .build(), - ); + builder = builder.with_reader(create_periodic_reader(config.meter_interval.unwrap_or(METER_INTERVAL))); } else { // If endpoint is not empty, use otlp output let exporter = opentelemetry_otlp::MetricExporter::builder() @@ -152,16 +157,12 @@ fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { .unwrap(); builder = builder.with_reader( PeriodicReader::builder(exporter) - .with_interval(std::time::Duration::from_secs(config.meter_interval)) + .with_interval(std::time::Duration::from_secs(config.meter_interval.unwrap_or(METER_INTERVAL))) .build(), ); // If use_stdout is true, output to stdout at the same time - if config.use_stdout { - builder = builder.with_reader( - PeriodicReader::builder(opentelemetry_stdout::MetricExporter::default()) - .with_interval(std::time::Duration::from_secs(config.meter_interval)) - .build(), - ); + if config.use_stdout.unwrap_or(USE_STDOUT) { + builder = builder.with_reader(create_periodic_reader(config.meter_interval.unwrap_or(METER_INTERVAL))); } } let registry = Registry::new(); @@ -177,8 +178,9 @@ fn init_meter_provider(config: &OtelConfig) -> SdkMeterProvider { /// Initialize Tracer Provider fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { - let sampler = if config.sample_ratio > 0.0 && config.sample_ratio < 1.0 { - Sampler::TraceIdRatioBased(config.sample_ratio) + let sample_ratio = config.sample_ratio.unwrap_or(SAMPLE_RATIO); + let sampler = if sample_ratio > 0.0 && sample_ratio < 1.0 { + Sampler::TraceIdRatioBased(sample_ratio) } else { Sampler::AlwaysOn }; @@ -197,7 +199,7 @@ fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { .with_endpoint(&config.endpoint) .build() .unwrap(); - if config.use_stdout { + if config.use_stdout.unwrap_or(USE_STDOUT) { builder .with_batch_exporter(exporter) .with_batch_exporter(opentelemetry_stdout::SpanExporter::default()) @@ -215,7 +217,6 @@ fn init_tracer_provider(config: &OtelConfig) -> SdkTracerProvider { pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { let tracer_provider = init_tracer_provider(config); let meter_provider = init_meter_provider(config); - let tracer = tracer_provider.tracer(config.service_name.clone()); // Initialize logger provider based on configuration let logger_provider = { @@ -235,30 +236,41 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { builder = builder.with_batch_exporter(exporter); // Add stdout exporter if requested - if config.use_stdout { + if config.use_stdout.unwrap_or(USE_STDOUT) { builder = builder.with_batch_exporter(opentelemetry_stdout::LogExporter::default()); } } builder.build() }; - + let config = config.clone(); + let logger_level = config.logger_level.unwrap_or(LOGGER_LEVEL.to_string()); + let logger_level = logger_level.as_str(); // Setup OpenTelemetryTracingBridge layer let otel_layer = { // Filter to prevent infinite telemetry loops // This blocks events from OpenTelemetry and its dependent libraries (tonic, reqwest, etc.) // from being sent back to OpenTelemetry itself - let filter_otel = EnvFilter::new("info") - .add_directive("hyper=off".parse().unwrap()) - .add_directive("opentelemetry=off".parse().unwrap()) - .add_directive("tonic=off".parse().unwrap()) - .add_directive("h2=off".parse().unwrap()) - .add_directive("reqwest=off".parse().unwrap()); + let filter_otel = match logger_level { + "trace" | "debug" => { + info!("OpenTelemetry tracing initialized with level: {}", logger_level); + EnvFilter::new(logger_level) + } + _ => { + let mut filter = EnvFilter::new(logger_level); + for directive in ["hyper", "opentelemetry", "tonic", "h2", "reqwest"] { + filter = filter.add_directive(format!("{}=off", directive).parse().unwrap()); + } + filter + } + }; layer::OpenTelemetryTracingBridge::new(&logger_provider).with_filter(filter_otel) }; + + let tracer = tracer_provider.tracer(config.service_name.unwrap_or(SERVICE_NAME.to_string())); let registry = tracing_subscriber::registry() - .with(tracing_subscriber::filter::LevelFilter::INFO) + .with(switch_level(logger_level)) .with(OpenTelemetryLayer::new(tracer)) .with(MetricsLayer::new(meter_provider.clone())) .with(otel_layer); @@ -271,14 +283,13 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { .with_line_number(true); // Creating a formatting layer with explicit type to avoid type mismatches - let fmt_layer = if config.endpoint.is_empty() { - // Local debug mode: add filter to show OpenTelemetry debug logs - let filter_fmt = EnvFilter::new("info").add_directive("opentelemetry=debug".parse().unwrap()); - fmt_layer.with_filter(filter_fmt) - } else { - // Production mode: use default filter settings - fmt_layer.with_filter(EnvFilter::new("info").add_directive("opentelemetry=off".parse().unwrap())) - }; + let fmt_layer = fmt_layer.with_filter( + EnvFilter::new(logger_level).add_directive( + format!("opentelemetry={}", if config.endpoint.is_empty() { logger_level } else { "off" }) + .parse() + .unwrap(), + ), + ); registry.with(ErrorLayer::default()).with(fmt_layer).init(); if !config.endpoint.is_empty() { @@ -291,3 +302,15 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { logger_provider, } } + +/// Switch log level +fn switch_level(logger_level: &str) -> tracing_subscriber::filter::LevelFilter { + match logger_level { + "error" => tracing_subscriber::filter::LevelFilter::ERROR, + "warn" => tracing_subscriber::filter::LevelFilter::WARN, + "info" => tracing_subscriber::filter::LevelFilter::INFO, + "debug" => tracing_subscriber::filter::LevelFilter::DEBUG, + "trace" => tracing_subscriber::filter::LevelFilter::TRACE, + _ => tracing_subscriber::filter::LevelFilter::OFF, + } +} diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 08e10859b..6c838ac54 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -34,35 +34,18 @@ use hyper_util::{ service::TowerToHyperService, }; use iam::init_iam_sys; -use once_cell::sync::OnceCell; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; -use rustfs_obs::{init_obs, load_config, BaseLogEntry, ServerLogEntry}; +use rustfs_obs::{init_obs, load_config, set_global_guard, InitLogStatus}; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; -use std::time::SystemTime; use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; use tracing::{debug, error, info, info_span, warn}; -use tracing_core::Level; use tracing_error::ErrorLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; -/// Guard that holds a reference to the global observability subsystem. -/// This struct ensures that tracing/logging components remain alive for the -/// application's lifetime. The underlying guard is dropped when this struct -/// is dropped, which may flush logs or perform cleanup operations. -#[allow(dead_code)] -struct TracingGuard(Box); - -impl Drop for TracingGuard { - fn drop(&mut self) { - debug!("Dropping global tracing guard, flushing logs"); - } -} -static GLOBAL_GUARD: OnceCell = OnceCell::new(); - #[allow(dead_code)] fn setup_tracing() { use tracing_subscriber::EnvFilter; @@ -107,34 +90,23 @@ fn print_server_info() { async fn main() -> Result<()> { // Parse the obtained parameters let opt = config::Opt::parse(); - // println!("config: {:?}", &opt); // Load the configuration file let config = load_config(Some(opt.clone().obs_config)); // Initialize Observability - let (logger, guard) = init_obs(config).await; + let (_logger, guard) = init_obs(config.clone()).await; - // Pack and store the guard - GLOBAL_GUARD.set(TracingGuard(Box::new(guard))).unwrap_or_else(|_| { - error!("Unable to set global tracing guard"); - }); + // Store in global storage + set_global_guard(guard)?; - // Initialize the logger - let start_time = SystemTime::now(); - let base_entry = BaseLogEntry::new() - .timestamp(chrono::DateTime::from(start_time)) - .message(Some("main init obs start".to_string())) - .request_id(Some("main".to_string())); - let server_entry = ServerLogEntry::new(Level::INFO, "main_server_entry".to_string()) - .with_base(base_entry) - .user_id(Some("user_id".to_string())); - let _r = logger.lock().await.log_server_entry(server_entry).await; + // Log initialization status + InitLogStatus::init_start_log(&config.observability).await?; // Run parameters run(opt).await } -// + // #[tokio::main] async fn run(opt: config::Opt) -> Result<()> { let span = info_span!("trace-main-run"); @@ -142,7 +114,7 @@ async fn run(opt: config::Opt) -> Result<()> { debug!("opt: {:?}", &opt); - let mut server_addr = net::check_local_server_addr(opt.address.as_str()).unwrap(); + let mut server_addr = net::check_local_server_addr(opt.address.as_str())?; if server_addr.port() == 0 { server_addr.set_port(get_available_port()); @@ -155,8 +127,7 @@ async fn run(opt: config::Opt) -> Result<()> { debug!("server_address {}", &server_address); //设置 AK 和 SK - - iam::init_global_action_cred(Some(opt.access_key.clone()), Some(opt.secret_key.clone())).unwrap(); + iam::init_global_action_cred(Some(opt.access_key.clone()), Some(opt.secret_key.clone()))?; set_global_rustfs_port(server_port); //监听地址,端口从参数中获取 From d12817a772da1701756fef4a87119a9d60dc06d3 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 27 Mar 2025 22:21:10 +0800 Subject: [PATCH 021/103] upgrade docker images --- .docker/observability/README.md | 10 +++++----- .docker/observability/docker-compose.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.docker/observability/README.md b/.docker/observability/README.md index f0bd03fcb..a84f7592d 100644 --- a/.docker/observability/README.md +++ b/.docker/observability/README.md @@ -2,11 +2,11 @@ This directory contains the observability stack for the application. The stack is composed of the following components: -- Prometheus -- Grafana -- Loki -- Jaeger -- Otel Collector +- Prometheus v3.2.1 +- Grafana 11.6.0 +- Loki 3.4.2 +- Jaeger 2.4.0 +- Otel Collector 0.120.0 #0.121.0 remove loki ## Prometheus diff --git a/.docker/observability/docker-compose.yml b/.docker/observability/docker-compose.yml index d6bd19323..f6714bb26 100644 --- a/.docker/observability/docker-compose.yml +++ b/.docker/observability/docker-compose.yml @@ -16,7 +16,7 @@ services: networks: - otel-network jaeger: - image: jaegertracing/jaeger:2.3.0 + image: jaegertracing/jaeger:2.4.0 environment: - TZ=Asia/Shanghai ports: @@ -26,7 +26,7 @@ services: networks: - otel-network prometheus: - image: prom/prometheus:v3.2.0 + image: prom/prometheus:v3.2.1 environment: - TZ=Asia/Shanghai volumes: @@ -42,12 +42,12 @@ services: volumes: - ./loki-config.yaml:/etc/loki/local-config.yaml ports: - - "3100:3100" - command: -config.file=/etc/loki/local-config.yaml + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml networks: - otel-network grafana: - image: grafana/grafana:11.5.2 + image: grafana/grafana:11.6.0 ports: - "3000:3000" # Web UI environment: From 2c8b9a83231947df829c89b6fdfafdfd9e37f9fc Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 27 Mar 2025 23:18:09 +0800 Subject: [PATCH 022/103] webhook add auth_token --- config/obs.example.toml | 3 ++- packages/obs/src/config.rs | 3 ++- packages/obs/src/sink.rs | 26 ++++++++++++++++++-------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/config/obs.example.toml b/config/obs.example.toml index 57f454441..4b107e15e 100644 --- a/config/obs.example.toml +++ b/config/obs.example.toml @@ -18,7 +18,8 @@ batch_timeout_ms = 1000 # Default is 1000ms if not specified [sinks.webhook] enabled = false -url = "http://localhost:8080/webhook" +endpoint = "http://localhost:8080/webhook" +auth_token = "" batch_size = 100 # Default is 3 if not specified batch_timeout_ms = 1000 # Default is 100ms if not specified diff --git a/packages/obs/src/config.rs b/packages/obs/src/config.rs index 3acc2efdb..88078fe4c 100644 --- a/packages/obs/src/config.rs +++ b/packages/obs/src/config.rs @@ -51,7 +51,8 @@ pub struct KafkaSinkConfig { #[derive(Debug, Deserialize, Clone, Default)] pub struct WebhookSinkConfig { pub enabled: bool, - pub url: String, + pub endpoint: String, + pub auth_token: String, pub max_retries: Option, // Maximum number of retry times, default 3 pub retry_delay_ms: Option, // Retry the delay cardinality, default 100ms } diff --git a/packages/obs/src/sink.rs b/packages/obs/src/sink.rs index 8eb1830d7..f362d815f 100644 --- a/packages/obs/src/sink.rs +++ b/packages/obs/src/sink.rs @@ -179,7 +179,8 @@ impl Drop for KafkaSink { #[cfg(feature = "webhook")] /// Webhook Sink Implementation pub struct WebhookSink { - url: String, + endpoint: String, + auth_token: String, client: reqwest::Client, max_retries: usize, retry_delay_ms: u64, @@ -187,9 +188,10 @@ pub struct WebhookSink { #[cfg(feature = "webhook")] impl WebhookSink { - pub fn new(url: String, max_retries: usize, retry_delay_ms: u64) -> Self { + pub fn new(endpoint: String, auth_token: String, max_retries: usize, retry_delay_ms: u64) -> Self { WebhookSink { - url, + endpoint, + auth_token, client: reqwest::Client::builder() .timeout(std::time::Duration::from_secs(10)) .build() @@ -205,11 +207,18 @@ impl WebhookSink { impl Sink for WebhookSink { async fn write(&self, entry: &UnifiedLogEntry) { let mut retries = 0; - let url = self.url.clone(); + let url = self.endpoint.clone(); let entry_clone = entry.clone(); - + let auth_value = reqwest::header::HeaderValue::from_str(format!("Bearer {}", self.auth_token.clone()).as_str()).unwrap(); while retries < self.max_retries { - match self.client.post(&url).json(&entry_clone).send().await { + match self + .client + .post(&url) + .header(reqwest::header::AUTHORIZATION, auth_value.clone()) + .json(&entry_clone) + .send() + .await + { Ok(response) if response.status().is_success() => { return; } @@ -234,7 +243,7 @@ impl Drop for WebhookSink { fn drop(&mut self) { // Perform any necessary cleanup here // For example, you might want to log that the sink is being dropped - eprintln!("Dropping WebhookSink with URL: {}", self.url); + eprintln!("Dropping WebhookSink with URL: {}", self.endpoint); } } @@ -410,7 +419,8 @@ pub fn create_sinks(config: &AppConfig) -> Vec> { #[cfg(feature = "webhook")] if config.sinks.webhook.enabled { sinks.push(Arc::new(WebhookSink::new( - config.sinks.webhook.url.clone(), + config.sinks.webhook.endpoint.clone(), + config.sinks.webhook.auth_token.clone(), config.sinks.webhook.max_retries.unwrap_or(3), config.sinks.webhook.retry_delay_ms.unwrap_or(100), ))); From 4d88af731c36ef22b51d6760abb9f33871ae1ef9 Mon Sep 17 00:00:00 2001 From: weisd Date: Fri, 28 Mar 2025 15:39:53 +0800 Subject: [PATCH 023/103] fix etag bug --- ecstore/src/io.rs | 8 ++++++-- rustfs/src/auth.rs | 6 +++--- scripts/static.sh | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ecstore/src/io.rs b/ecstore/src/io.rs index 764c8834d..3ca27fe0d 100644 --- a/ecstore/src/io.rs +++ b/ecstore/src/io.rs @@ -140,10 +140,14 @@ impl EtagReader { impl AsyncRead for EtagReader { fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll> { + let befor_size = buf.filled().len(); + match Pin::new(&mut self.inner).poll_read(cx, buf) { Poll::Ready(Ok(())) => { - let bytes = buf.filled(); - self.md5.update(bytes); + if buf.filled().len() > befor_size { + let bytes = &buf.filled()[befor_size..]; + self.md5.update(bytes); + } Poll::Ready(Ok(())) } diff --git a/rustfs/src/auth.rs b/rustfs/src/auth.rs index 42d4a464d..3d0425535 100644 --- a/rustfs/src/auth.rs +++ b/rustfs/src/auth.rs @@ -113,15 +113,15 @@ pub fn check_claims_from_token(header: &HeaderMap, cred: &auth::Credentials) -> } if token.is_empty() && cred.is_temp() && !cred.is_service_account() { - return Err(s3_error!(InvalidRequest, "invalid token")); + return Err(s3_error!(InvalidRequest, "invalid token1")); } if !token.is_empty() && !cred.is_temp() { - return Err(s3_error!(InvalidRequest, "invalid token")); + return Err(s3_error!(InvalidRequest, "invalid token2")); } if !cred.is_service_account() && cred.is_temp() && token != cred.session_token { - return Err(s3_error!(InvalidRequest, "invalid token")); + return Err(s3_error!(InvalidRequest, "invalid token3")); } if cred.is_temp() && cred.is_expired() { diff --git a/scripts/static.sh b/scripts/static.sh index 9fd7469d8..814762ecf 100755 --- a/scripts/static.sh +++ b/scripts/static.sh @@ -1 +1 @@ -curl -L "https://dl.rustfs.com/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -o tempfile.zip -d ./rustfs/static && rm tempfile.zip \ No newline at end of file +curl -L "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -o tempfile.zip -d ./rustfs/static && rm tempfile.zip \ No newline at end of file From d516eec200a3a4ee0e96e5df0e5458d3d287a5a8 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 28 Mar 2025 19:03:09 +0800 Subject: [PATCH 024/103] improve code for config and FileSink --- packages/obs/src/config.rs | 26 ++++++++++++++++---------- packages/obs/src/sink.rs | 16 ++++++++++++++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/obs/src/config.rs b/packages/obs/src/config.rs index 88078fe4c..be20c5b0b 100644 --- a/packages/obs/src/config.rs +++ b/packages/obs/src/config.rs @@ -142,14 +142,20 @@ const DEFAULT_CONFIG_FILE: &str = "obs"; /// ``` pub fn load_config(config_dir: Option) -> AppConfig { let config_dir = if let Some(path) = config_dir { - // Use the provided path - let path = std::path::Path::new(&path); - if path.extension().is_some() { - // If path has extension, use it as is (extension will be added by Config::builder) - path.with_extension("").to_string_lossy().into_owned() + // If a path is provided, check if it's empty + if path.is_empty() { + // If empty, use the default config file name + DEFAULT_CONFIG_FILE.to_string() } else { - // If path is a directory, append the default config file name - path.to_string_lossy().into_owned() + // Use the provided path + let path = std::path::Path::new(&path); + if path.extension().is_some() { + // If path has extension, use it as is (extension will be added by Config::builder) + path.with_extension("").to_string_lossy().into_owned() + } else { + // If path is a directory, append the default config file name + path.to_string_lossy().into_owned() + } } } else { // If no path provided, use current directory + default config file @@ -166,11 +172,11 @@ pub fn load_config(config_dir: Option) -> AppConfig { println!("Using config file base: {}", config_dir); let config = Config::builder() - .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Toml)) + .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Toml).required(false)) .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Yaml).required(false)) .add_source(config::Environment::with_prefix("")) .build() - .unwrap(); + .unwrap_or_default(); - config.try_deserialize().unwrap() + config.try_deserialize().unwrap_or_default() } diff --git a/packages/obs/src/sink.rs b/packages/obs/src/sink.rs index f362d815f..cc3aed3e0 100644 --- a/packages/obs/src/sink.rs +++ b/packages/obs/src/sink.rs @@ -4,6 +4,7 @@ use std::sync::Arc; use tokio::fs::OpenOptions; use tokio::io; use tokio::io::AsyncWriteExt; +use tracing::debug; /// Sink Trait definition, asynchronously write logs #[async_trait] @@ -268,8 +269,19 @@ impl FileSink { flush_interval_ms: u64, flush_threshold: usize, ) -> Result { - let file = OpenOptions::new().append(true).create(true).open(&path).await?; - + // check if the file exists + let file_exists = tokio::fs::metadata(&path).await.is_ok(); + let file = if file_exists { + // If the file exists, open it in append mode + debug!("FileSink: File exists, opening in append mode."); + OpenOptions::new().append(true).create(true).open(&path).await? + } else { + // If the file does not exist, create it + debug!("FileSink: File does not exist, creating a new file."); + // Create the file and write a header or initial content if needed + OpenOptions::new().create(true).write(true).open(&path).await? + }; + // let file = OpenOptions::new().append(true).create(true).open(&path).await?; let writer = io::BufWriter::with_capacity(buffer_size, file); let now = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) From f2ebffd0cad3f5ceaa9b4393a3e366937061f175 Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 29 Mar 2025 14:08:33 +0800 Subject: [PATCH 025/103] n --- .github/workflows/build.yml | 52 +++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e11da3cf5..a85336188 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,11 +3,11 @@ name: Build on: workflow_dispatch: schedule: - - cron: '0 0 * * 0' # at midnight of each sunday + - cron: "0 0 * * 0" # at midnight of each sunday push: branches: - main - tags: [ 'v*', '*' ] + tags: ["v*", "*"] jobs: build-rustfs: @@ -16,9 +16,17 @@ jobs: strategy: matrix: variant: - - { profile: dev, target: x86_64-unknown-linux-gnu, glibc: "default" } - - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" } - - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "2.31" } + - { profile: dev, target: x86_64-unknown-linux-gnu, glibc: "default" } + - { + profile: release, + target: x86_64-unknown-linux-gnu, + glibc: "default", + } + - { + profile: release, + target: x86_64-unknown-linux-gnu, + glibc: "2.31", + } steps: - uses: actions/checkout@v4 @@ -51,13 +59,13 @@ jobs: ARTIFACT_NAME="${ARTIFACT_NAME}-glibc${{ matrix.variant.glibc }}" fi echo "artifact_name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT - + # Determine binary path bin_path="target/artifacts/rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.bin" if [ -f "target/artifacts/rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.glibc${{ matrix.variant.glibc }}.bin" ]; then bin_path="target/artifacts/rustfs.${{ matrix.variant.profile }}.${{ matrix.variant.target }}.glibc${{ matrix.variant.glibc }}.bin" fi - + # Create package mkdir -p ${ARTIFACT_NAME} cp "$bin_path" ${ARTIFACT_NAME}/rustfs @@ -69,6 +77,15 @@ jobs: name: ${{ steps.package.outputs.artifact_name }} path: ${{ steps.package.outputs.artifact_name }}.zip retention-days: 7 + - name: Upload to Aliyun OSS + uses: JohnGuan/oss-upload-action@main + with: + key-id: ${{ secrets.ALICLOUDOSS_KEY_ID }} + key-secret: ${{ secrets.ALICLOUDOSS_KEY_SECRET }} + region: oss-cn-beijing + bucket: rustfs-artifacts + assets: | + ${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/ build-rustfs-gui: runs-on: ubuntu-latest @@ -88,7 +105,7 @@ jobs: name: "rustfs-${{ matrix.variant.profile }}-${{ matrix.variant.target }}" - name: Display structure of downloaded files run: | - ls -R + ls -R unzip -o -j "rustfs-${{ matrix.variant.profile }}-${{ matrix.variant.target }}.zip" -d ./cli/rustfs-gui/embedded-rustfs/ ls -la cli/rustfs-gui/embedded-rustfs - name: Cache dioxus-cli @@ -108,12 +125,12 @@ jobs: - name: Build and Bundle rustfs-gui run: | ls -la - + release_path="target/${{ matrix.variant.target }}" mkdir -p ${release_path} cd cli/rustfs-gui ls -la embedded-rustfs - + # Configure the linker based on the target case "${{ matrix.target }}" in "x86_64-unknown-linux-gnu") @@ -140,7 +157,7 @@ jobs: # Validating Environment Variables (for Debugging) echo "CC for ${{ matrix.target }}: $CC_${{ matrix.target }}" echo "Linker for ${{ matrix.target }}: $CARGO_TARGET_${{ matrix.target }}_LINKER" - + if [[ "${{ matrix.variant.target }}" == *"apple-darwin"* ]]; then dx bundle --platform macos --package-types "macos" --package-types "dmg" --package-types "ios" --release --profile release --out-dir ../../${release_path} elif [[ "${{ matrix.variant.target }}" == *"windows-msvc"* ]]; then @@ -159,13 +176,22 @@ jobs: name: ${{ steps.package.outputs.gui_artifact_name }} path: ${{ steps.package.outputs.gui_artifact_name }}.zip retention-days: 7 + - name: Upload to Aliyun OSS + uses: JohnGuan/oss-upload-action@main + with: + key-id: ${{ secrets.ALICLOUDOSS_KEY_ID }} + key-secret: ${{ secrets.ALICLOUDOSS_KEY_SECRET }} + region: oss-cn-beijing + bucket: rustfs-artifacts + assets: | + ${{ steps.package.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/ merge: runs-on: ubuntu-latest - needs: [ build-rustfs, build-rustfs-gui ] + needs: [build-rustfs, build-rustfs-gui] steps: - uses: actions/upload-artifact/merge@v4 with: name: rustfs-packages - pattern: 'rustfs-*' + pattern: "rustfs-*" delete-merged: true From 4b8fcc4b31ad53816394c8bab7708e103ae7a49a Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 29 Mar 2025 14:29:36 +0800 Subject: [PATCH 026/103] fix: filename --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a85336188..bf9399ccc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,7 +85,7 @@ jobs: region: oss-cn-beijing bucket: rustfs-artifacts assets: | - ${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/ + ${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.artifact_name }} build-rustfs-gui: runs-on: ubuntu-latest @@ -184,7 +184,7 @@ jobs: region: oss-cn-beijing bucket: rustfs-artifacts assets: | - ${{ steps.package.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/ + ${{ steps.package.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.gui_artifact_name }}.zip merge: runs-on: ubuntu-latest From 31697a55b654ffd8aa65bef7e3da7aa59682c278 Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 29 Mar 2025 19:38:30 +0800 Subject: [PATCH 027/103] feat: latest zip --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf9399ccc..886a5bc0b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,7 +85,8 @@ jobs: region: oss-cn-beijing bucket: rustfs-artifacts assets: | - ${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.artifact_name }} + ${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.zip + ${{ steps.package.outputs.artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.latest.zip build-rustfs-gui: runs-on: ubuntu-latest @@ -185,6 +186,7 @@ jobs: bucket: rustfs-artifacts assets: | ${{ steps.package.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.gui_artifact_name }}.zip + ${{ steps.package.outputs.gui_artifact_name }}.zip:/artifacts/rustfs/${{ steps.package.outputs.gui_artifact_name }}.latest.zip merge: runs-on: ubuntu-latest From c87e50b002ae89f9c87a23238ba939e086cc6829 Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 30 Mar 2025 21:28:29 +0800 Subject: [PATCH 028/103] improve code for FileSink --- .gitignore | 3 ++- packages/obs/src/global.rs | 2 +- packages/obs/src/lib.rs | 2 +- packages/obs/src/sink.rs | 46 +++++++++++++++----------------------- 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 7017949a1..53e10cf27 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ rustfs/static/* vendor cli/rustfs-gui/embedded-rustfs/rustfs -config/obs.toml \ No newline at end of file +config/obs.toml +*.log \ No newline at end of file diff --git a/packages/obs/src/global.rs b/packages/obs/src/global.rs index 86297b8b4..41c5e555e 100644 --- a/packages/obs/src/global.rs +++ b/packages/obs/src/global.rs @@ -8,7 +8,7 @@ pub(crate) const SERVICE_NAME: &str = "RustFS"; pub(crate) const SAMPLE_RATIO: f64 = 1.0; pub(crate) const METER_INTERVAL: u64 = 60; pub(crate) const SERVICE_VERSION: &str = "0.1.0"; -pub(crate) const ENVIRONMENT: &str = "development"; +pub(crate) const ENVIRONMENT: &str = "production"; pub(crate) const LOGGER_LEVEL: &str = "info"; /// Global guard for OpenTelemetry tracing diff --git a/packages/obs/src/lib.rs b/packages/obs/src/lib.rs index 07c5749e2..843c52367 100644 --- a/packages/obs/src/lib.rs +++ b/packages/obs/src/lib.rs @@ -72,7 +72,7 @@ pub use worker::start_worker; /// ``` pub async fn init_obs(config: AppConfig) -> (Arc>, telemetry::OtelGuard) { let guard = init_telemetry(&config.observability); - let sinks = sink::create_sinks(&config); + let sinks = sink::create_sinks(&config).await; let logger = init_global_logger(&config, sinks).await; (logger, guard) } diff --git a/packages/obs/src/sink.rs b/packages/obs/src/sink.rs index cc3aed3e0..4a44f0ea4 100644 --- a/packages/obs/src/sink.rs +++ b/packages/obs/src/sink.rs @@ -262,7 +262,7 @@ pub struct FileSink { #[cfg(feature = "file")] impl FileSink { - #[allow(dead_code)] + /// Create a new FileSink instance pub async fn new( path: String, buffer_size: usize, @@ -271,6 +271,11 @@ impl FileSink { ) -> Result { // check if the file exists let file_exists = tokio::fs::metadata(&path).await.is_ok(); + // if the file not exists, create it + if !file_exists { + tokio::fs::create_dir_all(std::path::Path::new(&path).parent().unwrap()).await?; + debug!("the file not exists,create if. path: {:?}", path) + } let file = if file_exists { // If the file exists, open it in append mode debug!("FileSink: File exists, opening in append mode."); @@ -281,7 +286,6 @@ impl FileSink { // Create the file and write a header or initial content if needed OpenOptions::new().create(true).write(true).open(&path).await? }; - // let file = OpenOptions::new().append(true).create(true).open(&path).await?; let writer = io::BufWriter::with_capacity(buffer_size, file); let now = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) @@ -406,7 +410,7 @@ impl Drop for FileSink { } /// Create a list of Sink instances -pub fn create_sinks(config: &AppConfig) -> Vec> { +pub async fn create_sinks(config: &AppConfig) -> Vec> { let mut sinks: Vec> = Vec::new(); #[cfg(feature = "kafka")] @@ -445,31 +449,17 @@ pub fn create_sinks(config: &AppConfig) -> Vec> { } else { "default.log".to_string() }; - - // Use synchronous file operations - let file_result = std::fs::OpenOptions::new().append(true).create(true).open(&path); - match file_result { - Ok(file) => { - let buffer_size = config.sinks.file.buffer_size.unwrap_or(8192); - let writer = io::BufWriter::with_capacity(buffer_size, tokio::fs::File::from_std(file)); - - let now = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap() - .as_millis() as u64; - - sinks.push(Arc::new(FileSink { - path: path.clone(), - buffer_size, - writer: Arc::new(tokio::sync::Mutex::new(writer)), - entry_count: std::sync::atomic::AtomicUsize::new(0), - last_flush: std::sync::atomic::AtomicU64::new(now), - flush_interval_ms: config.sinks.file.flush_interval_ms.unwrap_or(1000), - flush_threshold: config.sinks.file.flush_threshold.unwrap_or(100), - })); - } - Err(e) => eprintln!("Failed to create file sink: {}", e), - } + debug!("FileSink: Using path: {}", path); + sinks.push(Arc::new( + FileSink::new( + path.clone(), + config.sinks.file.buffer_size.unwrap_or(8192), + config.sinks.file.flush_interval_ms.unwrap_or(1000), + config.sinks.file.flush_threshold.unwrap_or(100), + ) + .await + .unwrap(), + )); } sinks From 63ef986bacf856ea47ee83bb402c06e5b849d295 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Wed, 12 Mar 2025 13:11:54 +0000 Subject: [PATCH 029/103] tmp1 Signed-off-by: junxiang Mu <1948535941@qq.com> --- Cargo.lock | 1376 +++++- Cargo.toml | 8 +- .../generated/flatbuffers_generated/models.rs | 207 +- .../src/generated/proto_gen/node_service.rs | 3836 ++++------------- s3select/api/Cargo.toml | 10 + s3select/api/src/lib.rs | 52 + s3select/api/src/query/ast.rs | 8 + s3select/api/src/query/datasource/mod.rs | 1 + s3select/api/src/query/dispatcher.rs | 36 + s3select/api/src/query/execution.rs | 253 ++ s3select/api/src/query/function.rs | 23 + s3select/api/src/query/logical_planner.rs | 29 + s3select/api/src/query/mod.rs | 19 + s3select/api/src/query/parser.rs | 8 + s3select/api/src/query/session.rs | 20 + s3select/api/src/server/dbms.rs | 43 + s3select/api/src/server/mod.rs | 1 + s3select/query/Cargo.toml | 12 + s3select/query/src/data_source/data_source.rs | 140 + s3select/query/src/data_source/mod.rs | 1 + s3select/query/src/dispatcher/manager.rs | 331 ++ s3select/query/src/dispatcher/mod.rs | 1 + s3select/query/src/execution/factory.rs | 109 + s3select/query/src/execution/mod.rs | 1 + s3select/query/src/instance.rs | 68 + s3select/query/src/lib.rs | 6 + s3select/query/src/metadata/base_table.rs | 63 + s3select/query/src/metadata/mod.rs | 149 + s3select/query/src/sql/logical/mod.rs | 1 + s3select/query/src/sql/logical/planner.rs | 3 + s3select/query/src/sql/mod.rs | 3 + s3select/query/src/sql/physical/mod.rs | 1 + s3select/query/src/sql/planner.rs | 8 + 33 files changed, 3660 insertions(+), 3167 deletions(-) create mode 100644 s3select/api/Cargo.toml create mode 100644 s3select/api/src/lib.rs create mode 100644 s3select/api/src/query/ast.rs create mode 100644 s3select/api/src/query/datasource/mod.rs create mode 100644 s3select/api/src/query/dispatcher.rs create mode 100644 s3select/api/src/query/execution.rs create mode 100644 s3select/api/src/query/function.rs create mode 100644 s3select/api/src/query/logical_planner.rs create mode 100644 s3select/api/src/query/mod.rs create mode 100644 s3select/api/src/query/parser.rs create mode 100644 s3select/api/src/query/session.rs create mode 100644 s3select/api/src/server/dbms.rs create mode 100644 s3select/api/src/server/mod.rs create mode 100644 s3select/query/Cargo.toml create mode 100644 s3select/query/src/data_source/data_source.rs create mode 100644 s3select/query/src/data_source/mod.rs create mode 100644 s3select/query/src/dispatcher/manager.rs create mode 100644 s3select/query/src/dispatcher/mod.rs create mode 100644 s3select/query/src/execution/factory.rs create mode 100644 s3select/query/src/execution/mod.rs create mode 100644 s3select/query/src/instance.rs create mode 100644 s3select/query/src/lib.rs create mode 100644 s3select/query/src/metadata/base_table.rs create mode 100644 s3select/query/src/metadata/mod.rs create mode 100644 s3select/query/src/sql/logical/mod.rs create mode 100644 s3select/query/src/sql/logical/planner.rs create mode 100644 s3select/query/src/sql/mod.rs create mode 100644 s3select/query/src/sql/physical/mod.rs create mode 100644 s3select/query/src/sql/planner.rs diff --git a/Cargo.lock b/Cargo.lock index 37c39134b..0b4fae4b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,6 +63,20 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "const-random", + "getrandom 0.2.15", + "once_cell", + "version_check", + "zerocopy 0.7.35", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -72,6 +86,27 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -143,6 +178,16 @@ version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +[[package]] +name = "api" +version = "0.0.1" +dependencies = [ + "async-trait", + "datafusion", + "futures", + "snafu", +] + [[package]] name = "arc-swap" version = "1.7.1" @@ -161,12 +206,227 @@ dependencies = [ "password-hash", ] +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + [[package]] name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "arrow" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc208515aa0151028e464cc94a692156e945ce5126abd3537bb7fd6ba2143ed1" +dependencies = [ + "arrow-arith", + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-csv", + "arrow-data", + "arrow-ipc", + "arrow-json", + "arrow-ord", + "arrow-row", + "arrow-schema", + "arrow-select", + "arrow-string", +] + +[[package]] +name = "arrow-arith" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e07e726e2b3f7816a85c6a45b6ec118eeeabf0b2a8c208122ad949437181f49a" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "chrono", + "num", +] + +[[package]] +name = "arrow-array" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2262eba4f16c78496adfd559a29fe4b24df6088efc9985a873d58e92be022d5" +dependencies = [ + "ahash 0.8.11", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "chrono", + "chrono-tz", + "half", + "hashbrown 0.15.2", + "num", +] + +[[package]] +name = "arrow-buffer" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e899dade2c3b7f5642eb8366cfd898958bcca099cde6dfea543c7e8d3ad88d4" +dependencies = [ + "bytes", + "half", + "num", +] + +[[package]] +name = "arrow-cast" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4103d88c5b441525ed4ac23153be7458494c2b0c9a11115848fdb9b81f6f886a" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", + "atoi", + "base64", + "chrono", + "comfy-table", + "half", + "lexical-core", + "num", + "ryu", +] + +[[package]] +name = "arrow-csv" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d3cb0914486a3cae19a5cad2598e44e225d53157926d0ada03c20521191a65" +dependencies = [ + "arrow-array", + "arrow-cast", + "arrow-schema", + "chrono", + "csv", + "csv-core", + "lazy_static", + "regex", +] + +[[package]] +name = "arrow-data" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a329fb064477c9ec5f0870d2f5130966f91055c7c5bce2b3a084f116bc28c3b" +dependencies = [ + "arrow-buffer", + "arrow-schema", + "half", + "num", +] + +[[package]] +name = "arrow-ipc" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddecdeab02491b1ce88885986e25002a3da34dd349f682c7cfe67bab7cc17b86" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "flatbuffers", + "lz4_flex", +] + +[[package]] +name = "arrow-json" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d03b9340013413eb84868682ace00a1098c81a5ebc96d279f7ebf9a4cac3c0fd" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-schema", + "chrono", + "half", + "indexmap 2.7.1", + "lexical-core", + "num", + "serde", + "serde_json", +] + +[[package]] +name = "arrow-ord" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f841bfcc1997ef6ac48ee0305c4dfceb1f7c786fe31e67c1186edf775e1f1160" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", +] + +[[package]] +name = "arrow-row" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eeb55b0a0a83851aa01f2ca5ee5648f607e8506ba6802577afdda9d75cdedcd" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "half", +] + +[[package]] +name = "arrow-schema" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85934a9d0261e0fa5d4e2a5295107d743b543a6e0484a835d4b8db2da15306f9" + +[[package]] +name = "arrow-select" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e2932aece2d0c869dd2125feb9bd1709ef5c445daa3838ac4112dcfa0fda52c" +dependencies = [ + "ahash 0.8.11", + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "num", +] + +[[package]] +name = "arrow-string" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "912e38bd6a7a7714c1d9b61df80315685553b7455e8a6045c27531d8ecd5b458" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", + "memchr", + "num", + "regex", + "regex-syntax 0.8.5", +] + [[package]] name = "ashpd" version = "0.8.1" @@ -229,6 +489,23 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-compression" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06575e6a9673580f52661c92107baabffbf41e2141373441cbcdc47cb733003c" +dependencies = [ + "bzip2", + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", + "xz2", + "zstd", + "zstd-safe", +] + [[package]] name = "async-io" version = "2.4.0" @@ -493,6 +770,19 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bigdecimal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f31f3af01c5c65a07985c804d3366560e6fa7883d640a122819b14ec327482c" +dependencies = [ + "autocfg", + "libm", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -517,6 +807,19 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "blake3" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "675f87afced0413c9bb02843499dbbd3882a237645883f71a2b59644a6d2f753" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + [[package]] name = "block" version = "0.1.6" @@ -572,6 +875,27 @@ dependencies = [ "piper", ] +[[package]] +name = "brotli" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74fa05ad7d803d413eb8380983b092cbbaf9a85f151b871360e7b00cd7060b37" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bumpalo" version = "3.17.0" @@ -605,6 +929,25 @@ dependencies = [ "bytes", ] +[[package]] +name = "bzip2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" +dependencies = [ + "bzip2-sys", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.13+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "cairo-rs" version = "0.18.5" @@ -636,6 +979,8 @@ version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ + "jobserver", + "libc", "shlex", ] @@ -704,9 +1049,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.40" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -714,7 +1059,28 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link", + "windows-targets 0.52.6", +] + +[[package]] +name = "chrono-tz" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c6ac4f2c0bf0f44e9161aec9675e1050aa4a530663c4a9e37e108fa948bca9f" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf 0.11.3", +] + +[[package]] +name = "chrono-tz-build" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7" +dependencies = [ + "parse-zoneinfo", + "phf_codegen 0.11.3", ] [[package]] @@ -871,6 +1237,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "comfy-table" +version = "7.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a65ebfec4fb190b6f90e944a817d60499ee0744e582530e2c9900a22e591d9a" +dependencies = [ + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "common" version = "0.0.1" @@ -908,6 +1284,26 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cb3c4a0d3776f7535c32793be81d6d5fec0d48ac70955d9834e643aa249a52f" +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.15", + "once_cell", + "tiny-keccak", +] + [[package]] name = "const-serialize" version = "0.6.2" @@ -969,6 +1365,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + [[package]] name = "convert_case" version = "0.4.0" @@ -1173,6 +1575,27 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "csv" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" +dependencies = [ + "csv-core", + "itoa 1.0.14", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d02f3b0da4c6504f86e9cd789d8dbafab48c2321be74e9987593de5a894d93d" +dependencies = [ + "memchr", +] + [[package]] name = "ctr" version = "0.9.2" @@ -1202,6 +1625,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.98", ] @@ -1229,12 +1653,505 @@ dependencies = [ "parking_lot_core 0.9.10", ] +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.10", +] + [[package]] name = "data-encoding" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" +[[package]] +name = "datafusion" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46b879c1aa3a85ecbfa376704f0fe4bfebae1a44a5d35faa4466bf85469b6a0e" +dependencies = [ + "arrow", + "arrow-ipc", + "arrow-schema", + "async-trait", + "bytes", + "bzip2", + "chrono", + "datafusion-catalog", + "datafusion-catalog-listing", + "datafusion-common", + "datafusion-common-runtime", + "datafusion-datasource", + "datafusion-execution", + "datafusion-expr", + "datafusion-expr-common", + "datafusion-functions", + "datafusion-functions-aggregate", + "datafusion-functions-nested", + "datafusion-functions-table", + "datafusion-functions-window", + "datafusion-macros", + "datafusion-optimizer", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "datafusion-physical-optimizer", + "datafusion-physical-plan", + "datafusion-sql", + "flate2", + "futures", + "itertools 0.14.0", + "log", + "object_store", + "parking_lot 0.12.3", + "parquet", + "rand 0.8.5", + "regex", + "sqlparser", + "tempfile", + "tokio", + "url", + "uuid", + "xz2", + "zstd", +] + +[[package]] +name = "datafusion-catalog" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e42f516243fe30137f2b7d5712611286baf8d1d758a46157bada7c35fdf38df" +dependencies = [ + "arrow", + "async-trait", + "dashmap 6.1.0", + "datafusion-common", + "datafusion-execution", + "datafusion-expr", + "datafusion-physical-plan", + "datafusion-sql", + "futures", + "itertools 0.14.0", + "log", + "parking_lot 0.12.3", +] + +[[package]] +name = "datafusion-catalog-listing" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e495290c231d617f0a940860a885cb2f4c3efe46c1983c30d3fa12faf1ccb208" +dependencies = [ + "arrow", + "async-trait", + "datafusion-catalog", + "datafusion-common", + "datafusion-datasource", + "datafusion-execution", + "datafusion-expr", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "datafusion-physical-plan", + "futures", + "log", + "object_store", + "tokio", +] + +[[package]] +name = "datafusion-common" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af67ddc82e1c8e6843c326ca13aa20e5420cce9f886b4e1ee39ea43defae3145" +dependencies = [ + "ahash 0.8.11", + "arrow", + "arrow-ipc", + "base64", + "half", + "hashbrown 0.14.5", + "indexmap 2.7.1", + "libc", + "log", + "object_store", + "parquet", + "paste", + "recursive", + "sqlparser", + "tokio", + "web-time", +] + +[[package]] +name = "datafusion-common-runtime" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ee9403a2ec39183437825d232f556a5dee89f13f6fd78f8c7f8f999489e4ca" +dependencies = [ + "log", + "tokio", +] + +[[package]] +name = "datafusion-datasource" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c8b7568b638dd309bcc1cdeb66776f233b110d44bdc6fd67ef1919f9ec9803" +dependencies = [ + "arrow", + "async-compression", + "async-trait", + "bytes", + "bzip2", + "chrono", + "datafusion-catalog", + "datafusion-common", + "datafusion-common-runtime", + "datafusion-execution", + "datafusion-expr", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "datafusion-physical-plan", + "flate2", + "futures", + "glob", + "itertools 0.14.0", + "log", + "object_store", + "rand 0.8.5", + "tokio", + "tokio-util", + "url", + "xz2", + "zstd", +] + +[[package]] +name = "datafusion-doc" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8612c81304578a2e2b82d31caf8173312cb086a7a23a23556b9fff3ac7c18221" + +[[package]] +name = "datafusion-execution" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3591e6d4900e57bad7f861f14f5c763f716da76553b0d037ec91c192c876f09c" +dependencies = [ + "arrow", + "dashmap 6.1.0", + "datafusion-common", + "datafusion-expr", + "futures", + "log", + "object_store", + "parking_lot 0.12.3", + "rand 0.8.5", + "tempfile", + "url", +] + +[[package]] +name = "datafusion-expr" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033d0f6198d177f50a7721d80db141af15dd12f45ad6dce34e2cdbb6538e39d" +dependencies = [ + "arrow", + "chrono", + "datafusion-common", + "datafusion-doc", + "datafusion-expr-common", + "datafusion-functions-aggregate-common", + "datafusion-functions-window-common", + "datafusion-physical-expr-common", + "indexmap 2.7.1", + "paste", + "recursive", + "serde_json", + "sqlparser", +] + +[[package]] +name = "datafusion-expr-common" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56def48a7dfb9f92aa18e18dfdffaca79b5383f03c59bb0107959c1698634557" +dependencies = [ + "arrow", + "datafusion-common", + "indexmap 2.7.1", + "itertools 0.14.0", + "paste", +] + +[[package]] +name = "datafusion-functions" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a79b703b42b0aac97485b84c6810c78114b0974a75a33514840ba0bbe0de38f" +dependencies = [ + "arrow", + "arrow-buffer", + "base64", + "blake2", + "blake3", + "chrono", + "datafusion-common", + "datafusion-doc", + "datafusion-execution", + "datafusion-expr", + "datafusion-expr-common", + "datafusion-macros", + "hex", + "itertools 0.14.0", + "log", + "md-5", + "rand 0.8.5", + "regex", + "sha2 0.10.8", + "unicode-segmentation", + "uuid", +] + +[[package]] +name = "datafusion-functions-aggregate" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdad20375e85365ed262b5583955c308840efc6ff9271ff463cf86789adfb686" +dependencies = [ + "ahash 0.8.11", + "arrow", + "datafusion-common", + "datafusion-doc", + "datafusion-execution", + "datafusion-expr", + "datafusion-functions-aggregate-common", + "datafusion-macros", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "half", + "log", + "paste", +] + +[[package]] +name = "datafusion-functions-aggregate-common" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff73249ee3cdc81ad04317d3b4231fc02a8c03a3a1b4b13953244e6443f6b498" +dependencies = [ + "ahash 0.8.11", + "arrow", + "datafusion-common", + "datafusion-expr-common", + "datafusion-physical-expr-common", +] + +[[package]] +name = "datafusion-functions-nested" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20dcd70c58f17b7ce937866e43c75293a3250aadc1db830ad6d502967aaffb40" +dependencies = [ + "arrow", + "arrow-ord", + "datafusion-common", + "datafusion-doc", + "datafusion-execution", + "datafusion-expr", + "datafusion-functions", + "datafusion-functions-aggregate", + "datafusion-macros", + "datafusion-physical-expr-common", + "itertools 0.14.0", + "log", + "paste", +] + +[[package]] +name = "datafusion-functions-table" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac12628c3e43461118e95d5772f729e1cc39db883d8ee52e4b80038b0f614bbf" +dependencies = [ + "arrow", + "async-trait", + "datafusion-catalog", + "datafusion-common", + "datafusion-expr", + "datafusion-physical-plan", + "parking_lot 0.12.3", + "paste", +] + +[[package]] +name = "datafusion-functions-window" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03eb449555c7cc03bb61d43d90edef70d070d34bc4a0d8f7e358d157232f3220" +dependencies = [ + "datafusion-common", + "datafusion-doc", + "datafusion-expr", + "datafusion-functions-window-common", + "datafusion-macros", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "log", + "paste", +] + +[[package]] +name = "datafusion-functions-window-common" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a0c7606e568ee6a15d33a2532eb0d18e7769bb88af55f6b70be4db9fd937d18" +dependencies = [ + "datafusion-common", + "datafusion-physical-expr-common", +] + +[[package]] +name = "datafusion-macros" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64030e805d3d257e3012e4378500d4ac90b1ebacd03f1110e8ec927b77f09486" +dependencies = [ + "datafusion-expr", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "datafusion-optimizer" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae6af7bdae7565aa7a4cb1deb7fe18d89c63c5d93b5203b473ca1dbe02a1cd3d" +dependencies = [ + "arrow", + "chrono", + "datafusion-common", + "datafusion-expr", + "datafusion-physical-expr", + "indexmap 2.7.1", + "itertools 0.14.0", + "log", + "recursive", + "regex", + "regex-syntax 0.8.5", +] + +[[package]] +name = "datafusion-physical-expr" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f68601feda90c255c9023a881e833efca9d7539bab0565ac1355b0249326e91" +dependencies = [ + "ahash 0.8.11", + "arrow", + "datafusion-common", + "datafusion-expr", + "datafusion-expr-common", + "datafusion-functions-aggregate-common", + "datafusion-physical-expr-common", + "half", + "hashbrown 0.14.5", + "indexmap 2.7.1", + "itertools 0.14.0", + "log", + "paste", + "petgraph", +] + +[[package]] +name = "datafusion-physical-expr-common" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c1a08b00d340ca3bc1cd2f094ecaeaf6f099a2980e11255976660fa0409182" +dependencies = [ + "ahash 0.8.11", + "arrow", + "datafusion-common", + "datafusion-expr-common", + "hashbrown 0.14.5", + "itertools 0.14.0", +] + +[[package]] +name = "datafusion-physical-optimizer" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd34f3438cf9629ea0e3425027582334fb6671a05ee43671ca3c47896b75dda" +dependencies = [ + "arrow", + "datafusion-common", + "datafusion-execution", + "datafusion-expr", + "datafusion-expr-common", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "datafusion-physical-plan", + "itertools 0.14.0", + "log", + "recursive", +] + +[[package]] +name = "datafusion-physical-plan" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7624484ada341d30ef465eae61f760e779f080c621bbc3dc0335a75fa78e8dec" +dependencies = [ + "ahash 0.8.11", + "arrow", + "arrow-ord", + "arrow-schema", + "async-trait", + "chrono", + "datafusion-common", + "datafusion-common-runtime", + "datafusion-execution", + "datafusion-expr", + "datafusion-functions-window-common", + "datafusion-physical-expr", + "datafusion-physical-expr-common", + "futures", + "half", + "hashbrown 0.14.5", + "indexmap 2.7.1", + "itertools 0.14.0", + "log", + "parking_lot 0.12.3", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "datafusion-sql" +version = "46.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e717736a394ed92d9dcf2d74439c655474dd39aa65a064a6bae697b6d20e5fe" +dependencies = [ + "arrow", + "bigdecimal", + "datafusion-common", + "datafusion-expr", + "indexmap 2.7.1", + "log", + "recursive", + "regex", + "sqlparser", +] + [[package]] name = "dbus" version = "0.9.7" @@ -1269,6 +2186,37 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.98", +] + [[package]] name = "derive_more" version = "0.99.19" @@ -2686,6 +3634,7 @@ checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", + "num-traits", ] [[package]] @@ -2694,7 +3643,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", ] [[package]] @@ -2702,6 +3651,10 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] [[package]] name = "hashbrown" @@ -2940,7 +3893,7 @@ dependencies = [ "ecstore", "futures", "ipnetwork", - "itertools", + "itertools 0.14.0", "jsonwebtoken", "lazy_static", "log", @@ -3174,6 +4127,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "integer-encoding" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" + [[package]] name = "ipnet" version = "2.11.0" @@ -3201,6 +4160,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -3267,6 +4235,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -3342,6 +4319,70 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lexical-core" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b765c31809609075565a70b4b71402281283aeda7ecaf4818ac14a7b2ade8958" +dependencies = [ + "lexical-parse-float", + "lexical-parse-integer", + "lexical-util", + "lexical-write-float", + "lexical-write-integer", +] + +[[package]] +name = "lexical-parse-float" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de6f9cb01fb0b08060209a057c048fcbab8717b4c1ecd2eac66ebfe39a65b0f2" +dependencies = [ + "lexical-parse-integer", + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-parse-integer" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72207aae22fc0a121ba7b6d479e42cbfea549af1479c3f3a4f12c70dd66df12e" +dependencies = [ + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-util" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a82e24bf537fd24c177ffbbdc6ebcc8d54732c35b50a3f28cc3f4e4c949a0b3" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "lexical-write-float" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5afc668a27f460fb45a81a757b6bf2f43c2d7e30cb5a2dcd3abf294c78d62bd" +dependencies = [ + "lexical-util", + "lexical-write-integer", + "static_assertions", +] + +[[package]] +name = "lexical-write-integer" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "629ddff1a914a836fb245616a7888b62903aae58fa771e1d83943035efa0f978" +dependencies = [ + "lexical-util", + "static_assertions", +] + [[package]] name = "libappindicator" version = "0.9.0" @@ -3511,6 +4552,26 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "lz4_flex" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" +dependencies = [ + "twox-hash", +] + +[[package]] +name = "lzma-sys" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "mac" version = "0.1.1" @@ -3925,6 +4986,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -4174,6 +5236,27 @@ dependencies = [ "memchr", ] +[[package]] +name = "object_store" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cfccb68961a56facde1163f9319e0d15743352344e7808a11795fb99698dcaf" +dependencies = [ + "async-trait", + "bytes", + "chrono", + "futures", + "humantime", + "itertools 0.13.0", + "parking_lot 0.12.3", + "percent-encoding", + "snafu", + "tokio", + "tracing", + "url", + "walkdir", +] + [[package]] name = "once_cell" version = "1.20.3" @@ -4192,6 +5275,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-stream" version = "0.2.0" @@ -4293,6 +5385,52 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "parquet" +version = "54.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f88838dca3b84d41444a0341b19f347e8098a3898b0f21536654b8b799e11abd" +dependencies = [ + "ahash 0.8.11", + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-ipc", + "arrow-schema", + "arrow-select", + "base64", + "brotli", + "bytes", + "chrono", + "flate2", + "futures", + "half", + "hashbrown 0.15.2", + "lz4_flex", + "num", + "num-bigint", + "object_store", + "paste", + "seq-macro", + "simdutf8", + "snap", + "thrift", + "tokio", + "twox-hash", + "zstd", + "zstd-sys", +] + +[[package]] +name = "parse-zoneinfo" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24" +dependencies = [ + "regex", +] + [[package]] name = "password-hash" version = "0.5.0" @@ -4390,6 +5528,15 @@ dependencies = [ "phf_shared 0.10.0", ] +[[package]] +name = "phf" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +dependencies = [ + "phf_shared 0.11.3", +] + [[package]] name = "phf_codegen" version = "0.8.0" @@ -4410,6 +5557,16 @@ dependencies = [ "phf_shared 0.10.0", ] +[[package]] +name = "phf_codegen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" +dependencies = [ + "phf_generator 0.11.3", + "phf_shared 0.11.3", +] + [[package]] name = "phf_generator" version = "0.8.0" @@ -4748,7 +5905,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" dependencies = [ "heck 0.5.0", - "itertools", + "itertools 0.14.0", "log", "multimap", "once_cell", @@ -4768,7 +5925,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools", + "itertools 0.14.0", "proc-macro2", "quote", "syn 2.0.98", @@ -4818,6 +5975,27 @@ dependencies = [ "tower 0.5.2", ] +[[package]] +name = "psm" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58e5423e24c18cc840e1c98370b3993c6649cd1678b4d24318bcf0a083cbe88" +dependencies = [ + "cc", +] + +[[package]] +name = "query" +version = "0.0.1" +dependencies = [ + "api", + "async-trait", + "datafusion", + "derive_builder", + "tokio", + "tracing", +] + [[package]] name = "quick-xml" version = "0.37.2" @@ -4877,7 +6055,7 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5012,6 +6190,42 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" +[[package]] +name = "reader" +version = "0.0.1" +dependencies = [ + "bytes", + "futures", + "hex-simd", + "md-5", + "pin-project-lite", + "s3s", + "sha2 0.11.0-pre.4", + "thiserror 2.0.11", + "tokio", + "tracing", +] + +[[package]] +name = "recursive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0786a43debb760f491b1bc0269fe5e84155353c67482b9e60d0cfb596054b43e" +dependencies = [ + "recursive-proc-macro-impl", + "stacker", +] + +[[package]] +name = "recursive-proc-macro-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76009fbe0614077fc1a2ce255e3a1881a2e3a3527097d5dc6d8212c585e7e38b" +dependencies = [ + "quote", + "syn 2.0.98", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -5610,6 +6824,12 @@ dependencies = [ "futures-core", ] +[[package]] +name = "seq-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" + [[package]] name = "serde" version = "1.0.218" @@ -5714,7 +6934,7 @@ checksum = "4fae7a3038a32e5a34ba32c6c45eb4852f8affaf8b794ebfcd4b1099e2d62ebe" dependencies = [ "bytes", "const_format", - "dashmap", + "dashmap 5.5.3", "futures", "gloo-net", "http", @@ -5957,6 +7177,34 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +[[package]] +name = "snafu" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "223891c85e2a29c3fe8fb900c1fae5e69c2e42415e3177752e8718475efa5019" +dependencies = [ + "backtrace", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c3c6b7927ffe7ecaa769ee0e3994da3b8cafc8f444578982c83ecb161af917" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "snap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" + [[package]] name = "socket2" version = "0.5.8" @@ -5999,12 +7247,47 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "sqlparser" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66e3b7374ad4a6af849b08b3e7a6eda0edbd82f0fd59b57e22671bf16979899" +dependencies = [ + "log", + "recursive", + "sqlparser_derive", +] + +[[package]] +name = "sqlparser_derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da5fc6819faabb412da764b99d3b713bb55083c11e7e0c00144d386cd6a1939c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "stacker" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9156ebd5870ef293bfb43f91c7a74528d363ec0d424afe24160ed5a4343d08a" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.59.0", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -6327,6 +7610,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "thrift" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" +dependencies = [ + "byteorder", + "integer-encoding", + "ordered-float", +] + [[package]] name = "time" version = "0.3.37" @@ -6360,6 +7654,15 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -6790,6 +8093,16 @@ dependencies = [ "utf-8", ] +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + [[package]] name = "typenum" version = "1.18.0" @@ -6825,6 +8138,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -6896,9 +8215,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587" dependencies = [ "getrandom 0.3.1", + "js-sys", "rand 0.9.0", "serde", "uuid-macro-internal", + "wasm-bindgen", ] [[package]] @@ -7737,6 +9058,15 @@ version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" +[[package]] +name = "xz2" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" +dependencies = [ + "lzma-sys", +] + [[package]] name = "yoke" version = "0.7.5" @@ -7965,6 +9295,34 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.13+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "zvariant" version = "4.2.0" diff --git a/Cargo.toml b/Cargo.toml index 9e3e80616..e581661c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ members = [ "iam", # Identity and Access Management "crypto", # Cryptography and security features "cli/rustfs-gui", # Graphical user interface client + "s3select/api", + "s3select/query", ] resolver = "2" @@ -33,8 +35,10 @@ async-trait = "0.1.86" backon = "1.3.0" bytes = "1.9.0" bytesize = "1.3.0" -chrono = { version = "0.4.40", features = ["serde"] } +chrono = { version = "0.4.39", features = ["serde"] } clap = { version = "4.5.31", features = ["derive", "env"] } +datafusion = "46.0.0" +derive_builder = "0.20.2" dioxus = { version = "0.6.3", features = ["router"] } dirs = "6.0.0" ecstore = { path = "./ecstore" } @@ -112,7 +116,7 @@ md-5 = "0.10.6" workers = { path = "./common/workers" } test-case = "3.3.1" zip = "2.2.3" - +snafu = "0.8.5" [profile.wasm-dev] diff --git a/common/protos/src/generated/flatbuffers_generated/models.rs b/common/protos/src/generated/flatbuffers_generated/models.rs index aa1f6ae2f..e4949fdcf 100644 --- a/common/protos/src/generated/flatbuffers_generated/models.rs +++ b/common/protos/src/generated/flatbuffers_generated/models.rs @@ -1,10 +1,9 @@ // automatically generated by the FlatBuffers compiler, do not modify - // @generated -use core::mem; use core::cmp::Ordering; +use core::mem; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -12,112 +11,114 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod models { - use core::mem; - use core::cmp::Ordering; + use core::cmp::Ordering; + use core::mem; - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; -pub enum PingBodyOffset {} -#[derive(Copy, Clone, PartialEq)] + 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: 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> { - let mut builder = PingBodyBuilder::new(_fbb); - if let Some(x) = args.payload { builder.add_payload(x); } - builder.finish() - } - - - #[inline] - pub fn payload(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? - .finish(); - Ok(()) - } -} -pub struct PingBodyArgs<'a> { - pub payload: Option>>, -} -impl<'a> Default for PingBodyArgs<'a> { - #[inline] - fn default() -> Self { - PingBodyArgs { - payload: None, + pub struct PingBody<'a> { + pub _tab: flatbuffers::Table<'a>, } - } -} -pub struct PingBodyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { - #[inline] - pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(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, + 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: flatbuffers::Table::new(buf, loc), + } + } } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - 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 + 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> { + let mut builder = PingBodyBuilder::new(_fbb); + if let Some(x) = args.payload { + builder.add_payload(x); + } + builder.finish() + } + + #[inline] + pub fn payload(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? + .finish(); + Ok(()) + } + } + pub struct PingBodyArgs<'a> { + pub payload: Option>>, + } + 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, + } + impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { + #[inline] + pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { + self.fbb_ + .push_slot_always::>(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> { + 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 diff --git a/common/protos/src/generated/proto_gen/node_service.rs b/common/protos/src/generated/proto_gen/node_service.rs index 88f7b3ab0..000d5b486 100644 --- a/common/protos/src/generated/proto_gen/node_service.rs +++ b/common/protos/src/generated/proto_gen/node_service.rs @@ -622,10 +622,7 @@ pub struct GenerallyLockResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct Mss { #[prost(map = "string, string", tag = "1")] - pub value: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub value: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LocalStorageInfoRequest { @@ -789,10 +786,7 @@ pub struct DownloadProfileDataResponse { #[prost(bool, tag = "1")] pub success: bool, #[prost(map = "string, bytes", tag = "2")] - pub data: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::vec::Vec, - >, + pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec>, #[prost(string, optional, tag = "3")] pub error_info: ::core::option::Option<::prost::alloc::string::String>, } @@ -1059,15 +1053,9 @@ pub struct LoadTransitionTierConfigResponse { } /// Generated client implementations. pub mod node_service_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; + #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct NodeServiceClient { inner: tonic::client::Grpc, @@ -1098,22 +1086,16 @@ pub mod node_service_client { let inner = tonic::client::Grpc::with_origin(inner, origin); Self { inner } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> NodeServiceClient> + pub fn with_interceptor(inner: T, interceptor: F) -> NodeServiceClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, - Response = http::Response< - >::ResponseBody, - >, + Response = http::Response<>::ResponseBody>, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { NodeServiceClient::new(InterceptedService::new(inner, interceptor)) } @@ -1156,15 +1138,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Ping", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Ping"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Ping")); @@ -1173,22 +1149,13 @@ pub mod node_service_client { pub async fn heal_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/HealBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/HealBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "HealBucket")); @@ -1197,22 +1164,13 @@ pub mod node_service_client { pub async fn list_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListBucket")); @@ -1221,22 +1179,13 @@ pub mod node_service_client { pub async fn make_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeBucket")); @@ -1245,22 +1194,13 @@ pub mod node_service_client { pub async fn get_bucket_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetBucketInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketInfo")); @@ -1269,22 +1209,13 @@ pub mod node_service_client { pub async fn delete_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucket")); @@ -1293,22 +1224,13 @@ pub mod node_service_client { pub async fn read_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadAll", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAll"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAll")); @@ -1317,22 +1239,13 @@ pub mod node_service_client { pub async fn write_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteAll", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteAll"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteAll")); @@ -1345,15 +1258,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Delete", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Delete"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Delete")); @@ -1362,22 +1269,13 @@ pub mod node_service_client { pub async fn verify_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/VerifyFile", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/VerifyFile"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "VerifyFile")); @@ -1386,22 +1284,13 @@ pub mod node_service_client { pub async fn check_parts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/CheckParts", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/CheckParts"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "CheckParts")); @@ -1410,22 +1299,13 @@ pub mod node_service_client { pub async fn rename_part( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenamePart", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenamePart"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenamePart")); @@ -1434,22 +1314,13 @@ pub mod node_service_client { pub async fn rename_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenameFile", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameFile"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameFile")); @@ -1462,15 +1333,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Write", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Write"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Write")); @@ -1479,22 +1344,13 @@ pub mod node_service_client { pub async fn write_stream( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteStream", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteStream"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteStream")); @@ -1504,22 +1360,13 @@ pub mod node_service_client { pub async fn read_at( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadAt", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAt"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAt")); @@ -1528,22 +1375,13 @@ pub mod node_service_client { pub async fn list_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListDir", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListDir"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListDir")); @@ -1552,22 +1390,13 @@ pub mod node_service_client { pub async fn walk_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WalkDir", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WalkDir"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WalkDir")); @@ -1576,22 +1405,13 @@ pub mod node_service_client { pub async fn rename_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenameData", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameData"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameData")); @@ -1600,22 +1420,13 @@ pub mod node_service_client { pub async fn make_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeVolumes", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolumes"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolumes")); @@ -1624,22 +1435,13 @@ pub mod node_service_client { pub async fn make_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolume")); @@ -1648,22 +1450,13 @@ pub mod node_service_client { pub async fn list_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListVolumes", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListVolumes"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListVolumes")); @@ -1672,22 +1465,13 @@ pub mod node_service_client { pub async fn stat_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StatVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StatVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StatVolume")); @@ -1696,22 +1480,13 @@ pub mod node_service_client { pub async fn delete_paths( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeletePaths", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePaths"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePaths")); @@ -1720,22 +1495,13 @@ pub mod node_service_client { pub async fn update_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UpdateMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetadata"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetadata")); @@ -1744,22 +1510,13 @@ pub mod node_service_client { pub async fn write_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteMetadata"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteMetadata")); @@ -1768,22 +1525,13 @@ pub mod node_service_client { pub async fn read_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadVersion", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadVersion"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadVersion")); @@ -1796,15 +1544,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadXL", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadXL"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadXL")); @@ -1813,22 +1555,13 @@ pub mod node_service_client { pub async fn delete_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVersion", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersion"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersion")); @@ -1837,22 +1570,13 @@ pub mod node_service_client { pub async fn delete_versions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVersions", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersions"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersions")); @@ -1861,22 +1585,13 @@ pub mod node_service_client { pub async fn read_multiple( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadMultiple", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadMultiple"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadMultiple")); @@ -1885,22 +1600,13 @@ pub mod node_service_client { pub async fn delete_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVolume")); @@ -1909,22 +1615,13 @@ pub mod node_service_client { pub async fn disk_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DiskInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DiskInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DiskInfo")); @@ -1933,22 +1630,13 @@ pub mod node_service_client { pub async fn ns_scanner( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/NsScanner", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/NsScanner"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "NsScanner")); @@ -1957,22 +1645,13 @@ pub mod node_service_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Lock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Lock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Lock")); @@ -1981,22 +1660,13 @@ pub mod node_service_client { pub async fn un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UnLock")); @@ -2005,22 +1675,13 @@ pub mod node_service_client { pub async fn r_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RLock")); @@ -2029,22 +1690,13 @@ pub mod node_service_client { pub async fn r_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RUnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RUnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RUnLock")); @@ -2053,22 +1705,13 @@ pub mod node_service_client { pub async fn force_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ForceUnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ForceUnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ForceUnLock")); @@ -2077,22 +1720,13 @@ pub mod node_service_client { pub async fn refresh( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Refresh", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Refresh"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Refresh")); @@ -2101,22 +1735,13 @@ pub mod node_service_client { pub async fn local_storage_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LocalStorageInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LocalStorageInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LocalStorageInfo")); @@ -2125,22 +1750,13 @@ pub mod node_service_client { pub async fn server_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ServerInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ServerInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ServerInfo")); @@ -2149,22 +1765,13 @@ pub mod node_service_client { pub async fn get_cpus( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetCpus", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetCpus"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetCpus")); @@ -2173,22 +1780,13 @@ pub mod node_service_client { pub async fn get_net_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetNetInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetNetInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetNetInfo")); @@ -2197,22 +1795,13 @@ pub mod node_service_client { pub async fn get_partitions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetPartitions", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetPartitions"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetPartitions")); @@ -2221,22 +1810,13 @@ pub mod node_service_client { pub async fn get_os_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetOsInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetOsInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetOsInfo")); @@ -2245,22 +1825,13 @@ pub mod node_service_client { pub async fn get_se_linux_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSELinuxInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSELinuxInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSELinuxInfo")); @@ -2269,22 +1840,13 @@ pub mod node_service_client { pub async fn get_sys_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSysConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysConfig"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysConfig")); @@ -2293,22 +1855,13 @@ pub mod node_service_client { pub async fn get_sys_errors( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSysErrors", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysErrors"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysErrors")); @@ -2317,22 +1870,13 @@ pub mod node_service_client { pub async fn get_mem_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMemInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMemInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMemInfo")); @@ -2341,22 +1885,13 @@ pub mod node_service_client { pub async fn get_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMetrics", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetrics"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMetrics")); @@ -2365,22 +1900,13 @@ pub mod node_service_client { pub async fn get_proc_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetProcInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetProcInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetProcInfo")); @@ -2389,22 +1915,13 @@ pub mod node_service_client { pub async fn start_profiling( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StartProfiling", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StartProfiling"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StartProfiling")); @@ -2413,48 +1930,28 @@ pub mod node_service_client { pub async fn download_profile_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DownloadProfileData", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DownloadProfileData"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DownloadProfileData"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DownloadProfileData")); self.inner.unary(req, path, codec).await } pub async fn get_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetBucketStats", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketStats"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketStats")); @@ -2463,22 +1960,13 @@ pub mod node_service_client { pub async fn get_sr_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSRMetrics", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSRMetrics"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSRMetrics")); @@ -2487,100 +1975,58 @@ pub mod node_service_client { pub async fn get_all_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetAllBucketStats", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetAllBucketStats"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "GetAllBucketStats"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "GetAllBucketStats")); self.inner.unary(req, path, codec).await } pub async fn load_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadBucketMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadBucketMetadata"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata")); self.inner.unary(req, path, codec).await } pub async fn delete_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteBucketMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucketMetadata"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata")); self.inner.unary(req, path, codec).await } pub async fn delete_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeletePolicy", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePolicy"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePolicy")); @@ -2589,22 +2035,13 @@ pub mod node_service_client { pub async fn load_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadPolicy", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicy"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicy")); @@ -2613,48 +2050,28 @@ pub mod node_service_client { pub async fn load_policy_mapping( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadPolicyMapping", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicyMapping"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping")); self.inner.unary(req, path, codec).await } pub async fn delete_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteUser", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteUser"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteUser")); @@ -2663,48 +2080,28 @@ pub mod node_service_client { pub async fn delete_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteServiceAccount", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteServiceAccount"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount")); self.inner.unary(req, path, codec).await } pub async fn load_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadUser", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadUser"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadUser")); @@ -2713,48 +2110,28 @@ pub mod node_service_client { pub async fn load_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadServiceAccount", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadServiceAccount"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadServiceAccount"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadServiceAccount")); self.inner.unary(req, path, codec).await } pub async fn load_group( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadGroup", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadGroup"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadGroup")); @@ -2763,30 +2140,16 @@ pub mod node_service_client { pub async fn reload_site_replication_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReloadSiteReplicationConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadSiteReplicationConfig"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new( - "node_service.NodeService", - "ReloadSiteReplicationConfig", - ), - ); + .insert(GrpcMethod::new("node_service.NodeService", "ReloadSiteReplicationConfig")); self.inner.unary(req, path, codec).await } /// rpc VerifyBinary() returns () {}; @@ -2794,22 +2157,13 @@ pub mod node_service_client { pub async fn signal_service( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/SignalService", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/SignalService"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "SignalService")); @@ -2818,100 +2172,58 @@ pub mod node_service_client { pub async fn background_heal_status( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/BackgroundHealStatus", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/BackgroundHealStatus"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus")); self.inner.unary(req, path, codec).await } pub async fn get_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMetacacheListing", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetacacheListing"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "GetMetacacheListing"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "GetMetacacheListing")); self.inner.unary(req, path, codec).await } pub async fn update_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UpdateMetacacheListing", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetacacheListing"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing")); self.inner.unary(req, path, codec).await } pub async fn reload_pool_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReloadPoolMeta", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadPoolMeta"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReloadPoolMeta")); @@ -2920,22 +2232,13 @@ pub mod node_service_client { pub async fn stop_rebalance( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StopRebalance", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StopRebalance"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StopRebalance")); @@ -2944,69 +2247,38 @@ pub mod node_service_client { pub async fn load_rebalance_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadRebalanceMeta", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadRebalanceMeta"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta")); self.inner.unary(req, path, codec).await } pub async fn load_transition_tier_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadTransitionTierConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadTransitionTierConfig"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new( - "node_service.NodeService", - "LoadTransitionTierConfig", - ), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadTransitionTierConfig")); self.inner.unary(req, path, codec).await } } } /// Generated server implementations. pub mod node_service_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] + #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with NodeServiceServer. #[async_trait] @@ -3019,38 +2291,23 @@ pub mod node_service_server { async fn heal_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn list_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_bucket_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_all( &self, request: tonic::Request, @@ -3058,10 +2315,7 @@ pub mod node_service_server { async fn write_all( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete( &self, request: tonic::Request, @@ -3069,52 +2323,33 @@ pub mod node_service_server { async fn verify_file( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn check_parts( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn rename_part( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn rename_file( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn write( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WriteStream method. - type WriteStreamStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type WriteStreamStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn write_stream( &self, request: tonic::Request>, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the ReadAt method. - type ReadAtStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type ReadAtStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; /// rpc Append(AppendRequest) returns (AppendResponse) {}; @@ -3127,9 +2362,7 @@ pub mod node_service_server { request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WalkDir method. - type WalkDirStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type WalkDirStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn walk_dir( @@ -3139,66 +2372,39 @@ pub mod node_service_server { async fn rename_data( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_volumes( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn list_volumes( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn stat_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_paths( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn update_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn write_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_version( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_xl( &self, request: tonic::Request, @@ -3206,42 +2412,25 @@ pub mod node_service_server { async fn delete_version( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_versions( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_multiple( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn disk_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the NsScanner method. - type NsScannerStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type NsScannerStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn ns_scanner( @@ -3251,59 +2440,35 @@ pub mod node_service_server { async fn lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn r_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn r_un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn force_un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn refresh( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn local_storage_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn server_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_cpus( &self, request: tonic::Request, @@ -3311,236 +2476,137 @@ pub mod node_service_server { async fn get_net_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_partitions( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_os_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_se_linux_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sys_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sys_errors( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_mem_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_metrics( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_proc_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn start_profiling( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn download_profile_data( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sr_metrics( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_all_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_policy( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_policy( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_policy_mapping( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_user( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_service_account( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_user( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_service_account( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_group( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn reload_site_replication_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// rpc VerifyBinary() returns () {}; /// rpc CommitBinary() returns () {}; async fn signal_service( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn background_heal_status( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn update_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn reload_pool_meta( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn stop_rebalance( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_rebalance_meta( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_transition_tier_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct NodeServiceServer { @@ -3563,10 +2629,7 @@ pub mod node_service_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -3610,10 +2673,7 @@ pub mod node_service_server { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -3621,21 +2681,12 @@ pub mod node_service_server { "/node_service.NodeService/Ping" => { #[allow(non_camel_case_types)] struct PingSvc(pub Arc); - impl tonic::server::UnaryService - for PingSvc { + impl tonic::server::UnaryService for PingSvc { type Response = super::PingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::ping(&inner, request).await - }; + let fut = async move { ::ping(&inner, request).await }; Box::pin(fut) } } @@ -3648,14 +2699,8 @@ pub mod node_service_server { let method = PingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3664,23 +2709,12 @@ pub mod node_service_server { "/node_service.NodeService/HealBucket" => { #[allow(non_camel_case_types)] struct HealBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for HealBucketSvc { + impl tonic::server::UnaryService for HealBucketSvc { type Response = super::HealBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::heal_bucket(&inner, request).await - }; + let fut = async move { ::heal_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3693,14 +2727,8 @@ pub mod node_service_server { let method = HealBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3709,23 +2737,12 @@ pub mod node_service_server { "/node_service.NodeService/ListBucket" => { #[allow(non_camel_case_types)] struct ListBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListBucketSvc { + impl tonic::server::UnaryService for ListBucketSvc { type Response = super::ListBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_bucket(&inner, request).await - }; + let fut = async move { ::list_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3738,14 +2755,8 @@ pub mod node_service_server { let method = ListBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3754,23 +2765,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeBucket" => { #[allow(non_camel_case_types)] struct MakeBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeBucketSvc { + impl tonic::server::UnaryService for MakeBucketSvc { type Response = super::MakeBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_bucket(&inner, request).await - }; + let fut = async move { ::make_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3783,14 +2783,8 @@ pub mod node_service_server { let method = MakeBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3799,23 +2793,12 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketInfo" => { #[allow(non_camel_case_types)] struct GetBucketInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetBucketInfoSvc { + impl tonic::server::UnaryService for GetBucketInfoSvc { type Response = super::GetBucketInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_bucket_info(&inner, request).await - }; + let fut = async move { ::get_bucket_info(&inner, request).await }; Box::pin(fut) } } @@ -3828,14 +2811,8 @@ pub mod node_service_server { let method = GetBucketInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3844,23 +2821,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucket" => { #[allow(non_camel_case_types)] struct DeleteBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteBucketSvc { + impl tonic::server::UnaryService for DeleteBucketSvc { type Response = super::DeleteBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_bucket(&inner, request).await - }; + let fut = async move { ::delete_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3873,14 +2839,8 @@ pub mod node_service_server { let method = DeleteBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3889,23 +2849,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadAll" => { #[allow(non_camel_case_types)] struct ReadAllSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadAllSvc { + impl tonic::server::UnaryService for ReadAllSvc { type Response = super::ReadAllResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_all(&inner, request).await - }; + let fut = async move { ::read_all(&inner, request).await }; Box::pin(fut) } } @@ -3918,14 +2867,8 @@ pub mod node_service_server { let method = ReadAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3934,23 +2877,12 @@ pub mod node_service_server { "/node_service.NodeService/WriteAll" => { #[allow(non_camel_case_types)] struct WriteAllSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for WriteAllSvc { + impl tonic::server::UnaryService for WriteAllSvc { type Response = super::WriteAllResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_all(&inner, request).await - }; + let fut = async move { ::write_all(&inner, request).await }; Box::pin(fut) } } @@ -3963,14 +2895,8 @@ pub mod node_service_server { let method = WriteAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3979,23 +2905,12 @@ pub mod node_service_server { "/node_service.NodeService/Delete" => { #[allow(non_camel_case_types)] struct DeleteSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteSvc { + impl tonic::server::UnaryService for DeleteSvc { type Response = super::DeleteResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete(&inner, request).await - }; + let fut = async move { ::delete(&inner, request).await }; Box::pin(fut) } } @@ -4008,14 +2923,8 @@ pub mod node_service_server { let method = DeleteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4024,23 +2933,12 @@ pub mod node_service_server { "/node_service.NodeService/VerifyFile" => { #[allow(non_camel_case_types)] struct VerifyFileSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for VerifyFileSvc { + impl tonic::server::UnaryService for VerifyFileSvc { type Response = super::VerifyFileResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::verify_file(&inner, request).await - }; + let fut = async move { ::verify_file(&inner, request).await }; Box::pin(fut) } } @@ -4053,14 +2951,8 @@ pub mod node_service_server { let method = VerifyFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4069,23 +2961,12 @@ pub mod node_service_server { "/node_service.NodeService/CheckParts" => { #[allow(non_camel_case_types)] struct CheckPartsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for CheckPartsSvc { + impl tonic::server::UnaryService for CheckPartsSvc { type Response = super::CheckPartsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::check_parts(&inner, request).await - }; + let fut = async move { ::check_parts(&inner, request).await }; Box::pin(fut) } } @@ -4098,14 +2979,8 @@ pub mod node_service_server { let method = CheckPartsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4114,23 +2989,12 @@ pub mod node_service_server { "/node_service.NodeService/RenamePart" => { #[allow(non_camel_case_types)] struct RenamePartSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenamePartSvc { + impl tonic::server::UnaryService for RenamePartSvc { type Response = super::RenamePartResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_part(&inner, request).await - }; + let fut = async move { ::rename_part(&inner, request).await }; Box::pin(fut) } } @@ -4143,14 +3007,8 @@ pub mod node_service_server { let method = RenamePartSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4159,23 +3017,12 @@ pub mod node_service_server { "/node_service.NodeService/RenameFile" => { #[allow(non_camel_case_types)] struct RenameFileSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenameFileSvc { + impl tonic::server::UnaryService for RenameFileSvc { type Response = super::RenameFileResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_file(&inner, request).await - }; + let fut = async move { ::rename_file(&inner, request).await }; Box::pin(fut) } } @@ -4188,14 +3035,8 @@ pub mod node_service_server { let method = RenameFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4204,21 +3045,12 @@ pub mod node_service_server { "/node_service.NodeService/Write" => { #[allow(non_camel_case_types)] struct WriteSvc(pub Arc); - impl tonic::server::UnaryService - for WriteSvc { + impl tonic::server::UnaryService for WriteSvc { type Response = super::WriteResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write(&inner, request).await - }; + let fut = async move { ::write(&inner, request).await }; Box::pin(fut) } } @@ -4231,14 +3063,8 @@ pub mod node_service_server { let method = WriteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4247,26 +3073,13 @@ pub mod node_service_server { "/node_service.NodeService/WriteStream" => { #[allow(non_camel_case_types)] struct WriteStreamSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for WriteStreamSvc { + impl tonic::server::StreamingService for WriteStreamSvc { type Response = super::WriteResponse; type ResponseStream = T::WriteStreamStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_stream(&inner, request).await - }; + let fut = async move { ::write_stream(&inner, request).await }; Box::pin(fut) } } @@ -4279,14 +3092,8 @@ pub mod node_service_server { let method = WriteStreamSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -4295,26 +3102,13 @@ pub mod node_service_server { "/node_service.NodeService/ReadAt" => { #[allow(non_camel_case_types)] struct ReadAtSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for ReadAtSvc { + impl tonic::server::StreamingService for ReadAtSvc { type Response = super::ReadAtResponse; type ResponseStream = T::ReadAtStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_at(&inner, request).await - }; + let fut = async move { ::read_at(&inner, request).await }; Box::pin(fut) } } @@ -4327,14 +3121,8 @@ pub mod node_service_server { let method = ReadAtSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -4343,23 +3131,12 @@ pub mod node_service_server { "/node_service.NodeService/ListDir" => { #[allow(non_camel_case_types)] struct ListDirSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListDirSvc { + impl tonic::server::UnaryService for ListDirSvc { type Response = super::ListDirResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_dir(&inner, request).await - }; + let fut = async move { ::list_dir(&inner, request).await }; Box::pin(fut) } } @@ -4372,14 +3149,8 @@ pub mod node_service_server { let method = ListDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4388,24 +3159,13 @@ pub mod node_service_server { "/node_service.NodeService/WalkDir" => { #[allow(non_camel_case_types)] struct WalkDirSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::ServerStreamingService - for WalkDirSvc { + impl tonic::server::ServerStreamingService for WalkDirSvc { type Response = super::WalkDirResponse; type ResponseStream = T::WalkDirStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::walk_dir(&inner, request).await - }; + let fut = async move { ::walk_dir(&inner, request).await }; Box::pin(fut) } } @@ -4418,14 +3178,8 @@ pub mod node_service_server { let method = WalkDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.server_streaming(method, req).await; Ok(res) }; @@ -4434,23 +3188,12 @@ pub mod node_service_server { "/node_service.NodeService/RenameData" => { #[allow(non_camel_case_types)] struct RenameDataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenameDataSvc { + impl tonic::server::UnaryService for RenameDataSvc { type Response = super::RenameDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_data(&inner, request).await - }; + let fut = async move { ::rename_data(&inner, request).await }; Box::pin(fut) } } @@ -4463,14 +3206,8 @@ pub mod node_service_server { let method = RenameDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4479,23 +3216,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolumes" => { #[allow(non_camel_case_types)] struct MakeVolumesSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeVolumesSvc { + impl tonic::server::UnaryService for MakeVolumesSvc { type Response = super::MakeVolumesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_volumes(&inner, request).await - }; + let fut = async move { ::make_volumes(&inner, request).await }; Box::pin(fut) } } @@ -4508,14 +3234,8 @@ pub mod node_service_server { let method = MakeVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4524,23 +3244,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolume" => { #[allow(non_camel_case_types)] struct MakeVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeVolumeSvc { + impl tonic::server::UnaryService for MakeVolumeSvc { type Response = super::MakeVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_volume(&inner, request).await - }; + let fut = async move { ::make_volume(&inner, request).await }; Box::pin(fut) } } @@ -4553,14 +3262,8 @@ pub mod node_service_server { let method = MakeVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4569,23 +3272,12 @@ pub mod node_service_server { "/node_service.NodeService/ListVolumes" => { #[allow(non_camel_case_types)] struct ListVolumesSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListVolumesSvc { + impl tonic::server::UnaryService for ListVolumesSvc { type Response = super::ListVolumesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_volumes(&inner, request).await - }; + let fut = async move { ::list_volumes(&inner, request).await }; Box::pin(fut) } } @@ -4598,14 +3290,8 @@ pub mod node_service_server { let method = ListVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4614,23 +3300,12 @@ pub mod node_service_server { "/node_service.NodeService/StatVolume" => { #[allow(non_camel_case_types)] struct StatVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StatVolumeSvc { + impl tonic::server::UnaryService for StatVolumeSvc { type Response = super::StatVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::stat_volume(&inner, request).await - }; + let fut = async move { ::stat_volume(&inner, request).await }; Box::pin(fut) } } @@ -4643,14 +3318,8 @@ pub mod node_service_server { let method = StatVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4659,23 +3328,12 @@ pub mod node_service_server { "/node_service.NodeService/DeletePaths" => { #[allow(non_camel_case_types)] struct DeletePathsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeletePathsSvc { + impl tonic::server::UnaryService for DeletePathsSvc { type Response = super::DeletePathsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_paths(&inner, request).await - }; + let fut = async move { ::delete_paths(&inner, request).await }; Box::pin(fut) } } @@ -4688,14 +3346,8 @@ pub mod node_service_server { let method = DeletePathsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4704,23 +3356,12 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetadata" => { #[allow(non_camel_case_types)] struct UpdateMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UpdateMetadataSvc { + impl tonic::server::UnaryService for UpdateMetadataSvc { type Response = super::UpdateMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::update_metadata(&inner, request).await - }; + let fut = async move { ::update_metadata(&inner, request).await }; Box::pin(fut) } } @@ -4733,14 +3374,8 @@ pub mod node_service_server { let method = UpdateMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4749,23 +3384,12 @@ pub mod node_service_server { "/node_service.NodeService/WriteMetadata" => { #[allow(non_camel_case_types)] struct WriteMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for WriteMetadataSvc { + impl tonic::server::UnaryService for WriteMetadataSvc { type Response = super::WriteMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_metadata(&inner, request).await - }; + let fut = async move { ::write_metadata(&inner, request).await }; Box::pin(fut) } } @@ -4778,14 +3402,8 @@ pub mod node_service_server { let method = WriteMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4794,23 +3412,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadVersion" => { #[allow(non_camel_case_types)] struct ReadVersionSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadVersionSvc { + impl tonic::server::UnaryService for ReadVersionSvc { type Response = super::ReadVersionResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_version(&inner, request).await - }; + let fut = async move { ::read_version(&inner, request).await }; Box::pin(fut) } } @@ -4823,14 +3430,8 @@ pub mod node_service_server { let method = ReadVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4839,23 +3440,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadXL" => { #[allow(non_camel_case_types)] struct ReadXLSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadXLSvc { + impl tonic::server::UnaryService for ReadXLSvc { type Response = super::ReadXlResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_xl(&inner, request).await - }; + let fut = async move { ::read_xl(&inner, request).await }; Box::pin(fut) } } @@ -4868,14 +3458,8 @@ pub mod node_service_server { let method = ReadXLSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4884,23 +3468,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersion" => { #[allow(non_camel_case_types)] struct DeleteVersionSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVersionSvc { + impl tonic::server::UnaryService for DeleteVersionSvc { type Response = super::DeleteVersionResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_version(&inner, request).await - }; + let fut = async move { ::delete_version(&inner, request).await }; Box::pin(fut) } } @@ -4913,14 +3486,8 @@ pub mod node_service_server { let method = DeleteVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4929,23 +3496,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersions" => { #[allow(non_camel_case_types)] struct DeleteVersionsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVersionsSvc { + impl tonic::server::UnaryService for DeleteVersionsSvc { type Response = super::DeleteVersionsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_versions(&inner, request).await - }; + let fut = async move { ::delete_versions(&inner, request).await }; Box::pin(fut) } } @@ -4958,14 +3514,8 @@ pub mod node_service_server { let method = DeleteVersionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4974,23 +3524,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadMultiple" => { #[allow(non_camel_case_types)] struct ReadMultipleSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadMultipleSvc { + impl tonic::server::UnaryService for ReadMultipleSvc { type Response = super::ReadMultipleResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_multiple(&inner, request).await - }; + let fut = async move { ::read_multiple(&inner, request).await }; Box::pin(fut) } } @@ -5003,14 +3542,8 @@ pub mod node_service_server { let method = ReadMultipleSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5019,23 +3552,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVolume" => { #[allow(non_camel_case_types)] struct DeleteVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVolumeSvc { + impl tonic::server::UnaryService for DeleteVolumeSvc { type Response = super::DeleteVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_volume(&inner, request).await - }; + let fut = async move { ::delete_volume(&inner, request).await }; Box::pin(fut) } } @@ -5048,14 +3570,8 @@ pub mod node_service_server { let method = DeleteVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5064,23 +3580,12 @@ pub mod node_service_server { "/node_service.NodeService/DiskInfo" => { #[allow(non_camel_case_types)] struct DiskInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DiskInfoSvc { + impl tonic::server::UnaryService for DiskInfoSvc { type Response = super::DiskInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::disk_info(&inner, request).await - }; + let fut = async move { ::disk_info(&inner, request).await }; Box::pin(fut) } } @@ -5093,14 +3598,8 @@ pub mod node_service_server { let method = DiskInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5109,26 +3608,13 @@ pub mod node_service_server { "/node_service.NodeService/NsScanner" => { #[allow(non_camel_case_types)] struct NsScannerSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for NsScannerSvc { + impl tonic::server::StreamingService for NsScannerSvc { type Response = super::NsScannerResponse; type ResponseStream = T::NsScannerStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::ns_scanner(&inner, request).await - }; + let fut = async move { ::ns_scanner(&inner, request).await }; Box::pin(fut) } } @@ -5141,14 +3627,8 @@ pub mod node_service_server { let method = NsScannerSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -5157,23 +3637,12 @@ pub mod node_service_server { "/node_service.NodeService/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LockSvc { + impl tonic::server::UnaryService for LockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::lock(&inner, request).await - }; + let fut = async move { ::lock(&inner, request).await }; Box::pin(fut) } } @@ -5186,14 +3655,8 @@ pub mod node_service_server { let method = LockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5202,23 +3665,12 @@ pub mod node_service_server { "/node_service.NodeService/UnLock" => { #[allow(non_camel_case_types)] struct UnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UnLockSvc { + impl tonic::server::UnaryService for UnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::un_lock(&inner, request).await - }; + let fut = async move { ::un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5231,14 +3683,8 @@ pub mod node_service_server { let method = UnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5247,23 +3693,12 @@ pub mod node_service_server { "/node_service.NodeService/RLock" => { #[allow(non_camel_case_types)] struct RLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RLockSvc { + impl tonic::server::UnaryService for RLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::r_lock(&inner, request).await - }; + let fut = async move { ::r_lock(&inner, request).await }; Box::pin(fut) } } @@ -5276,14 +3711,8 @@ pub mod node_service_server { let method = RLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5292,23 +3721,12 @@ pub mod node_service_server { "/node_service.NodeService/RUnLock" => { #[allow(non_camel_case_types)] struct RUnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RUnLockSvc { + impl tonic::server::UnaryService for RUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::r_un_lock(&inner, request).await - }; + let fut = async move { ::r_un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5321,14 +3739,8 @@ pub mod node_service_server { let method = RUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5337,23 +3749,12 @@ pub mod node_service_server { "/node_service.NodeService/ForceUnLock" => { #[allow(non_camel_case_types)] struct ForceUnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ForceUnLockSvc { + impl tonic::server::UnaryService for ForceUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::force_un_lock(&inner, request).await - }; + let fut = async move { ::force_un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5366,14 +3767,8 @@ pub mod node_service_server { let method = ForceUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5382,23 +3777,12 @@ pub mod node_service_server { "/node_service.NodeService/Refresh" => { #[allow(non_camel_case_types)] struct RefreshSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RefreshSvc { + impl tonic::server::UnaryService for RefreshSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::refresh(&inner, request).await - }; + let fut = async move { ::refresh(&inner, request).await }; Box::pin(fut) } } @@ -5411,14 +3795,8 @@ pub mod node_service_server { let method = RefreshSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5427,24 +3805,12 @@ pub mod node_service_server { "/node_service.NodeService/LocalStorageInfo" => { #[allow(non_camel_case_types)] struct LocalStorageInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LocalStorageInfoSvc { + impl tonic::server::UnaryService for LocalStorageInfoSvc { type Response = super::LocalStorageInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::local_storage_info(&inner, request) - .await - }; + let fut = async move { ::local_storage_info(&inner, request).await }; Box::pin(fut) } } @@ -5457,14 +3823,8 @@ pub mod node_service_server { let method = LocalStorageInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5473,23 +3833,12 @@ pub mod node_service_server { "/node_service.NodeService/ServerInfo" => { #[allow(non_camel_case_types)] struct ServerInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ServerInfoSvc { + impl tonic::server::UnaryService for ServerInfoSvc { type Response = super::ServerInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::server_info(&inner, request).await - }; + let fut = async move { ::server_info(&inner, request).await }; Box::pin(fut) } } @@ -5502,14 +3851,8 @@ pub mod node_service_server { let method = ServerInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5518,23 +3861,12 @@ pub mod node_service_server { "/node_service.NodeService/GetCpus" => { #[allow(non_camel_case_types)] struct GetCpusSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetCpusSvc { + impl tonic::server::UnaryService for GetCpusSvc { type Response = super::GetCpusResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_cpus(&inner, request).await - }; + let fut = async move { ::get_cpus(&inner, request).await }; Box::pin(fut) } } @@ -5547,14 +3879,8 @@ pub mod node_service_server { let method = GetCpusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5563,23 +3889,12 @@ pub mod node_service_server { "/node_service.NodeService/GetNetInfo" => { #[allow(non_camel_case_types)] struct GetNetInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetNetInfoSvc { + impl tonic::server::UnaryService for GetNetInfoSvc { type Response = super::GetNetInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_net_info(&inner, request).await - }; + let fut = async move { ::get_net_info(&inner, request).await }; Box::pin(fut) } } @@ -5592,14 +3907,8 @@ pub mod node_service_server { let method = GetNetInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5608,23 +3917,12 @@ pub mod node_service_server { "/node_service.NodeService/GetPartitions" => { #[allow(non_camel_case_types)] struct GetPartitionsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetPartitionsSvc { + impl tonic::server::UnaryService for GetPartitionsSvc { type Response = super::GetPartitionsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_partitions(&inner, request).await - }; + let fut = async move { ::get_partitions(&inner, request).await }; Box::pin(fut) } } @@ -5637,14 +3935,8 @@ pub mod node_service_server { let method = GetPartitionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5653,23 +3945,12 @@ pub mod node_service_server { "/node_service.NodeService/GetOsInfo" => { #[allow(non_camel_case_types)] struct GetOsInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetOsInfoSvc { + impl tonic::server::UnaryService for GetOsInfoSvc { type Response = super::GetOsInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_os_info(&inner, request).await - }; + let fut = async move { ::get_os_info(&inner, request).await }; Box::pin(fut) } } @@ -5682,14 +3963,8 @@ pub mod node_service_server { let method = GetOsInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5698,23 +3973,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSELinuxInfo" => { #[allow(non_camel_case_types)] struct GetSELinuxInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSELinuxInfoSvc { + impl tonic::server::UnaryService for GetSELinuxInfoSvc { type Response = super::GetSeLinuxInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_se_linux_info(&inner, request).await - }; + let fut = async move { ::get_se_linux_info(&inner, request).await }; Box::pin(fut) } } @@ -5727,14 +3991,8 @@ pub mod node_service_server { let method = GetSELinuxInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5743,23 +4001,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSysConfig" => { #[allow(non_camel_case_types)] struct GetSysConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSysConfigSvc { + impl tonic::server::UnaryService for GetSysConfigSvc { type Response = super::GetSysConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sys_config(&inner, request).await - }; + let fut = async move { ::get_sys_config(&inner, request).await }; Box::pin(fut) } } @@ -5772,14 +4019,8 @@ pub mod node_service_server { let method = GetSysConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5788,23 +4029,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSysErrors" => { #[allow(non_camel_case_types)] struct GetSysErrorsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSysErrorsSvc { + impl tonic::server::UnaryService for GetSysErrorsSvc { type Response = super::GetSysErrorsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sys_errors(&inner, request).await - }; + let fut = async move { ::get_sys_errors(&inner, request).await }; Box::pin(fut) } } @@ -5817,14 +4047,8 @@ pub mod node_service_server { let method = GetSysErrorsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5833,23 +4057,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMemInfo" => { #[allow(non_camel_case_types)] struct GetMemInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMemInfoSvc { + impl tonic::server::UnaryService for GetMemInfoSvc { type Response = super::GetMemInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_mem_info(&inner, request).await - }; + let fut = async move { ::get_mem_info(&inner, request).await }; Box::pin(fut) } } @@ -5862,14 +4075,8 @@ pub mod node_service_server { let method = GetMemInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5878,23 +4085,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMetrics" => { #[allow(non_camel_case_types)] struct GetMetricsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMetricsSvc { + impl tonic::server::UnaryService for GetMetricsSvc { type Response = super::GetMetricsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_metrics(&inner, request).await - }; + let fut = async move { ::get_metrics(&inner, request).await }; Box::pin(fut) } } @@ -5907,14 +4103,8 @@ pub mod node_service_server { let method = GetMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5923,23 +4113,12 @@ pub mod node_service_server { "/node_service.NodeService/GetProcInfo" => { #[allow(non_camel_case_types)] struct GetProcInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetProcInfoSvc { + impl tonic::server::UnaryService for GetProcInfoSvc { type Response = super::GetProcInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proc_info(&inner, request).await - }; + let fut = async move { ::get_proc_info(&inner, request).await }; Box::pin(fut) } } @@ -5952,14 +4131,8 @@ pub mod node_service_server { let method = GetProcInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5968,23 +4141,12 @@ pub mod node_service_server { "/node_service.NodeService/StartProfiling" => { #[allow(non_camel_case_types)] struct StartProfilingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StartProfilingSvc { + impl tonic::server::UnaryService for StartProfilingSvc { type Response = super::StartProfilingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::start_profiling(&inner, request).await - }; + let fut = async move { ::start_profiling(&inner, request).await }; Box::pin(fut) } } @@ -5997,14 +4159,8 @@ pub mod node_service_server { let method = StartProfilingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6013,24 +4169,12 @@ pub mod node_service_server { "/node_service.NodeService/DownloadProfileData" => { #[allow(non_camel_case_types)] struct DownloadProfileDataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DownloadProfileDataSvc { + impl tonic::server::UnaryService for DownloadProfileDataSvc { type Response = super::DownloadProfileDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::download_profile_data(&inner, request) - .await - }; + let fut = async move { ::download_profile_data(&inner, request).await }; Box::pin(fut) } } @@ -6043,14 +4187,8 @@ pub mod node_service_server { let method = DownloadProfileDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6059,23 +4197,12 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketStats" => { #[allow(non_camel_case_types)] struct GetBucketStatsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetBucketStatsSvc { + impl tonic::server::UnaryService for GetBucketStatsSvc { type Response = super::GetBucketStatsDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_bucket_stats(&inner, request).await - }; + let fut = async move { ::get_bucket_stats(&inner, request).await }; Box::pin(fut) } } @@ -6088,14 +4215,8 @@ pub mod node_service_server { let method = GetBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6104,23 +4225,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSRMetrics" => { #[allow(non_camel_case_types)] struct GetSRMetricsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSRMetricsSvc { + impl tonic::server::UnaryService for GetSRMetricsSvc { type Response = super::GetSrMetricsDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sr_metrics(&inner, request).await - }; + let fut = async move { ::get_sr_metrics(&inner, request).await }; Box::pin(fut) } } @@ -6133,14 +4243,8 @@ pub mod node_service_server { let method = GetSRMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6149,24 +4253,12 @@ pub mod node_service_server { "/node_service.NodeService/GetAllBucketStats" => { #[allow(non_camel_case_types)] struct GetAllBucketStatsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetAllBucketStatsSvc { + impl tonic::server::UnaryService for GetAllBucketStatsSvc { type Response = super::GetAllBucketStatsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_all_bucket_stats(&inner, request) - .await - }; + let fut = async move { ::get_all_bucket_stats(&inner, request).await }; Box::pin(fut) } } @@ -6179,14 +4271,8 @@ pub mod node_service_server { let method = GetAllBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6195,24 +4281,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadBucketMetadata" => { #[allow(non_camel_case_types)] struct LoadBucketMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadBucketMetadataSvc { + impl tonic::server::UnaryService for LoadBucketMetadataSvc { type Response = super::LoadBucketMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_bucket_metadata(&inner, request) - .await - }; + let fut = async move { ::load_bucket_metadata(&inner, request).await }; Box::pin(fut) } } @@ -6225,14 +4299,8 @@ pub mod node_service_server { let method = LoadBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6241,24 +4309,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucketMetadata" => { #[allow(non_camel_case_types)] struct DeleteBucketMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteBucketMetadataSvc { + impl tonic::server::UnaryService for DeleteBucketMetadataSvc { type Response = super::DeleteBucketMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_bucket_metadata(&inner, request) - .await - }; + let fut = async move { ::delete_bucket_metadata(&inner, request).await }; Box::pin(fut) } } @@ -6271,14 +4327,8 @@ pub mod node_service_server { let method = DeleteBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6287,23 +4337,12 @@ pub mod node_service_server { "/node_service.NodeService/DeletePolicy" => { #[allow(non_camel_case_types)] struct DeletePolicySvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeletePolicySvc { + impl tonic::server::UnaryService for DeletePolicySvc { type Response = super::DeletePolicyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_policy(&inner, request).await - }; + let fut = async move { ::delete_policy(&inner, request).await }; Box::pin(fut) } } @@ -6316,14 +4355,8 @@ pub mod node_service_server { let method = DeletePolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6332,23 +4365,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicy" => { #[allow(non_camel_case_types)] struct LoadPolicySvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadPolicySvc { + impl tonic::server::UnaryService for LoadPolicySvc { type Response = super::LoadPolicyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_policy(&inner, request).await - }; + let fut = async move { ::load_policy(&inner, request).await }; Box::pin(fut) } } @@ -6361,14 +4383,8 @@ pub mod node_service_server { let method = LoadPolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6377,24 +4393,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicyMapping" => { #[allow(non_camel_case_types)] struct LoadPolicyMappingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadPolicyMappingSvc { + impl tonic::server::UnaryService for LoadPolicyMappingSvc { type Response = super::LoadPolicyMappingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_policy_mapping(&inner, request) - .await - }; + let fut = async move { ::load_policy_mapping(&inner, request).await }; Box::pin(fut) } } @@ -6407,14 +4411,8 @@ pub mod node_service_server { let method = LoadPolicyMappingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6423,23 +4421,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteUser" => { #[allow(non_camel_case_types)] struct DeleteUserSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteUserSvc { + impl tonic::server::UnaryService for DeleteUserSvc { type Response = super::DeleteUserResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_user(&inner, request).await - }; + let fut = async move { ::delete_user(&inner, request).await }; Box::pin(fut) } } @@ -6452,14 +4439,8 @@ pub mod node_service_server { let method = DeleteUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6468,24 +4449,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteServiceAccount" => { #[allow(non_camel_case_types)] struct DeleteServiceAccountSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteServiceAccountSvc { + impl tonic::server::UnaryService for DeleteServiceAccountSvc { type Response = super::DeleteServiceAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_service_account(&inner, request) - .await - }; + let fut = async move { ::delete_service_account(&inner, request).await }; Box::pin(fut) } } @@ -6498,14 +4467,8 @@ pub mod node_service_server { let method = DeleteServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6514,23 +4477,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadUser" => { #[allow(non_camel_case_types)] struct LoadUserSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadUserSvc { + impl tonic::server::UnaryService for LoadUserSvc { type Response = super::LoadUserResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_user(&inner, request).await - }; + let fut = async move { ::load_user(&inner, request).await }; Box::pin(fut) } } @@ -6543,14 +4495,8 @@ pub mod node_service_server { let method = LoadUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6559,24 +4505,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadServiceAccount" => { #[allow(non_camel_case_types)] struct LoadServiceAccountSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadServiceAccountSvc { + impl tonic::server::UnaryService for LoadServiceAccountSvc { type Response = super::LoadServiceAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_service_account(&inner, request) - .await - }; + let fut = async move { ::load_service_account(&inner, request).await }; Box::pin(fut) } } @@ -6589,14 +4523,8 @@ pub mod node_service_server { let method = LoadServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6605,23 +4533,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadGroup" => { #[allow(non_camel_case_types)] struct LoadGroupSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadGroupSvc { + impl tonic::server::UnaryService for LoadGroupSvc { type Response = super::LoadGroupResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_group(&inner, request).await - }; + let fut = async move { ::load_group(&inner, request).await }; Box::pin(fut) } } @@ -6634,14 +4551,8 @@ pub mod node_service_server { let method = LoadGroupSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6650,30 +4561,14 @@ pub mod node_service_server { "/node_service.NodeService/ReloadSiteReplicationConfig" => { #[allow(non_camel_case_types)] struct ReloadSiteReplicationConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService< - super::ReloadSiteReplicationConfigRequest, - > for ReloadSiteReplicationConfigSvc { + impl tonic::server::UnaryService + for ReloadSiteReplicationConfigSvc + { type Response = super::ReloadSiteReplicationConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::ReloadSiteReplicationConfigRequest, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::reload_site_replication_config( - &inner, - request, - ) - .await - }; + let fut = async move { ::reload_site_replication_config(&inner, request).await }; Box::pin(fut) } } @@ -6686,14 +4581,8 @@ pub mod node_service_server { let method = ReloadSiteReplicationConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6702,23 +4591,12 @@ pub mod node_service_server { "/node_service.NodeService/SignalService" => { #[allow(non_camel_case_types)] struct SignalServiceSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for SignalServiceSvc { + impl tonic::server::UnaryService for SignalServiceSvc { type Response = super::SignalServiceResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::signal_service(&inner, request).await - }; + let fut = async move { ::signal_service(&inner, request).await }; Box::pin(fut) } } @@ -6731,14 +4609,8 @@ pub mod node_service_server { let method = SignalServiceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6747,24 +4619,12 @@ pub mod node_service_server { "/node_service.NodeService/BackgroundHealStatus" => { #[allow(non_camel_case_types)] struct BackgroundHealStatusSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for BackgroundHealStatusSvc { + impl tonic::server::UnaryService for BackgroundHealStatusSvc { type Response = super::BackgroundHealStatusResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::background_heal_status(&inner, request) - .await - }; + let fut = async move { ::background_heal_status(&inner, request).await }; Box::pin(fut) } } @@ -6777,14 +4637,8 @@ pub mod node_service_server { let method = BackgroundHealStatusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6793,24 +4647,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMetacacheListing" => { #[allow(non_camel_case_types)] struct GetMetacacheListingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMetacacheListingSvc { + impl tonic::server::UnaryService for GetMetacacheListingSvc { type Response = super::GetMetacacheListingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_metacache_listing(&inner, request) - .await - }; + let fut = async move { ::get_metacache_listing(&inner, request).await }; Box::pin(fut) } } @@ -6823,14 +4665,8 @@ pub mod node_service_server { let method = GetMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6839,27 +4675,12 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetacacheListing" => { #[allow(non_camel_case_types)] struct UpdateMetacacheListingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UpdateMetacacheListingSvc { + impl tonic::server::UnaryService for UpdateMetacacheListingSvc { type Response = super::UpdateMetacacheListingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::update_metacache_listing( - &inner, - request, - ) - .await - }; + let fut = async move { ::update_metacache_listing(&inner, request).await }; Box::pin(fut) } } @@ -6872,14 +4693,8 @@ pub mod node_service_server { let method = UpdateMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6888,23 +4703,12 @@ pub mod node_service_server { "/node_service.NodeService/ReloadPoolMeta" => { #[allow(non_camel_case_types)] struct ReloadPoolMetaSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReloadPoolMetaSvc { + impl tonic::server::UnaryService for ReloadPoolMetaSvc { type Response = super::ReloadPoolMetaResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::reload_pool_meta(&inner, request).await - }; + let fut = async move { ::reload_pool_meta(&inner, request).await }; Box::pin(fut) } } @@ -6917,14 +4721,8 @@ pub mod node_service_server { let method = ReloadPoolMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6933,23 +4731,12 @@ pub mod node_service_server { "/node_service.NodeService/StopRebalance" => { #[allow(non_camel_case_types)] struct StopRebalanceSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StopRebalanceSvc { + impl tonic::server::UnaryService for StopRebalanceSvc { type Response = super::StopRebalanceResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::stop_rebalance(&inner, request).await - }; + let fut = async move { ::stop_rebalance(&inner, request).await }; Box::pin(fut) } } @@ -6962,14 +4749,8 @@ pub mod node_service_server { let method = StopRebalanceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6978,24 +4759,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadRebalanceMeta" => { #[allow(non_camel_case_types)] struct LoadRebalanceMetaSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadRebalanceMetaSvc { + impl tonic::server::UnaryService for LoadRebalanceMetaSvc { type Response = super::LoadRebalanceMetaResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_rebalance_meta(&inner, request) - .await - }; + let fut = async move { ::load_rebalance_meta(&inner, request).await }; Box::pin(fut) } } @@ -7008,14 +4777,8 @@ pub mod node_service_server { let method = LoadRebalanceMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -7024,29 +4787,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadTransitionTierConfig" => { #[allow(non_camel_case_types)] struct LoadTransitionTierConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadTransitionTierConfigSvc { + impl tonic::server::UnaryService for LoadTransitionTierConfigSvc { type Response = super::LoadTransitionTierConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::LoadTransitionTierConfigRequest, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_transition_tier_config( - &inner, - request, - ) - .await - }; + let fut = async move { ::load_transition_tier_config(&inner, request).await }; Box::pin(fut) } } @@ -7059,36 +4805,20 @@ pub mod node_service_server { let method = LoadTransitionTierConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers.insert(tonic::Status::GRPC_STATUS, (tonic::Code::Unimplemented as i32).into()); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } diff --git a/s3select/api/Cargo.toml b/s3select/api/Cargo.toml new file mode 100644 index 000000000..26f65bace --- /dev/null +++ b/s3select/api/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "api" +version.workspace = true +edition.workspace = true + +[dependencies] +async-trait.workspace = true +datafusion = { workspace = true } +futures = { workspace = true } +snafu = { workspace = true, features = ["backtrace"] } \ No newline at end of file diff --git a/s3select/api/src/lib.rs b/s3select/api/src/lib.rs new file mode 100644 index 000000000..acf653932 --- /dev/null +++ b/s3select/api/src/lib.rs @@ -0,0 +1,52 @@ +use std::fmt::Display; + +use datafusion::common::DataFusionError; +use snafu::{Backtrace, Location, Snafu}; + +pub mod query; +pub mod server; + +pub type QueryResult = Result; + +#[derive(Debug, Snafu)] +#[snafu(visibility(pub))] +pub enum QueryError { + Datafusion { + source: DataFusionError, + location: Location, + backtrace: Backtrace, + }, +} + +impl From for QueryError { + fn from(value: DataFusionError) -> Self { + match value { + DataFusionError::External(e) if e.downcast_ref::().is_some() => *e.downcast::().unwrap(), + + v => Self::Datafusion { + source: v, + location: Default::default(), + backtrace: Backtrace::capture(), + }, + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ResolvedTable { + // path + table: String, +} + +impl ResolvedTable { + pub fn table(&self) -> &str { + &self.table + } +} + +impl Display for ResolvedTable { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let Self { table } = self; + write!(f, "{table}") + } +} diff --git a/s3select/api/src/query/ast.rs b/s3select/api/src/query/ast.rs new file mode 100644 index 000000000..dbe9b4b2a --- /dev/null +++ b/s3select/api/src/query/ast.rs @@ -0,0 +1,8 @@ +use datafusion::sql::sqlparser::ast::Statement; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ExtStatement { + /// ANSI SQL AST node + SqlStatement(Box), + // we can expand command +} diff --git a/s3select/api/src/query/datasource/mod.rs b/s3select/api/src/query/datasource/mod.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/s3select/api/src/query/datasource/mod.rs @@ -0,0 +1 @@ + diff --git a/s3select/api/src/query/dispatcher.rs b/s3select/api/src/query/dispatcher.rs new file mode 100644 index 000000000..baa1885f1 --- /dev/null +++ b/s3select/api/src/query/dispatcher.rs @@ -0,0 +1,36 @@ +use std::sync::Arc; + +use async_trait::async_trait; + +use crate::QueryResult; + +use super::{ + execution::{Output, QueryStateMachine}, + logical_planner::Plan, + Query, +}; + +#[async_trait] +pub trait QueryDispatcher: Send + Sync { + async fn start(&self) -> QueryResult<()>; + + fn stop(&self); + + // fn create_query_id(&self) -> QueryId; + + // fn query_info(&self, id: &QueryId); + + async fn execute_query(&self, query: &Query) -> QueryResult; + + async fn build_logical_plan(&self, query_state_machine: Arc) -> QueryResult>; + + async fn execute_logical_plan(&self, logical_plan: Plan, query_state_machine: Arc) -> QueryResult; + + async fn build_query_state_machine(&self, query: Query) -> QueryResult>; + + // fn running_query_infos(&self) -> Vec; + + // fn running_query_status(&self) -> Vec; + + // fn cancel_query(&self, id: &QueryId); +} diff --git a/s3select/api/src/query/execution.rs b/s3select/api/src/query/execution.rs new file mode 100644 index 000000000..94d9b46c1 --- /dev/null +++ b/s3select/api/src/query/execution.rs @@ -0,0 +1,253 @@ +use std::fmt::Display; +use std::pin::Pin; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::sync::Arc; +use std::task::{Context, Poll}; +use std::time::{Duration, Instant}; + +use async_trait::async_trait; +use datafusion::arrow::datatypes::{Schema, SchemaRef}; +use datafusion::arrow::record_batch::RecordBatch; +use datafusion::physical_plan::SendableRecordBatchStream; +use futures::{Stream, StreamExt, TryStreamExt}; + +use crate::{QueryError, QueryResult}; + +use super::logical_planner::Plan; +use super::session::SessionCtx; +use super::Query; + +pub type QueryExecutionRef = Arc; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum QueryType { + Batch, + Stream, +} + +impl Display for QueryType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Batch => write!(f, "batch"), + Self::Stream => write!(f, "stream"), + } + } +} + +#[async_trait] +pub trait QueryExecution: Send + Sync { + fn query_type(&self) -> QueryType { + QueryType::Batch + } + // 开始 + async fn start(&self) -> QueryResult; + // 停止 + fn cancel(&self) -> QueryResult<()>; + // query状态 + // 查询计划 + // 静态信息 + // fn info(&self) -> QueryInfo; + // 运行时信息 + // fn status(&self) -> QueryStatus; + // sql + // 资源占用(cpu时间/内存/吞吐量等) + // 是否需要持久化query信息 + fn need_persist(&self) -> bool { + false + } +} + +pub enum Output { + StreamData(SendableRecordBatchStream), + Nil(()), +} + +impl Output { + pub fn schema(&self) -> SchemaRef { + match self { + Self::StreamData(stream) => stream.schema(), + Self::Nil(_) => Arc::new(Schema::empty()), + } + } + + pub async fn chunk_result(self) -> QueryResult> { + match self { + Self::Nil(_) => Ok(vec![]), + Self::StreamData(stream) => { + let schema = stream.schema(); + let mut res: Vec = stream.try_collect::>().await?; + if res.is_empty() { + res.push(RecordBatch::new_empty(schema)); + } + Ok(res) + } + } + } + + pub async fn num_rows(self) -> usize { + match self.chunk_result().await { + Ok(rb) => rb.iter().map(|e| e.num_rows()).sum(), + Err(_) => 0, + } + } + + /// Returns the number of records affected by the query operation + /// + /// If it is a select statement, returns the number of rows in the result set + /// + /// -1 means unknown + /// + /// panic! when StreamData's number of records greater than i64::Max + pub async fn affected_rows(self) -> i64 { + self.num_rows().await as i64 + } +} + +impl Stream for Output { + type Item = std::result::Result; + + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + let this = self.get_mut(); + match this { + Output::StreamData(stream) => stream.poll_next_unpin(cx).map_err(|e| e.into()), + Output::Nil(_) => Poll::Ready(None), + } + } +} + +#[async_trait] +pub trait QueryExecutionFactory { + async fn create_query_execution( + &self, + plan: Plan, + query_state_machine: QueryStateMachineRef, + ) -> QueryResult; +} + +pub type QueryStateMachineRef = Arc; + +pub struct QueryStateMachine { + pub session: SessionCtx, + pub query: Query, + + state: AtomicPtr, + start: Instant, +} + +impl QueryStateMachine { + pub fn begin(query: Query, session: SessionCtx) -> Self { + Self { + session, + query, + state: AtomicPtr::new(Box::into_raw(Box::new(QueryState::ACCEPTING))), + start: Instant::now(), + } + } + + pub fn begin_analyze(&self) { + // TODO record time + self.translate_to(Box::new(QueryState::RUNNING(RUNNING::ANALYZING))); + } + + pub fn end_analyze(&self) { + // TODO record time + } + + pub fn begin_optimize(&self) { + // TODO record time + self.translate_to(Box::new(QueryState::RUNNING(RUNNING::OPTMIZING))); + } + + pub fn end_optimize(&self) { + // TODO + } + + pub fn begin_schedule(&self) { + // TODO + self.translate_to(Box::new(QueryState::RUNNING(RUNNING::SCHEDULING))); + } + + pub fn end_schedule(&self) { + // TODO + } + + pub fn finish(&self) { + // TODO + self.translate_to(Box::new(QueryState::DONE(DONE::FINISHED))); + } + + pub fn cancel(&self) { + // TODO + self.translate_to(Box::new(QueryState::DONE(DONE::CANCELLED))); + } + + pub fn fail(&self) { + // TODO + self.translate_to(Box::new(QueryState::DONE(DONE::FAILED))); + } + + pub fn state(&self) -> &QueryState { + unsafe { &*self.state.load(Ordering::Relaxed) } + } + + pub fn duration(&self) -> Duration { + self.start.elapsed() + } + + fn translate_to(&self, state: Box) { + self.state.store(Box::into_raw(state), Ordering::Relaxed); + } +} + +#[derive(Debug, Clone)] +pub enum QueryState { + ACCEPTING, + RUNNING(RUNNING), + DONE(DONE), +} + +impl AsRef for QueryState { + fn as_ref(&self) -> &str { + match self { + QueryState::ACCEPTING => "ACCEPTING", + QueryState::RUNNING(e) => e.as_ref(), + QueryState::DONE(e) => e.as_ref(), + } + } +} + +#[derive(Debug, Clone)] +pub enum RUNNING { + DISPATCHING, + ANALYZING, + OPTMIZING, + SCHEDULING, +} + +impl AsRef for RUNNING { + fn as_ref(&self) -> &str { + match self { + Self::DISPATCHING => "DISPATCHING", + Self::ANALYZING => "ANALYZING", + Self::OPTMIZING => "OPTMIZING", + Self::SCHEDULING => "SCHEDULING", + } + } +} + +#[derive(Debug, Clone)] +pub enum DONE { + FINISHED, + FAILED, + CANCELLED, +} + +impl AsRef for DONE { + fn as_ref(&self) -> &str { + match self { + Self::FINISHED => "FINISHED", + Self::FAILED => "FAILED", + Self::CANCELLED => "CANCELLED", + } + } +} diff --git a/s3select/api/src/query/function.rs b/s3select/api/src/query/function.rs new file mode 100644 index 000000000..af207fc15 --- /dev/null +++ b/s3select/api/src/query/function.rs @@ -0,0 +1,23 @@ +use std::collections::HashSet; +use std::sync::Arc; + +use datafusion::logical_expr::{AggregateUDF, ScalarUDF, WindowUDF}; + +use crate::QueryResult; + +pub type FuncMetaManagerRef = Arc; +pub trait FunctionMetadataManager { + fn register_udf(&mut self, udf: ScalarUDF) -> QueryResult<()>; + + fn register_udaf(&mut self, udaf: AggregateUDF) -> QueryResult<()>; + + fn register_udwf(&mut self, udwf: WindowUDF) -> QueryResult<()>; + + fn udf(&self, name: &str) -> QueryResult>; + + fn udaf(&self, name: &str) -> QueryResult>; + + fn udwf(&self, name: &str) -> QueryResult>; + + fn udfs(&self) -> HashSet; +} diff --git a/s3select/api/src/query/logical_planner.rs b/s3select/api/src/query/logical_planner.rs new file mode 100644 index 000000000..325be6c84 --- /dev/null +++ b/s3select/api/src/query/logical_planner.rs @@ -0,0 +1,29 @@ +use datafusion::arrow::datatypes::SchemaRef; +use datafusion::logical_expr::LogicalPlan as DFPlan; + +#[derive(Clone)] +pub enum Plan { + // only support query sql + /// Query plan + Query(QueryPlan), +} + +impl Plan { + pub fn schema(&self) -> SchemaRef { + match self { + Self::Query(p) => SchemaRef::from(p.df_plan.schema().as_ref().to_owned()), + } + } +} + +#[derive(Debug, Clone)] +pub struct QueryPlan { + pub df_plan: DFPlan, + pub is_tag_scan: bool, +} + +impl QueryPlan { + pub fn is_explain(&self) -> bool { + matches!(self.df_plan, DFPlan::Explain(_) | DFPlan::Analyze(_)) + } +} diff --git a/s3select/api/src/query/mod.rs b/s3select/api/src/query/mod.rs new file mode 100644 index 000000000..e93fc5751 --- /dev/null +++ b/s3select/api/src/query/mod.rs @@ -0,0 +1,19 @@ +pub mod ast; +pub mod datasource; +pub mod dispatcher; +pub mod execution; +pub mod function; +pub mod logical_planner; +pub mod parser; +pub mod session; + +#[derive(Clone)] +pub struct Context { + // maybe we need transfer some info? +} + +#[derive(Clone)] +pub struct Query { + context: Context, + content: String, +} diff --git a/s3select/api/src/query/parser.rs b/s3select/api/src/query/parser.rs new file mode 100644 index 000000000..76d7e723f --- /dev/null +++ b/s3select/api/src/query/parser.rs @@ -0,0 +1,8 @@ +use std::collections::VecDeque; + +use super::ast::ExtStatement; +use crate::QueryResult; + +pub trait Parser { + fn parse(&self, sql: &str) -> QueryResult>; +} diff --git a/s3select/api/src/query/session.rs b/s3select/api/src/query/session.rs new file mode 100644 index 000000000..d387ff711 --- /dev/null +++ b/s3select/api/src/query/session.rs @@ -0,0 +1,20 @@ +use std::sync::Arc; + +use datafusion::execution::context::SessionState; + +#[derive(Clone)] +pub struct SessionCtx { + desc: Arc, + inner: SessionState, +} + +impl SessionCtx { + pub fn inner(&self) -> &SessionState { + &self.inner + } +} + +#[derive(Clone)] +pub struct SessionCtxDesc { + // maybe we need some info +} diff --git a/s3select/api/src/server/dbms.rs b/s3select/api/src/server/dbms.rs new file mode 100644 index 000000000..dc9e195d2 --- /dev/null +++ b/s3select/api/src/server/dbms.rs @@ -0,0 +1,43 @@ +use async_trait::async_trait; + +use crate::{ + query::{ + execution::{Output, QueryStateMachineRef}, + logical_planner::Plan, + Query, + }, + QueryResult, +}; + +pub struct QueryHandle { + query: Query, + result: Output, +} + +impl QueryHandle { + pub fn new(query: Query, result: Output) -> Self { + Self { query, result } + } + + pub fn query(&self) -> &Query { + &self.query + } + + pub fn result(self) -> Output { + self.result + } +} + +#[async_trait] +pub trait DatabaseManagerSystem { + async fn start(&self) -> QueryResult<()>; + async fn execute(&self, query: &Query) -> QueryResult; + async fn build_query_state_machine(&self, query: Query) -> QueryResult; + async fn build_logical_plan(&self, query_state_machine: QueryStateMachineRef) -> QueryResult>; + async fn execute_logical_plan( + &self, + logical_plan: Plan, + query_state_machine: QueryStateMachineRef, + ) -> QueryResult; + fn metrics(&self) -> String; +} diff --git a/s3select/api/src/server/mod.rs b/s3select/api/src/server/mod.rs new file mode 100644 index 000000000..c2e7c7b5c --- /dev/null +++ b/s3select/api/src/server/mod.rs @@ -0,0 +1 @@ +pub mod dbms; diff --git a/s3select/query/Cargo.toml b/s3select/query/Cargo.toml new file mode 100644 index 000000000..218f5cee6 --- /dev/null +++ b/s3select/query/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "query" +version.workspace = true +edition.workspace = true + +[dependencies] +api = { path = "../api" } +async-trait.workspace = true +datafusion = { workspace = true } +derive_builder = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } \ No newline at end of file diff --git a/s3select/query/src/data_source/data_source.rs b/s3select/query/src/data_source/data_source.rs new file mode 100644 index 000000000..a2c32f948 --- /dev/null +++ b/s3select/query/src/data_source/data_source.rs @@ -0,0 +1,140 @@ +use std::any::Any; +use std::fmt::Display; +use std::sync::Arc; +use std::write; + +use async_trait::async_trait; +use datafusion::arrow::datatypes::SchemaRef; +use datafusion::common::Result as DFResult; +use datafusion::datasource::listing::ListingTable; +use datafusion::datasource::{provider_as_source, TableProvider}; +use datafusion::error::DataFusionError; +use datafusion::logical_expr::{LogicalPlan, LogicalPlanBuilder, TableProviderFilterPushDown, TableSource}; +use datafusion::physical_plan::ExecutionPlan; +use datafusion::prelude::Expr; +use datafusion::sql::TableReference; +use tracing::debug; + +pub const TEMP_LOCATION_TABLE_NAME: &str = "external_location_table"; + +pub struct TableSourceAdapter { + database_name: String, + table_name: String, + table_handle: TableHandle, + + plan: LogicalPlan, +} + +impl TableSourceAdapter { + pub fn try_new( + table_ref: impl Into, + database_name: impl Into, + table_name: impl Into, + table_handle: impl Into, + ) -> Result { + let database_name = database_name.into(); + let table_name: String = table_name.into(); + + let table_handle = table_handle.into(); + let plan = match &table_handle { + // TableScan + TableHandle::External(t) => { + let table_source = provider_as_source(t.clone()); + LogicalPlanBuilder::scan(table_ref, table_source, None)?.build()? + } + // TableScan + TableHandle::TableProvider(t) => { + let table_source = provider_as_source(t.clone()); + if let Some(plan) = table_source.get_logical_plan() { + LogicalPlanBuilder::from(plan.clone()).build()? + } else { + LogicalPlanBuilder::scan(table_ref, table_source, None)?.build()? + } + } + }; + + debug!("Table source logical plan node of {}:\n{}", table_name, plan.display_indent_schema()); + + Ok(Self { + database_name: "default_db".to_string(), + table_name, + table_handle, + plan, + }) + } + + pub fn database_name(&self) -> &str { + &self.database_name + } + + pub fn table_name(&self) -> &str { + &self.table_name + } + + pub fn table_handle(&self) -> &TableHandle { + &self.table_handle + } +} + +#[async_trait] +impl TableSource for TableSourceAdapter { + fn as_any(&self) -> &dyn Any { + self + } + + fn schema(&self) -> SchemaRef { + self.table_handle.schema() + } + + fn supports_filters_pushdown(&self, filter: &[&Expr]) -> DFResult> { + self.table_handle.supports_filters_pushdown(filter) + } + + /// Called by [`InlineTableScan`] + fn get_logical_plan(&self) -> Option<&LogicalPlan> { + Some(&self.plan) + } +} + +#[derive(Clone)] +pub enum TableHandle { + TableProvider(Arc), + External(Arc), +} + +impl TableHandle { + pub fn schema(&self) -> SchemaRef { + match self { + Self::External(t) => t.schema(), + Self::TableProvider(t) => t.schema(), + } + } + + pub fn supports_filters_pushdown(&self, filter: &[&Expr]) -> DFResult> { + match self { + Self::External(t) => t.supports_filters_pushdown(filter), + Self::TableProvider(t) => t.supports_filters_pushdown(filter), + } + } +} + +impl From> for TableHandle { + fn from(value: Arc) -> Self { + TableHandle::TableProvider(value) + } +} + +impl From> for TableHandle { + fn from(value: Arc) -> Self { + TableHandle::External(value) + } +} + +impl Display for TableHandle { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::External(e) => write!(f, "External({:?})", e.table_paths()), + Self::TableProvider(_) => write!(f, "TableProvider"), + } + } +} diff --git a/s3select/query/src/data_source/mod.rs b/s3select/query/src/data_source/mod.rs new file mode 100644 index 000000000..5b53f15a4 --- /dev/null +++ b/s3select/query/src/data_source/mod.rs @@ -0,0 +1 @@ +pub mod data_source; diff --git a/s3select/query/src/dispatcher/manager.rs b/s3select/query/src/dispatcher/manager.rs new file mode 100644 index 000000000..bde400f4f --- /dev/null +++ b/s3select/query/src/dispatcher/manager.rs @@ -0,0 +1,331 @@ +use std::{ + collections::HashMap, + sync::{Arc, Mutex}, +}; + +use api::{ + query::{ + dispatcher::QueryDispatcher, + execution::{Output, QueryStateMachine}, + function::FuncMetaManagerRef, + logical_planner::Plan, + parser::Parser, + Query, + }, + QueryError, QueryResult, +}; +use async_trait::async_trait; +use tokio::task::JoinHandle; + +use crate::metadata::TableHandleProviderRef; + +#[derive(Clone)] +pub struct SimpleQueryDispatcher { + // client for default tenant + default_table_provider: TableHandleProviderRef, + // memory pool + // memory_pool: MemoryPoolRef, + // query tracker + // parser + parser: Arc, + // get query execution factory + query_execution_factory: QueryExecutionFactoryRef, + func_manager: FuncMetaManagerRef, + + async_task_joinhandle: Arc>>>, + failed_task_joinhandle: Arc>>>, +} + +#[async_trait] +impl QueryDispatcher for SimpleQueryDispatcher { + async fn start(&self) -> QueryResult<()> { + self.execute_persister_query(self.coord.node_id()).await + } + + fn stop(&self) { + // TODO + } + + async fn execute_query(&self, query: &Query) -> QueryResult { + let query_state_machine = { self.build_query_state_machine(query.clone()).await? }; + + let logical_plan = self.build_logical_plan(query_state_machine.clone()).await?; + let logical_plan = match logical_plan { + Some(plan) => plan, + None => return Ok(Output::Nil(())), + }; + let result = self.execute_logical_plan(logical_plan, query_state_machine).await?; + Ok(result) + } + + async fn build_logical_plan(&self, query_state_machine: Arc) -> QueryResult> { + let session = &query_state_machine.session; + let query = &query_state_machine.query; + + let scheme_provider = self.build_scheme_provider(session).await?; + + let logical_planner = DefaultLogicalPlanner::new(&scheme_provider); + + let span_recorder = session.get_child_span("parse sql"); + let statements = self.parser.parse(query.content())?; + + // not allow multi statement + if statements.len() > 1 { + return Err(QueryError::MultiStatement { + num: statements.len(), + sql: query_state_machine.query.content().to_string(), + }); + } + + let stmt = match statements.front() { + Some(stmt) => stmt.clone(), + None => return Ok(None), + }; + + drop(span_recorder); + + let logical_plan = self + .statement_to_logical_plan(stmt, &logical_planner, query_state_machine) + .await?; + Ok(Some(logical_plan)) + } + + async fn execute_logical_plan(&self, logical_plan: Plan, query_state_machine: Arc) -> QueryResult { + self.execute_logical_plan(logical_plan, query_state_machine).await + } + + async fn build_query_state_machine(&self, query: Query) -> QueryResult> { + let session = self + .session_factory + .create_session_ctx(query.context(), self.memory_pool.clone(), self.coord.clone())?; + + let query_state_machine = Arc::new(QueryStateMachine::begin(query, session)); + Ok(query_state_machine) + } +} + +impl SimpleQueryDispatcher { + async fn statement_to_logical_plan( + &self, + stmt: ExtStatement, + logical_planner: &DefaultLogicalPlanner<'_, S>, + query_state_machine: Arc, + ) -> QueryResult { + // begin analyze + query_state_machine.begin_analyze(); + let logical_plan = logical_planner + .create_logical_plan(stmt, &query_state_machine.session, self.coord.get_config().query.auth_enabled) + .await?; + query_state_machine.end_analyze(); + + Ok(logical_plan) + } + + async fn execute_logical_plan(&self, logical_plan: Plan, query_state_machine: Arc) -> QueryResult { + let execution = self + .query_execution_factory + .create_query_execution(logical_plan, query_state_machine.clone()) + .await?; + + // TrackedQuery.drop() is called implicitly when the value goes out of scope, + self.query_tracker + .try_track_query(query_state_machine.query_id, execution) + .await? + .start() + .await + } + + async fn build_scheme_provider(&self, session: &SessionCtx) -> QueryResult { + let meta_client = self.build_current_session_meta_client(session).await?; + let current_session_table_provider = self.build_table_handle_provider(meta_client.clone())?; + let metadata_provider = MetadataProvider::new( + self.coord.clone(), + meta_client, + current_session_table_provider, + self.default_table_provider.clone(), + self.func_manager.clone(), + self.query_tracker.clone(), + session.clone(), + ); + + Ok(metadata_provider) + } + + async fn build_current_session_meta_client(&self, session: &SessionCtx) -> QueryResult { + let meta_client = self + .coord + .tenant_meta(session.tenant()) + .await + .ok_or_else(|| MetaError::TenantNotFound { + tenant: session.tenant().to_string(), + }) + .context(MetaSnafu)?; + + Ok(meta_client) + } + + fn build_table_handle_provider(&self, meta_client: MetaClientRef) -> QueryResult { + let current_session_table_provider: Arc = Arc::new(BaseTableProvider::new( + self.coord.clone(), + self.split_manager.clone(), + meta_client, + self.stream_provider_manager.clone(), + )); + + Ok(current_session_table_provider) + } +} + +#[derive(Default, Clone)] +pub struct SimpleQueryDispatcherBuilder { + coord: Option, + default_table_provider: Option, + split_manager: Option, + session_factory: Option>, + parser: Option>, + + query_execution_factory: Option, + query_tracker: Option>, + memory_pool: Option, // memory + + func_manager: Option, + stream_provider_manager: Option, + span_ctx: Option, + auth_cache: Option>>, +} + +impl SimpleQueryDispatcherBuilder { + pub fn with_coord(mut self, coord: CoordinatorRef) -> Self { + self.coord = Some(coord); + self + } + + pub fn with_default_table_provider(mut self, default_table_provider: TableHandleProviderRef) -> Self { + self.default_table_provider = Some(default_table_provider); + self + } + + pub fn with_session_factory(mut self, session_factory: Arc) -> Self { + self.session_factory = Some(session_factory); + self + } + + pub fn with_split_manager(mut self, split_manager: SplitManagerRef) -> Self { + self.split_manager = Some(split_manager); + self + } + + pub fn with_parser(mut self, parser: Arc) -> Self { + self.parser = Some(parser); + self + } + + pub fn with_query_execution_factory(mut self, query_execution_factory: QueryExecutionFactoryRef) -> Self { + self.query_execution_factory = Some(query_execution_factory); + self + } + + pub fn with_query_tracker(mut self, query_tracker: Arc) -> Self { + self.query_tracker = Some(query_tracker); + self + } + + pub fn with_memory_pool(mut self, memory_pool: MemoryPoolRef) -> Self { + self.memory_pool = Some(memory_pool); + self + } + + pub fn with_func_manager(mut self, func_manager: FuncMetaManagerRef) -> Self { + self.func_manager = Some(func_manager); + self + } + + pub fn with_stream_provider_manager(mut self, stream_provider_manager: StreamProviderManagerRef) -> Self { + self.stream_provider_manager = Some(stream_provider_manager); + self + } + + pub fn with_span_ctx(mut self, span_ctx: Option) -> Self { + self.span_ctx = span_ctx; + self + } + + pub fn with_auth_cache(mut self, auth_cache: Arc>) -> Self { + self.auth_cache = Some(auth_cache); + self + } + + pub fn build(self) -> QueryResult> { + let coord = self.coord.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of coord".to_string(), + })?; + + let split_manager = self.split_manager.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of split manager".to_string(), + })?; + + let session_factory = self.session_factory.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of session_factory".to_string(), + })?; + + let parser = self.parser.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of parser".to_string(), + })?; + + let query_execution_factory = self.query_execution_factory.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of query_execution_factory".to_string(), + })?; + + let query_tracker = self.query_tracker.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of query_tracker".to_string(), + })?; + + let func_manager = self.func_manager.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of func_manager".to_string(), + })?; + + let stream_provider_manager = self.stream_provider_manager.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of stream_provider_manager".to_string(), + })?; + + let memory_pool = self.memory_pool.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of memory pool".to_string(), + })?; + + let default_table_provider = self.default_table_provider.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of default_table_provider".to_string(), + })?; + + let span_ctx = self.span_ctx; + + let auth_cache = self.auth_cache.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of auth_cache".to_string(), + })?; + + let dispatcher = Arc::new(SimpleQueryDispatcher { + coord, + default_table_provider, + split_manager, + session_factory, + memory_pool, + parser, + query_execution_factory, + query_tracker, + func_manager, + stream_provider_manager, + span_ctx, + async_task_joinhandle: Arc::new(Mutex::new(HashMap::new())), + failed_task_joinhandle: Arc::new(Mutex::new(HashMap::new())), + auth_cache, + }); + + let meta_task_receiver = dispatcher + .coord + .meta_manager() + .take_resourceinfo_rx() + .expect("meta resource channel only has one consumer"); + tokio::spawn(SimpleQueryDispatcher::recv_meta_modify(dispatcher.clone(), meta_task_receiver)); + + Ok(dispatcher) + } +} diff --git a/s3select/query/src/dispatcher/mod.rs b/s3select/query/src/dispatcher/mod.rs new file mode 100644 index 000000000..ff8de9eb9 --- /dev/null +++ b/s3select/query/src/dispatcher/mod.rs @@ -0,0 +1 @@ +pub mod manager; diff --git a/s3select/query/src/execution/factory.rs b/s3select/query/src/execution/factory.rs new file mode 100644 index 000000000..f6352eafb --- /dev/null +++ b/s3select/query/src/execution/factory.rs @@ -0,0 +1,109 @@ +use std::sync::Arc; + +use api::query::execution::QueryExecutionFactory; + +pub type QueryExecutionFactoryRef = Arc; + +pub struct SqlQueryExecutionFactory { + optimizer: Arc, + scheduler: SchedulerRef, + query_tracker: Arc, + trigger_executor_factory: TriggerExecutorFactoryRef, + runtime: Arc, + stream_checker_manager: StreamCheckerManagerRef, +} + +impl SqlQueryExecutionFactory { + #[inline(always)] + pub fn new( + optimizer: Arc, + scheduler: SchedulerRef, + query_tracker: Arc, + stream_checker_manager: StreamCheckerManagerRef, + config: Arc, + ) -> Self { + // Only do periodic scheduling, no need for many threads + let trigger_executor_runtime = DedicatedExecutor::new("stream-trigger", config.stream_trigger_cpu); + let trigger_executor_factory = Arc::new(TriggerExecutorFactory::new(Arc::new(trigger_executor_runtime))); + + // perform stream-related preparations, not actual operator execution + let runtime = Arc::new(DedicatedExecutor::new("stream-executor", config.stream_executor_cpu)); + + Self { + optimizer, + scheduler, + query_tracker, + trigger_executor_factory, + runtime, + stream_checker_manager, + } + } +} + +#[async_trait] +impl QueryExecutionFactory for SqlQueryExecutionFactory { + async fn create_query_execution( + &self, + plan: Plan, + state_machine: QueryStateMachineRef, + ) -> Result { + match plan { + Plan::Query(query_plan) => { + // 获取执行计划中所有涉及到的stream source + let stream_providers = extract_stream_providers(&query_plan); + + // (含有流表, explain, dml) + match (!stream_providers.is_empty(), query_plan.is_explain(), is_dml(&query_plan)) { + (false, _, _) | (true, true, _) => Ok(Arc::new(SqlQueryExecution::new( + state_machine, + query_plan, + self.optimizer.clone(), + self.scheduler.clone(), + ))), + (true, false, true) => { + // 流操作 + // stream source + dml + !explain + let options = state_machine.session.inner().config().into(); + let exec = MicroBatchStreamExecutionBuilder::new(MicroBatchStreamExecutionDesc { + plan: Arc::new(query_plan), + options, + }) + .with_stream_providers(stream_providers) + .build( + state_machine, + self.scheduler.clone(), + self.trigger_executor_factory.clone(), + self.runtime.clone(), + ) + .await?; + + Ok(Arc::new(exec)) + } + (true, false, false) => { + // stream source + !dml + !explain + Err(QueryError::NotImplemented { + err: "Stream table can only be used as source table in insert select statements.".to_string(), + }) + } + } + } + Plan::DDL(ddl_plan) => Ok(Arc::new(DDLExecution::new(state_machine, self.stream_checker_manager.clone(), ddl_plan))), + Plan::DML(dml_plan) => Ok(Arc::new(DMLExecution::new(state_machine, dml_plan))), + Plan::SYSTEM(sys_plan) => Ok(Arc::new(SystemExecution::new(state_machine, sys_plan, self.query_tracker.clone()))), + } + } +} + +fn is_dml(query_plan: &QueryPlan) -> bool { + match &query_plan.df_plan { + LogicalPlan::Dml(_) => true, + LogicalPlan::Extension(Extension { node }) => downcast_plan_node::(node.as_ref()).is_some(), + _ => false, + } +} + +impl Drop for SqlQueryExecutionFactory { + fn drop(&mut self) { + self.runtime.shutdown(); + } +} diff --git a/s3select/query/src/execution/mod.rs b/s3select/query/src/execution/mod.rs new file mode 100644 index 000000000..a106d20ea --- /dev/null +++ b/s3select/query/src/execution/mod.rs @@ -0,0 +1 @@ +pub mod factory; diff --git a/s3select/query/src/instance.rs b/s3select/query/src/instance.rs new file mode 100644 index 000000000..e27eea21e --- /dev/null +++ b/s3select/query/src/instance.rs @@ -0,0 +1,68 @@ +use std::sync::Arc; + +use api::{ + query::{dispatcher::QueryDispatcher, execution::QueryStateMachineRef, logical_planner::Plan, Query}, + server::dbms::{DatabaseManagerSystem, QueryHandle}, + QueryResult, +}; +use async_trait::async_trait; +use derive_builder::Builder; + +#[derive(Builder)] +pub struct RustFSms { + // query dispatcher & query execution + query_dispatcher: Arc, +} + +#[async_trait] +impl DatabaseManagerSystem for RustFSms +where + D: QueryDispatcher, +{ + async fn start(&self) -> QueryResult<()> { + self.query_dispatcher.start().await + } + + async fn execute(&self, query: &Query) -> QueryResult { + let result = self.query_dispatcher.execute_query(query).await?; + + Ok(QueryHandle::new(query.clone(), result)) + } + + async fn build_query_state_machine(&self, query: Query) -> QueryResult { + let query_state_machine = self.query_dispatcher.build_query_state_machine(query).await?; + + Ok(query_state_machine) + } + + async fn build_logical_plan(&self, query_state_machine: QueryStateMachineRef) -> QueryResult> { + let logical_plan = self.query_dispatcher.build_logical_plan(query_state_machine).await?; + + Ok(logical_plan) + } + + async fn execute_logical_plan( + &self, + logical_plan: Plan, + query_state_machine: QueryStateMachineRef, + ) -> QueryResult { + let query = query_state_machine.query.clone(); + let result = self + .query_dispatcher + .execute_logical_plan(logical_plan, query_state_machine) + .await?; + + Ok(QueryHandle::new(query.clone(), result)) + } + + fn metrics(&self) -> String { + let infos = self.query_dispatcher.running_query_infos(); + let status = self.query_dispatcher.running_query_status(); + + format!( + "infos: {}\nstatus: {}\n", + infos.iter().map(|e| format!("{:?}", e)).collect::>().join(","), + status.iter().map(|e| format!("{:?}", e)).collect::>().join(",") + ) + } +} diff --git a/s3select/query/src/lib.rs b/s3select/query/src/lib.rs new file mode 100644 index 000000000..a6cc51a37 --- /dev/null +++ b/s3select/query/src/lib.rs @@ -0,0 +1,6 @@ +pub mod data_source; +pub mod dispatcher; +pub mod execution; +pub mod instance; +pub mod metadata; +pub mod sql; diff --git a/s3select/query/src/metadata/base_table.rs b/s3select/query/src/metadata/base_table.rs new file mode 100644 index 000000000..2a5180882 --- /dev/null +++ b/s3select/query/src/metadata/base_table.rs @@ -0,0 +1,63 @@ +use std::sync::Arc; + +use datafusion::common::Result as DFResult; +use datafusion::config::{CsvOptions, JsonOptions}; +use datafusion::datasource::file_format::csv::CsvFormat; +use datafusion::datasource::file_format::json::JsonFormat; +use datafusion::datasource::file_format::parquet::ParquetFormat; +use datafusion::datasource::listing::{ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl}; +use datafusion::error::DataFusionError; +use datafusion::execution::SessionState; + +use crate::data_source::data_source::TableHandle; + +use super::TableHandleProvider; + +pub enum FileType { + Csv, + Parquet, + Json, + Unknown, +} + +#[derive(Default)] +pub struct BaseTableProvider { + file_type: FileType, +} + +impl BaseTableProvider { + pub fn new(file_type: FileType) -> Self { + Self { file_type } + } +} + +impl TableHandleProvider for BaseTableProvider { + async fn build_table_handle(&self, session_state: &SessionState, table_name: &str) -> DFResult { + let table_path = ListingTableUrl::parse(table_name)?; + let listing_options = match self.file_type { + FileType::Csv => { + let file_format = CsvFormat::default().with_options(CsvOptions::default().with_has_header(false)); + ListingOptions::new(Arc::new(file_format)).with_file_extension(".csv") + } + FileType::Parquet => { + let file_format = ParquetFormat::new(); + ListingOptions::new(Arc::new(file_format)).with_file_extension(".parquet") + } + FileType::Json => { + let file_format = JsonFormat::default(); + ListingOptions::new(Arc::new(file_format)).with_file_extension(".json") + } + FileType::Unknown => { + return Err(DataFusionError::NotImplemented("not support this file type".to_string())); + } + }; + + let resolve_schema = listing_options.infer_schema(session_state, &table_path).await?; + let config = ListingTableConfig::new(table_path) + .with_listing_options(listing_options) + .with_schema(resolve_schema); + let provider = Arc::new(ListingTable::try_new(config)?); + + Ok(TableHandle::External(provider)) + } +} diff --git a/s3select/query/src/metadata/mod.rs b/s3select/query/src/metadata/mod.rs new file mode 100644 index 000000000..5f60298a2 --- /dev/null +++ b/s3select/query/src/metadata/mod.rs @@ -0,0 +1,149 @@ +use std::sync::Arc; + +use api::query::{function::FuncMetaManagerRef, session::SessionCtx}; +use api::ResolvedTable; +use async_trait::async_trait; +use datafusion::arrow::datatypes::DataType; +use datafusion::common::Result as DFResult; +use datafusion::error::DataFusionError; +use datafusion::execution::SessionState; +use datafusion::logical_expr::var_provider::is_system_variables; +use datafusion::logical_expr::{AggregateUDF, ScalarUDF, TableSource, WindowUDF}; +use datafusion::variable::VarType; +use datafusion::{ + config::ConfigOptions, + sql::{planner::ContextProvider, TableReference}, +}; + +use crate::data_source::data_source::{TableHandle, TableSourceAdapter}; + +pub mod base_table; + +#[async_trait] +pub trait ContextProviderExtension: ContextProvider { + fn get_table_source(&self, name: TableReference) -> datafusion::common::Result>; +} + +pub type TableHandleProviderRef = Arc; + +pub trait TableHandleProvider { + fn build_table_handle(&self, session_state: &SessionState, table_name: &str) -> DFResult; +} + +pub struct MetadataProvider { + session: SessionCtx, + config_options: ConfigOptions, + func_manager: FuncMetaManagerRef, + current_session_table_provider: TableHandleProviderRef, +} + +impl MetadataProvider { + #[allow(clippy::too_many_arguments)] + pub fn new( + current_session_table_provider: TableHandleProviderRef, + func_manager: FuncMetaManagerRef, + session: SessionCtx, + ) -> Self { + Self { + current_session_table_provider, + config_options: session.inner().config_options().clone(), + session, + func_manager, + } + } + + fn build_table_handle(&self, name: &ResolvedTable) -> datafusion::common::Result { + let table_name = name.table(); + + self.current_session_table_provider.build_table_handle(table_name) + } +} + +#[async_trait::async_trait] +impl ContextProviderExtension for MetadataProvider { + fn get_table_source(&self, table_ref: TableReference) -> datafusion::common::Result> { + let name = table_ref + .clone() + .resolve_object(self.session.tenant(), self.session.default_database())?; + + let table_name = name.table(); + let database_name = name.database(); + let tenant_name = name.tenant(); + + // Cannot query across tenants + if self.session.tenant() != tenant_name { + return Err(DataFusionError::Plan(format!( + "Tenant conflict, the current connection's tenant is {}", + self.session.tenant() + ))); + } + + // save access table + self.access_databases.write().push_table(database_name, table_name); + + let table_handle = self.build_table_handle(&name)?; + + Ok(Arc::new(TableSourceAdapter::try_new( + table_ref.to_owned_reference(), + database_name, + table_name, + table_handle, + )?)) + } +} + +impl ContextProvider for MetadataProvider { + fn get_function_meta(&self, name: &str) -> Option> { + self.func_manager + .udf(name) + .ok() + .or(self.session.inner().scalar_functions().get(name).cloned()) + } + + fn get_aggregate_meta(&self, name: &str) -> Option> { + self.func_manager.udaf(name).ok() + } + + fn get_variable_type(&self, variable_names: &[String]) -> Option { + if variable_names.is_empty() { + return None; + } + + let var_type = if is_system_variables(variable_names) { + VarType::System + } else { + VarType::UserDefined + }; + + self.session + .inner() + .execution_props() + .get_var_provider(var_type) + .and_then(|p| p.get_type(variable_names)) + } + + fn options(&self) -> &ConfigOptions { + // TODO refactor + &self.config_options + } + + fn get_window_meta(&self, name: &str) -> Option> { + self.func_manager.udwf(name).ok() + } + + fn get_table_source(&self, name: TableReference) -> DFResult> { + Ok(self.get_table_source(name)?) + } + + fn udf_names(&self) -> Vec { + todo!() + } + + fn udaf_names(&self) -> Vec { + todo!() + } + + fn udwf_names(&self) -> Vec { + todo!() + } +} diff --git a/s3select/query/src/sql/logical/mod.rs b/s3select/query/src/sql/logical/mod.rs new file mode 100644 index 000000000..5e480858b --- /dev/null +++ b/s3select/query/src/sql/logical/mod.rs @@ -0,0 +1 @@ +pub mod planner; diff --git a/s3select/query/src/sql/logical/planner.rs b/s3select/query/src/sql/logical/planner.rs new file mode 100644 index 000000000..bcdc59c07 --- /dev/null +++ b/s3select/query/src/sql/logical/planner.rs @@ -0,0 +1,3 @@ +use crate::sql::planner::SqlPlanner; + +pub type DefaultLogicalPlanner<'a, S> = SqlPlanner<'a, S>; diff --git a/s3select/query/src/sql/mod.rs b/s3select/query/src/sql/mod.rs new file mode 100644 index 000000000..74b97905f --- /dev/null +++ b/s3select/query/src/sql/mod.rs @@ -0,0 +1,3 @@ +pub mod logical; +pub mod physical; +pub mod planner; diff --git a/s3select/query/src/sql/physical/mod.rs b/s3select/query/src/sql/physical/mod.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/s3select/query/src/sql/physical/mod.rs @@ -0,0 +1 @@ + diff --git a/s3select/query/src/sql/planner.rs b/s3select/query/src/sql/planner.rs new file mode 100644 index 000000000..0d4688437 --- /dev/null +++ b/s3select/query/src/sql/planner.rs @@ -0,0 +1,8 @@ +use datafusion::sql::planner::SqlToRel; + +use crate::metadata::ContextProviderExtension; + +pub struct SqlPlanner<'a, S: ContextProviderExtension> { + schema_provider: &'a S, + df_planner: SqlToRel<'a, S>, +} From 0b270bf0cc8a2c2fa93bfcc48390d6df3b591be1 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Thu, 13 Mar 2025 09:43:53 +0000 Subject: [PATCH 030/103] tmp2 Signed-off-by: junxiang Mu <1948535941@qq.com> --- Cargo.lock | 37 +- Cargo.toml | 1 + .../generated/flatbuffers_generated/models.rs | 207 +- .../src/generated/proto_gen/node_service.rs | 3836 +++++++++++++---- rustfs/Cargo.toml | 4 + rustfs/src/storage/ecfs.rs | 73 + s3select/api/Cargo.toml | 12 +- s3select/api/src/lib.rs | 18 +- s3select/api/src/object_store.rs | 150 + s3select/api/src/query/analyzer.rs | 12 + s3select/api/src/query/dispatcher.rs | 4 - s3select/api/src/query/execution.rs | 12 - s3select/api/src/query/logical_planner.rs | 11 + s3select/api/src/query/mod.rs | 22 + s3select/api/src/query/optimizer.rs | 15 + s3select/api/src/query/physical_planner.rs | 21 + s3select/api/src/query/scheduler.rs | 32 + s3select/api/src/query/session.rs | 41 +- s3select/api/src/server/dbms.rs | 2 - s3select/query/Cargo.toml | 5 + s3select/query/src/data_source/data_source.rs | 10 +- s3select/query/src/dispatcher/manager.rs | 225 +- s3select/query/src/execution/factory.rs | 103 +- s3select/query/src/execution/mod.rs | 2 + s3select/query/src/execution/query.rs | 92 + .../query/src/execution/scheduler/local.rs | 22 + s3select/query/src/execution/scheduler/mod.rs | 1 + s3select/query/src/instance.rs | 54 +- s3select/query/src/metadata/base_table.rs | 52 +- s3select/query/src/metadata/mod.rs | 52 +- s3select/query/src/sql/analyzer.rs | 33 + s3select/query/src/sql/dialect.rs | 18 + s3select/query/src/sql/logical/mod.rs | 1 + s3select/query/src/sql/logical/optimizer.rs | 115 + s3select/query/src/sql/mod.rs | 4 + s3select/query/src/sql/optimizer.rs | 89 + s3select/query/src/sql/parser.rs | 97 + s3select/query/src/sql/physical/mod.rs | 3 +- s3select/query/src/sql/physical/optimizer.rs | 12 + s3select/query/src/sql/physical/planner.rs | 104 + s3select/query/src/sql/planner.rs | 54 +- 41 files changed, 4402 insertions(+), 1256 deletions(-) create mode 100644 s3select/api/src/object_store.rs create mode 100644 s3select/api/src/query/analyzer.rs create mode 100644 s3select/api/src/query/optimizer.rs create mode 100644 s3select/api/src/query/physical_planner.rs create mode 100644 s3select/api/src/query/scheduler.rs create mode 100644 s3select/query/src/execution/query.rs create mode 100644 s3select/query/src/execution/scheduler/local.rs create mode 100644 s3select/query/src/execution/scheduler/mod.rs create mode 100644 s3select/query/src/sql/analyzer.rs create mode 100644 s3select/query/src/sql/dialect.rs create mode 100644 s3select/query/src/sql/logical/optimizer.rs create mode 100644 s3select/query/src/sql/optimizer.rs create mode 100644 s3select/query/src/sql/parser.rs create mode 100644 s3select/query/src/sql/physical/optimizer.rs create mode 100644 s3select/query/src/sql/physical/planner.rs diff --git a/Cargo.lock b/Cargo.lock index 0b4fae4b6..2ba596d60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,9 +183,19 @@ name = "api" version = "0.0.1" dependencies = [ "async-trait", + "bytes", + "chrono", "datafusion", + "ecstore", "futures", + "futures-core", + "http", + "object_store", + "s3s", "snafu", + "tokio", + "tracing", + "url", ] [[package]] @@ -5711,7 +5721,7 @@ dependencies = [ "crypto", "futures", "ipnetwork", - "itertools", + "itertools 0.14.0", "jsonwebtoken", "lazy_static", "log", @@ -5989,9 +5999,14 @@ name = "query" version = "0.0.1" dependencies = [ "api", + "async-recursion", "async-trait", "datafusion", "derive_builder", + "futures", + "parking_lot 0.12.3", + "s3s", + "snafu", "tokio", "tracing", ] @@ -6190,22 +6205,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" -[[package]] -name = "reader" -version = "0.0.1" -dependencies = [ - "bytes", - "futures", - "hex-simd", - "md-5", - "pin-project-lite", - "s3s", - "sha2 0.11.0-pre.4", - "thiserror 2.0.11", - "tokio", - "tracing", -] - [[package]] name = "recursive" version = "0.1.1" @@ -6524,6 +6523,7 @@ dependencies = [ name = "rustfs" version = "0.1.0" dependencies = [ + "api", "async-trait", "atoi", "axum", @@ -6533,6 +6533,8 @@ dependencies = [ "common", "const-str", "crypto", + "csv", + "datafusion", "ecstore", "flatbuffers", "futures", @@ -6560,6 +6562,7 @@ dependencies = [ "prost-types", "protobuf", "protos", + "query", "rmp-serde", "rust-embed", "s3s", diff --git a/Cargo.toml b/Cargo.toml index e581661c5..28d28347c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ all = "warn" [workspace.dependencies] madmin = { path = "./madmin" } +async-recursion = "1.0.5" async-trait = "0.1.86" backon = "1.3.0" bytes = "1.9.0" diff --git a/common/protos/src/generated/flatbuffers_generated/models.rs b/common/protos/src/generated/flatbuffers_generated/models.rs index e4949fdcf..aa1f6ae2f 100644 --- a/common/protos/src/generated/flatbuffers_generated/models.rs +++ b/common/protos/src/generated/flatbuffers_generated/models.rs @@ -1,9 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -11,114 +12,112 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod models { - use core::cmp::Ordering; - use core::mem; + use core::mem; + use core::cmp::Ordering; - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; - pub enum PingBodyOffset {} - #[derive(Copy, Clone, PartialEq)] +pub enum PingBodyOffset {} +#[derive(Copy, Clone, PartialEq)] - pub struct PingBody<'a> { - pub _tab: flatbuffers::Table<'a>, +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: 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> { + let mut builder = PingBodyBuilder::new(_fbb); + if let Some(x) = args.payload { builder.add_payload(x); } + builder.finish() + } + + + #[inline] + pub fn payload(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? + .finish(); + Ok(()) + } +} +pub struct PingBodyArgs<'a> { + pub payload: Option>>, +} +impl<'a> Default for PingBodyArgs<'a> { + #[inline] + fn default() -> Self { + PingBodyArgs { + payload: None, } + } +} - 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: flatbuffers::Table::new(buf, loc), - } - } +pub struct PingBodyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { + #[inline] + pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(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> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} - impl<'a> PingBody<'a> { - pub const VT_PAYLOAD: flatbuffers::VOffsetT = 4; +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 - 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> { - let mut builder = PingBodyBuilder::new(_fbb); - if let Some(x) = args.payload { - builder.add_payload(x); - } - builder.finish() - } - - #[inline] - pub fn payload(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? - .finish(); - Ok(()) - } - } - pub struct PingBodyArgs<'a> { - pub payload: Option>>, - } - 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, - } - impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { - #[inline] - pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(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> { - 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 diff --git a/common/protos/src/generated/proto_gen/node_service.rs b/common/protos/src/generated/proto_gen/node_service.rs index 000d5b486..88f7b3ab0 100644 --- a/common/protos/src/generated/proto_gen/node_service.rs +++ b/common/protos/src/generated/proto_gen/node_service.rs @@ -622,7 +622,10 @@ pub struct GenerallyLockResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct Mss { #[prost(map = "string, string", tag = "1")] - pub value: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub value: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, } #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LocalStorageInfoRequest { @@ -786,7 +789,10 @@ pub struct DownloadProfileDataResponse { #[prost(bool, tag = "1")] pub success: bool, #[prost(map = "string, bytes", tag = "2")] - pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec>, + pub data: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::vec::Vec, + >, #[prost(string, optional, tag = "3")] pub error_info: ::core::option::Option<::prost::alloc::string::String>, } @@ -1053,9 +1059,15 @@ pub struct LoadTransitionTierConfigResponse { } /// Generated client implementations. pub mod node_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] - use tonic::codegen::http::Uri; + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct NodeServiceClient { inner: tonic::client::Grpc, @@ -1086,16 +1098,22 @@ pub mod node_service_client { let inner = tonic::client::Grpc::with_origin(inner, origin); Self { inner } } - pub fn with_interceptor(inner: T, interceptor: F) -> NodeServiceClient> + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> NodeServiceClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, - Response = http::Response<>::ResponseBody>, + Response = http::Response< + >::ResponseBody, + >, >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, { NodeServiceClient::new(InterceptedService::new(inner, interceptor)) } @@ -1138,9 +1156,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Ping"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Ping", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Ping")); @@ -1149,13 +1173,22 @@ pub mod node_service_client { pub async fn heal_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/HealBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/HealBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "HealBucket")); @@ -1164,13 +1197,22 @@ pub mod node_service_client { pub async fn list_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ListBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListBucket")); @@ -1179,13 +1221,22 @@ pub mod node_service_client { pub async fn make_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/MakeBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeBucket")); @@ -1194,13 +1245,22 @@ pub mod node_service_client { pub async fn get_bucket_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetBucketInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketInfo")); @@ -1209,13 +1269,22 @@ pub mod node_service_client { pub async fn delete_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucket")); @@ -1224,13 +1293,22 @@ pub mod node_service_client { pub async fn read_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAll"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadAll", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAll")); @@ -1239,13 +1317,22 @@ pub mod node_service_client { pub async fn write_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteAll"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WriteAll", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteAll")); @@ -1258,9 +1345,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Delete"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Delete", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Delete")); @@ -1269,13 +1362,22 @@ pub mod node_service_client { pub async fn verify_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/VerifyFile"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/VerifyFile", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "VerifyFile")); @@ -1284,13 +1386,22 @@ pub mod node_service_client { pub async fn check_parts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/CheckParts"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/CheckParts", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "CheckParts")); @@ -1299,13 +1410,22 @@ pub mod node_service_client { pub async fn rename_part( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenamePart"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RenamePart", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenamePart")); @@ -1314,13 +1434,22 @@ pub mod node_service_client { pub async fn rename_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameFile"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RenameFile", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameFile")); @@ -1333,9 +1462,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Write"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Write", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Write")); @@ -1344,13 +1479,22 @@ pub mod node_service_client { pub async fn write_stream( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteStream"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WriteStream", + ); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteStream")); @@ -1360,13 +1504,22 @@ pub mod node_service_client { pub async fn read_at( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAt"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadAt", + ); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAt")); @@ -1375,13 +1528,22 @@ pub mod node_service_client { pub async fn list_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListDir"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ListDir", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListDir")); @@ -1390,13 +1552,22 @@ pub mod node_service_client { pub async fn walk_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WalkDir"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WalkDir", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WalkDir")); @@ -1405,13 +1576,22 @@ pub mod node_service_client { pub async fn rename_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameData"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RenameData", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameData")); @@ -1420,13 +1600,22 @@ pub mod node_service_client { pub async fn make_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolumes"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/MakeVolumes", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolumes")); @@ -1435,13 +1624,22 @@ pub mod node_service_client { pub async fn make_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolume"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/MakeVolume", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolume")); @@ -1450,13 +1648,22 @@ pub mod node_service_client { pub async fn list_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListVolumes"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ListVolumes", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListVolumes")); @@ -1465,13 +1672,22 @@ pub mod node_service_client { pub async fn stat_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StatVolume"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/StatVolume", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StatVolume")); @@ -1480,13 +1696,22 @@ pub mod node_service_client { pub async fn delete_paths( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePaths"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeletePaths", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePaths")); @@ -1495,13 +1720,22 @@ pub mod node_service_client { pub async fn update_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/UpdateMetadata", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetadata")); @@ -1510,13 +1744,22 @@ pub mod node_service_client { pub async fn write_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WriteMetadata", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteMetadata")); @@ -1525,13 +1768,22 @@ pub mod node_service_client { pub async fn read_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadVersion"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadVersion", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadVersion")); @@ -1544,9 +1796,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadXL"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadXL", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadXL")); @@ -1555,13 +1813,22 @@ pub mod node_service_client { pub async fn delete_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersion"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteVersion", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersion")); @@ -1570,13 +1837,22 @@ pub mod node_service_client { pub async fn delete_versions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersions"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteVersions", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersions")); @@ -1585,13 +1861,22 @@ pub mod node_service_client { pub async fn read_multiple( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadMultiple"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadMultiple", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadMultiple")); @@ -1600,13 +1885,22 @@ pub mod node_service_client { pub async fn delete_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVolume"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteVolume", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVolume")); @@ -1615,13 +1909,22 @@ pub mod node_service_client { pub async fn disk_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DiskInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DiskInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DiskInfo")); @@ -1630,13 +1933,22 @@ pub mod node_service_client { pub async fn ns_scanner( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/NsScanner"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/NsScanner", + ); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "NsScanner")); @@ -1645,13 +1957,22 @@ pub mod node_service_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Lock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Lock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Lock")); @@ -1660,13 +1981,22 @@ pub mod node_service_client { pub async fn un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UnLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/UnLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UnLock")); @@ -1675,13 +2005,22 @@ pub mod node_service_client { pub async fn r_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RLock")); @@ -1690,13 +2029,22 @@ pub mod node_service_client { pub async fn r_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RUnLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RUnLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RUnLock")); @@ -1705,13 +2053,22 @@ pub mod node_service_client { pub async fn force_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ForceUnLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ForceUnLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ForceUnLock")); @@ -1720,13 +2077,22 @@ pub mod node_service_client { pub async fn refresh( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Refresh"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Refresh", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Refresh")); @@ -1735,13 +2101,22 @@ pub mod node_service_client { pub async fn local_storage_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LocalStorageInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LocalStorageInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LocalStorageInfo")); @@ -1750,13 +2125,22 @@ pub mod node_service_client { pub async fn server_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ServerInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ServerInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ServerInfo")); @@ -1765,13 +2149,22 @@ pub mod node_service_client { pub async fn get_cpus( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetCpus"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetCpus", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetCpus")); @@ -1780,13 +2173,22 @@ pub mod node_service_client { pub async fn get_net_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetNetInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetNetInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetNetInfo")); @@ -1795,13 +2197,22 @@ pub mod node_service_client { pub async fn get_partitions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetPartitions"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetPartitions", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetPartitions")); @@ -1810,13 +2221,22 @@ pub mod node_service_client { pub async fn get_os_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetOsInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetOsInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetOsInfo")); @@ -1825,13 +2245,22 @@ pub mod node_service_client { pub async fn get_se_linux_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSELinuxInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSELinuxInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSELinuxInfo")); @@ -1840,13 +2269,22 @@ pub mod node_service_client { pub async fn get_sys_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysConfig"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSysConfig", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysConfig")); @@ -1855,13 +2293,22 @@ pub mod node_service_client { pub async fn get_sys_errors( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysErrors"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSysErrors", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysErrors")); @@ -1870,13 +2317,22 @@ pub mod node_service_client { pub async fn get_mem_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMemInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetMemInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMemInfo")); @@ -1885,13 +2341,22 @@ pub mod node_service_client { pub async fn get_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetrics"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetMetrics", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMetrics")); @@ -1900,13 +2365,22 @@ pub mod node_service_client { pub async fn get_proc_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetProcInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetProcInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetProcInfo")); @@ -1915,13 +2389,22 @@ pub mod node_service_client { pub async fn start_profiling( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StartProfiling"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/StartProfiling", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StartProfiling")); @@ -1930,28 +2413,48 @@ pub mod node_service_client { pub async fn download_profile_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DownloadProfileData"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DownloadProfileData", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "DownloadProfileData")); + .insert( + GrpcMethod::new("node_service.NodeService", "DownloadProfileData"), + ); self.inner.unary(req, path, codec).await } pub async fn get_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketStats"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetBucketStats", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketStats")); @@ -1960,13 +2463,22 @@ pub mod node_service_client { pub async fn get_sr_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSRMetrics"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSRMetrics", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSRMetrics")); @@ -1975,58 +2487,100 @@ pub mod node_service_client { pub async fn get_all_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetAllBucketStats"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetAllBucketStats", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "GetAllBucketStats")); + .insert( + GrpcMethod::new("node_service.NodeService", "GetAllBucketStats"), + ); self.inner.unary(req, path, codec).await } pub async fn load_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadBucketMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadBucketMetadata", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata"), + ); self.inner.unary(req, path, codec).await } pub async fn delete_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucketMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteBucketMetadata", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata")); + .insert( + GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata"), + ); self.inner.unary(req, path, codec).await } pub async fn delete_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePolicy"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeletePolicy", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePolicy")); @@ -2035,13 +2589,22 @@ pub mod node_service_client { pub async fn load_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicy"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadPolicy", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicy")); @@ -2050,28 +2613,48 @@ pub mod node_service_client { pub async fn load_policy_mapping( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicyMapping"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadPolicyMapping", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping"), + ); self.inner.unary(req, path, codec).await } pub async fn delete_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteUser"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteUser", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteUser")); @@ -2080,28 +2663,48 @@ pub mod node_service_client { pub async fn delete_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteServiceAccount"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteServiceAccount", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount")); + .insert( + GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount"), + ); self.inner.unary(req, path, codec).await } pub async fn load_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadUser"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadUser", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadUser")); @@ -2110,28 +2713,48 @@ pub mod node_service_client { pub async fn load_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadServiceAccount"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadServiceAccount", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadServiceAccount")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadServiceAccount"), + ); self.inner.unary(req, path, codec).await } pub async fn load_group( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadGroup"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadGroup", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadGroup")); @@ -2140,16 +2763,30 @@ pub mod node_service_client { pub async fn reload_site_replication_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadSiteReplicationConfig"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReloadSiteReplicationConfig", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "ReloadSiteReplicationConfig")); + .insert( + GrpcMethod::new( + "node_service.NodeService", + "ReloadSiteReplicationConfig", + ), + ); self.inner.unary(req, path, codec).await } /// rpc VerifyBinary() returns () {}; @@ -2157,13 +2794,22 @@ pub mod node_service_client { pub async fn signal_service( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/SignalService"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/SignalService", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "SignalService")); @@ -2172,58 +2818,100 @@ pub mod node_service_client { pub async fn background_heal_status( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/BackgroundHealStatus"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/BackgroundHealStatus", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus")); + .insert( + GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus"), + ); self.inner.unary(req, path, codec).await } pub async fn get_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetacacheListing"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetMetacacheListing", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "GetMetacacheListing")); + .insert( + GrpcMethod::new("node_service.NodeService", "GetMetacacheListing"), + ); self.inner.unary(req, path, codec).await } pub async fn update_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetacacheListing"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/UpdateMetacacheListing", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing")); + .insert( + GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing"), + ); self.inner.unary(req, path, codec).await } pub async fn reload_pool_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadPoolMeta"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReloadPoolMeta", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReloadPoolMeta")); @@ -2232,13 +2920,22 @@ pub mod node_service_client { pub async fn stop_rebalance( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StopRebalance"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/StopRebalance", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StopRebalance")); @@ -2247,38 +2944,69 @@ pub mod node_service_client { pub async fn load_rebalance_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadRebalanceMeta"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadRebalanceMeta", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta"), + ); self.inner.unary(req, path, codec).await } pub async fn load_transition_tier_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadTransitionTierConfig"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadTransitionTierConfig", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadTransitionTierConfig")); + .insert( + GrpcMethod::new( + "node_service.NodeService", + "LoadTransitionTierConfig", + ), + ); self.inner.unary(req, path, codec).await } } } /// Generated server implementations. pub mod node_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with NodeServiceServer. #[async_trait] @@ -2291,23 +3019,38 @@ pub mod node_service_server { async fn heal_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn list_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn make_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_bucket_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_all( &self, request: tonic::Request, @@ -2315,7 +3058,10 @@ pub mod node_service_server { async fn write_all( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete( &self, request: tonic::Request, @@ -2323,33 +3069,52 @@ pub mod node_service_server { async fn verify_file( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn check_parts( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn rename_part( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn rename_file( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn write( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WriteStream method. - type WriteStreamStream: tonic::codegen::tokio_stream::Stream> + type WriteStreamStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; async fn write_stream( &self, request: tonic::Request>, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Server streaming response type for the ReadAt method. - type ReadAtStream: tonic::codegen::tokio_stream::Stream> + type ReadAtStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; /// rpc Append(AppendRequest) returns (AppendResponse) {}; @@ -2362,7 +3127,9 @@ pub mod node_service_server { request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WalkDir method. - type WalkDirStream: tonic::codegen::tokio_stream::Stream> + type WalkDirStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; async fn walk_dir( @@ -2372,39 +3139,66 @@ pub mod node_service_server { async fn rename_data( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn make_volumes( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn make_volume( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn list_volumes( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn stat_volume( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_paths( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn update_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn write_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_version( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_xl( &self, request: tonic::Request, @@ -2412,25 +3206,42 @@ pub mod node_service_server { async fn delete_version( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_versions( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_multiple( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_volume( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn disk_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Server streaming response type for the NsScanner method. - type NsScannerStream: tonic::codegen::tokio_stream::Stream> + type NsScannerStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; async fn ns_scanner( @@ -2440,35 +3251,59 @@ pub mod node_service_server { async fn lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn un_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn r_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn r_un_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn force_un_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn refresh( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn local_storage_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn server_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_cpus( &self, request: tonic::Request, @@ -2476,137 +3311,236 @@ pub mod node_service_server { async fn get_net_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_partitions( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_os_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_se_linux_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_sys_config( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_sys_errors( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_mem_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_metrics( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_proc_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn start_profiling( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn download_profile_data( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_sr_metrics( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_all_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_policy( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_policy( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_policy_mapping( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_user( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_service_account( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_user( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_service_account( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_group( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn reload_site_replication_config( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// rpc VerifyBinary() returns () {}; /// rpc CommitBinary() returns () {}; async fn signal_service( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn background_heal_status( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn update_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn reload_pool_meta( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn stop_rebalance( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_rebalance_meta( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_transition_tier_config( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct NodeServiceServer { @@ -2629,7 +3563,10 @@ pub mod node_service_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -2673,7 +3610,10 @@ pub mod node_service_server { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -2681,12 +3621,21 @@ pub mod node_service_server { "/node_service.NodeService/Ping" => { #[allow(non_camel_case_types)] struct PingSvc(pub Arc); - impl tonic::server::UnaryService for PingSvc { + impl tonic::server::UnaryService + for PingSvc { type Response = super::PingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::ping(&inner, request).await }; + let fut = async move { + ::ping(&inner, request).await + }; Box::pin(fut) } } @@ -2699,8 +3648,14 @@ pub mod node_service_server { let method = PingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2709,12 +3664,23 @@ pub mod node_service_server { "/node_service.NodeService/HealBucket" => { #[allow(non_camel_case_types)] struct HealBucketSvc(pub Arc); - impl tonic::server::UnaryService for HealBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for HealBucketSvc { type Response = super::HealBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::heal_bucket(&inner, request).await }; + let fut = async move { + ::heal_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2727,8 +3693,14 @@ pub mod node_service_server { let method = HealBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2737,12 +3709,23 @@ pub mod node_service_server { "/node_service.NodeService/ListBucket" => { #[allow(non_camel_case_types)] struct ListBucketSvc(pub Arc); - impl tonic::server::UnaryService for ListBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ListBucketSvc { type Response = super::ListBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::list_bucket(&inner, request).await }; + let fut = async move { + ::list_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2755,8 +3738,14 @@ pub mod node_service_server { let method = ListBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2765,12 +3754,23 @@ pub mod node_service_server { "/node_service.NodeService/MakeBucket" => { #[allow(non_camel_case_types)] struct MakeBucketSvc(pub Arc); - impl tonic::server::UnaryService for MakeBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for MakeBucketSvc { type Response = super::MakeBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::make_bucket(&inner, request).await }; + let fut = async move { + ::make_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2783,8 +3783,14 @@ pub mod node_service_server { let method = MakeBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2793,12 +3799,23 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketInfo" => { #[allow(non_camel_case_types)] struct GetBucketInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetBucketInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetBucketInfoSvc { type Response = super::GetBucketInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_bucket_info(&inner, request).await }; + let fut = async move { + ::get_bucket_info(&inner, request).await + }; Box::pin(fut) } } @@ -2811,8 +3828,14 @@ pub mod node_service_server { let method = GetBucketInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2821,12 +3844,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucket" => { #[allow(non_camel_case_types)] struct DeleteBucketSvc(pub Arc); - impl tonic::server::UnaryService for DeleteBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteBucketSvc { type Response = super::DeleteBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_bucket(&inner, request).await }; + let fut = async move { + ::delete_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2839,8 +3873,14 @@ pub mod node_service_server { let method = DeleteBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2849,12 +3889,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadAll" => { #[allow(non_camel_case_types)] struct ReadAllSvc(pub Arc); - impl tonic::server::UnaryService for ReadAllSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadAllSvc { type Response = super::ReadAllResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_all(&inner, request).await }; + let fut = async move { + ::read_all(&inner, request).await + }; Box::pin(fut) } } @@ -2867,8 +3918,14 @@ pub mod node_service_server { let method = ReadAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2877,12 +3934,23 @@ pub mod node_service_server { "/node_service.NodeService/WriteAll" => { #[allow(non_camel_case_types)] struct WriteAllSvc(pub Arc); - impl tonic::server::UnaryService for WriteAllSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for WriteAllSvc { type Response = super::WriteAllResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write_all(&inner, request).await }; + let fut = async move { + ::write_all(&inner, request).await + }; Box::pin(fut) } } @@ -2895,8 +3963,14 @@ pub mod node_service_server { let method = WriteAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2905,12 +3979,23 @@ pub mod node_service_server { "/node_service.NodeService/Delete" => { #[allow(non_camel_case_types)] struct DeleteSvc(pub Arc); - impl tonic::server::UnaryService for DeleteSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteSvc { type Response = super::DeleteResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete(&inner, request).await }; + let fut = async move { + ::delete(&inner, request).await + }; Box::pin(fut) } } @@ -2923,8 +4008,14 @@ pub mod node_service_server { let method = DeleteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2933,12 +4024,23 @@ pub mod node_service_server { "/node_service.NodeService/VerifyFile" => { #[allow(non_camel_case_types)] struct VerifyFileSvc(pub Arc); - impl tonic::server::UnaryService for VerifyFileSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for VerifyFileSvc { type Response = super::VerifyFileResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::verify_file(&inner, request).await }; + let fut = async move { + ::verify_file(&inner, request).await + }; Box::pin(fut) } } @@ -2951,8 +4053,14 @@ pub mod node_service_server { let method = VerifyFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2961,12 +4069,23 @@ pub mod node_service_server { "/node_service.NodeService/CheckParts" => { #[allow(non_camel_case_types)] struct CheckPartsSvc(pub Arc); - impl tonic::server::UnaryService for CheckPartsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for CheckPartsSvc { type Response = super::CheckPartsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::check_parts(&inner, request).await }; + let fut = async move { + ::check_parts(&inner, request).await + }; Box::pin(fut) } } @@ -2979,8 +4098,14 @@ pub mod node_service_server { let method = CheckPartsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2989,12 +4114,23 @@ pub mod node_service_server { "/node_service.NodeService/RenamePart" => { #[allow(non_camel_case_types)] struct RenamePartSvc(pub Arc); - impl tonic::server::UnaryService for RenamePartSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RenamePartSvc { type Response = super::RenamePartResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::rename_part(&inner, request).await }; + let fut = async move { + ::rename_part(&inner, request).await + }; Box::pin(fut) } } @@ -3007,8 +4143,14 @@ pub mod node_service_server { let method = RenamePartSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3017,12 +4159,23 @@ pub mod node_service_server { "/node_service.NodeService/RenameFile" => { #[allow(non_camel_case_types)] struct RenameFileSvc(pub Arc); - impl tonic::server::UnaryService for RenameFileSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RenameFileSvc { type Response = super::RenameFileResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::rename_file(&inner, request).await }; + let fut = async move { + ::rename_file(&inner, request).await + }; Box::pin(fut) } } @@ -3035,8 +4188,14 @@ pub mod node_service_server { let method = RenameFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3045,12 +4204,21 @@ pub mod node_service_server { "/node_service.NodeService/Write" => { #[allow(non_camel_case_types)] struct WriteSvc(pub Arc); - impl tonic::server::UnaryService for WriteSvc { + impl tonic::server::UnaryService + for WriteSvc { type Response = super::WriteResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write(&inner, request).await }; + let fut = async move { + ::write(&inner, request).await + }; Box::pin(fut) } } @@ -3063,8 +4231,14 @@ pub mod node_service_server { let method = WriteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3073,13 +4247,26 @@ pub mod node_service_server { "/node_service.NodeService/WriteStream" => { #[allow(non_camel_case_types)] struct WriteStreamSvc(pub Arc); - impl tonic::server::StreamingService for WriteStreamSvc { + impl< + T: NodeService, + > tonic::server::StreamingService + for WriteStreamSvc { type Response = super::WriteResponse; type ResponseStream = T::WriteStreamStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request>) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write_stream(&inner, request).await }; + let fut = async move { + ::write_stream(&inner, request).await + }; Box::pin(fut) } } @@ -3092,8 +4279,14 @@ pub mod node_service_server { let method = WriteStreamSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -3102,13 +4295,26 @@ pub mod node_service_server { "/node_service.NodeService/ReadAt" => { #[allow(non_camel_case_types)] struct ReadAtSvc(pub Arc); - impl tonic::server::StreamingService for ReadAtSvc { + impl< + T: NodeService, + > tonic::server::StreamingService + for ReadAtSvc { type Response = super::ReadAtResponse; type ResponseStream = T::ReadAtStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request>) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_at(&inner, request).await }; + let fut = async move { + ::read_at(&inner, request).await + }; Box::pin(fut) } } @@ -3121,8 +4327,14 @@ pub mod node_service_server { let method = ReadAtSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -3131,12 +4343,23 @@ pub mod node_service_server { "/node_service.NodeService/ListDir" => { #[allow(non_camel_case_types)] struct ListDirSvc(pub Arc); - impl tonic::server::UnaryService for ListDirSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ListDirSvc { type Response = super::ListDirResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::list_dir(&inner, request).await }; + let fut = async move { + ::list_dir(&inner, request).await + }; Box::pin(fut) } } @@ -3149,8 +4372,14 @@ pub mod node_service_server { let method = ListDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3159,13 +4388,24 @@ pub mod node_service_server { "/node_service.NodeService/WalkDir" => { #[allow(non_camel_case_types)] struct WalkDirSvc(pub Arc); - impl tonic::server::ServerStreamingService for WalkDirSvc { + impl< + T: NodeService, + > tonic::server::ServerStreamingService + for WalkDirSvc { type Response = super::WalkDirResponse; type ResponseStream = T::WalkDirStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::walk_dir(&inner, request).await }; + let fut = async move { + ::walk_dir(&inner, request).await + }; Box::pin(fut) } } @@ -3178,8 +4418,14 @@ pub mod node_service_server { let method = WalkDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.server_streaming(method, req).await; Ok(res) }; @@ -3188,12 +4434,23 @@ pub mod node_service_server { "/node_service.NodeService/RenameData" => { #[allow(non_camel_case_types)] struct RenameDataSvc(pub Arc); - impl tonic::server::UnaryService for RenameDataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RenameDataSvc { type Response = super::RenameDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::rename_data(&inner, request).await }; + let fut = async move { + ::rename_data(&inner, request).await + }; Box::pin(fut) } } @@ -3206,8 +4463,14 @@ pub mod node_service_server { let method = RenameDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3216,12 +4479,23 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolumes" => { #[allow(non_camel_case_types)] struct MakeVolumesSvc(pub Arc); - impl tonic::server::UnaryService for MakeVolumesSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for MakeVolumesSvc { type Response = super::MakeVolumesResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::make_volumes(&inner, request).await }; + let fut = async move { + ::make_volumes(&inner, request).await + }; Box::pin(fut) } } @@ -3234,8 +4508,14 @@ pub mod node_service_server { let method = MakeVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3244,12 +4524,23 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolume" => { #[allow(non_camel_case_types)] struct MakeVolumeSvc(pub Arc); - impl tonic::server::UnaryService for MakeVolumeSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for MakeVolumeSvc { type Response = super::MakeVolumeResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::make_volume(&inner, request).await }; + let fut = async move { + ::make_volume(&inner, request).await + }; Box::pin(fut) } } @@ -3262,8 +4553,14 @@ pub mod node_service_server { let method = MakeVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3272,12 +4569,23 @@ pub mod node_service_server { "/node_service.NodeService/ListVolumes" => { #[allow(non_camel_case_types)] struct ListVolumesSvc(pub Arc); - impl tonic::server::UnaryService for ListVolumesSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ListVolumesSvc { type Response = super::ListVolumesResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::list_volumes(&inner, request).await }; + let fut = async move { + ::list_volumes(&inner, request).await + }; Box::pin(fut) } } @@ -3290,8 +4598,14 @@ pub mod node_service_server { let method = ListVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3300,12 +4614,23 @@ pub mod node_service_server { "/node_service.NodeService/StatVolume" => { #[allow(non_camel_case_types)] struct StatVolumeSvc(pub Arc); - impl tonic::server::UnaryService for StatVolumeSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for StatVolumeSvc { type Response = super::StatVolumeResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::stat_volume(&inner, request).await }; + let fut = async move { + ::stat_volume(&inner, request).await + }; Box::pin(fut) } } @@ -3318,8 +4643,14 @@ pub mod node_service_server { let method = StatVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3328,12 +4659,23 @@ pub mod node_service_server { "/node_service.NodeService/DeletePaths" => { #[allow(non_camel_case_types)] struct DeletePathsSvc(pub Arc); - impl tonic::server::UnaryService for DeletePathsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeletePathsSvc { type Response = super::DeletePathsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_paths(&inner, request).await }; + let fut = async move { + ::delete_paths(&inner, request).await + }; Box::pin(fut) } } @@ -3346,8 +4688,14 @@ pub mod node_service_server { let method = DeletePathsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3356,12 +4704,23 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetadata" => { #[allow(non_camel_case_types)] struct UpdateMetadataSvc(pub Arc); - impl tonic::server::UnaryService for UpdateMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for UpdateMetadataSvc { type Response = super::UpdateMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::update_metadata(&inner, request).await }; + let fut = async move { + ::update_metadata(&inner, request).await + }; Box::pin(fut) } } @@ -3374,8 +4733,14 @@ pub mod node_service_server { let method = UpdateMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3384,12 +4749,23 @@ pub mod node_service_server { "/node_service.NodeService/WriteMetadata" => { #[allow(non_camel_case_types)] struct WriteMetadataSvc(pub Arc); - impl tonic::server::UnaryService for WriteMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for WriteMetadataSvc { type Response = super::WriteMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write_metadata(&inner, request).await }; + let fut = async move { + ::write_metadata(&inner, request).await + }; Box::pin(fut) } } @@ -3402,8 +4778,14 @@ pub mod node_service_server { let method = WriteMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3412,12 +4794,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadVersion" => { #[allow(non_camel_case_types)] struct ReadVersionSvc(pub Arc); - impl tonic::server::UnaryService for ReadVersionSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadVersionSvc { type Response = super::ReadVersionResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_version(&inner, request).await }; + let fut = async move { + ::read_version(&inner, request).await + }; Box::pin(fut) } } @@ -3430,8 +4823,14 @@ pub mod node_service_server { let method = ReadVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3440,12 +4839,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadXL" => { #[allow(non_camel_case_types)] struct ReadXLSvc(pub Arc); - impl tonic::server::UnaryService for ReadXLSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadXLSvc { type Response = super::ReadXlResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_xl(&inner, request).await }; + let fut = async move { + ::read_xl(&inner, request).await + }; Box::pin(fut) } } @@ -3458,8 +4868,14 @@ pub mod node_service_server { let method = ReadXLSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3468,12 +4884,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersion" => { #[allow(non_camel_case_types)] struct DeleteVersionSvc(pub Arc); - impl tonic::server::UnaryService for DeleteVersionSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteVersionSvc { type Response = super::DeleteVersionResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_version(&inner, request).await }; + let fut = async move { + ::delete_version(&inner, request).await + }; Box::pin(fut) } } @@ -3486,8 +4913,14 @@ pub mod node_service_server { let method = DeleteVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3496,12 +4929,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersions" => { #[allow(non_camel_case_types)] struct DeleteVersionsSvc(pub Arc); - impl tonic::server::UnaryService for DeleteVersionsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteVersionsSvc { type Response = super::DeleteVersionsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_versions(&inner, request).await }; + let fut = async move { + ::delete_versions(&inner, request).await + }; Box::pin(fut) } } @@ -3514,8 +4958,14 @@ pub mod node_service_server { let method = DeleteVersionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3524,12 +4974,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadMultiple" => { #[allow(non_camel_case_types)] struct ReadMultipleSvc(pub Arc); - impl tonic::server::UnaryService for ReadMultipleSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadMultipleSvc { type Response = super::ReadMultipleResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_multiple(&inner, request).await }; + let fut = async move { + ::read_multiple(&inner, request).await + }; Box::pin(fut) } } @@ -3542,8 +5003,14 @@ pub mod node_service_server { let method = ReadMultipleSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3552,12 +5019,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVolume" => { #[allow(non_camel_case_types)] struct DeleteVolumeSvc(pub Arc); - impl tonic::server::UnaryService for DeleteVolumeSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteVolumeSvc { type Response = super::DeleteVolumeResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_volume(&inner, request).await }; + let fut = async move { + ::delete_volume(&inner, request).await + }; Box::pin(fut) } } @@ -3570,8 +5048,14 @@ pub mod node_service_server { let method = DeleteVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3580,12 +5064,23 @@ pub mod node_service_server { "/node_service.NodeService/DiskInfo" => { #[allow(non_camel_case_types)] struct DiskInfoSvc(pub Arc); - impl tonic::server::UnaryService for DiskInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DiskInfoSvc { type Response = super::DiskInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::disk_info(&inner, request).await }; + let fut = async move { + ::disk_info(&inner, request).await + }; Box::pin(fut) } } @@ -3598,8 +5093,14 @@ pub mod node_service_server { let method = DiskInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3608,13 +5109,26 @@ pub mod node_service_server { "/node_service.NodeService/NsScanner" => { #[allow(non_camel_case_types)] struct NsScannerSvc(pub Arc); - impl tonic::server::StreamingService for NsScannerSvc { + impl< + T: NodeService, + > tonic::server::StreamingService + for NsScannerSvc { type Response = super::NsScannerResponse; type ResponseStream = T::NsScannerStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request>) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::ns_scanner(&inner, request).await }; + let fut = async move { + ::ns_scanner(&inner, request).await + }; Box::pin(fut) } } @@ -3627,8 +5141,14 @@ pub mod node_service_server { let method = NsScannerSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -3637,12 +5157,23 @@ pub mod node_service_server { "/node_service.NodeService/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl tonic::server::UnaryService for LockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::lock(&inner, request).await }; + let fut = async move { + ::lock(&inner, request).await + }; Box::pin(fut) } } @@ -3655,8 +5186,14 @@ pub mod node_service_server { let method = LockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3665,12 +5202,23 @@ pub mod node_service_server { "/node_service.NodeService/UnLock" => { #[allow(non_camel_case_types)] struct UnLockSvc(pub Arc); - impl tonic::server::UnaryService for UnLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for UnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::un_lock(&inner, request).await }; + let fut = async move { + ::un_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3683,8 +5231,14 @@ pub mod node_service_server { let method = UnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3693,12 +5247,23 @@ pub mod node_service_server { "/node_service.NodeService/RLock" => { #[allow(non_camel_case_types)] struct RLockSvc(pub Arc); - impl tonic::server::UnaryService for RLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::r_lock(&inner, request).await }; + let fut = async move { + ::r_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3711,8 +5276,14 @@ pub mod node_service_server { let method = RLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3721,12 +5292,23 @@ pub mod node_service_server { "/node_service.NodeService/RUnLock" => { #[allow(non_camel_case_types)] struct RUnLockSvc(pub Arc); - impl tonic::server::UnaryService for RUnLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::r_un_lock(&inner, request).await }; + let fut = async move { + ::r_un_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3739,8 +5321,14 @@ pub mod node_service_server { let method = RUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3749,12 +5337,23 @@ pub mod node_service_server { "/node_service.NodeService/ForceUnLock" => { #[allow(non_camel_case_types)] struct ForceUnLockSvc(pub Arc); - impl tonic::server::UnaryService for ForceUnLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ForceUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::force_un_lock(&inner, request).await }; + let fut = async move { + ::force_un_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3767,8 +5366,14 @@ pub mod node_service_server { let method = ForceUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3777,12 +5382,23 @@ pub mod node_service_server { "/node_service.NodeService/Refresh" => { #[allow(non_camel_case_types)] struct RefreshSvc(pub Arc); - impl tonic::server::UnaryService for RefreshSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RefreshSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::refresh(&inner, request).await }; + let fut = async move { + ::refresh(&inner, request).await + }; Box::pin(fut) } } @@ -3795,8 +5411,14 @@ pub mod node_service_server { let method = RefreshSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3805,12 +5427,24 @@ pub mod node_service_server { "/node_service.NodeService/LocalStorageInfo" => { #[allow(non_camel_case_types)] struct LocalStorageInfoSvc(pub Arc); - impl tonic::server::UnaryService for LocalStorageInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LocalStorageInfoSvc { type Response = super::LocalStorageInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::local_storage_info(&inner, request).await }; + let fut = async move { + ::local_storage_info(&inner, request) + .await + }; Box::pin(fut) } } @@ -3823,8 +5457,14 @@ pub mod node_service_server { let method = LocalStorageInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3833,12 +5473,23 @@ pub mod node_service_server { "/node_service.NodeService/ServerInfo" => { #[allow(non_camel_case_types)] struct ServerInfoSvc(pub Arc); - impl tonic::server::UnaryService for ServerInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ServerInfoSvc { type Response = super::ServerInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::server_info(&inner, request).await }; + let fut = async move { + ::server_info(&inner, request).await + }; Box::pin(fut) } } @@ -3851,8 +5502,14 @@ pub mod node_service_server { let method = ServerInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3861,12 +5518,23 @@ pub mod node_service_server { "/node_service.NodeService/GetCpus" => { #[allow(non_camel_case_types)] struct GetCpusSvc(pub Arc); - impl tonic::server::UnaryService for GetCpusSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetCpusSvc { type Response = super::GetCpusResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_cpus(&inner, request).await }; + let fut = async move { + ::get_cpus(&inner, request).await + }; Box::pin(fut) } } @@ -3879,8 +5547,14 @@ pub mod node_service_server { let method = GetCpusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3889,12 +5563,23 @@ pub mod node_service_server { "/node_service.NodeService/GetNetInfo" => { #[allow(non_camel_case_types)] struct GetNetInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetNetInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetNetInfoSvc { type Response = super::GetNetInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_net_info(&inner, request).await }; + let fut = async move { + ::get_net_info(&inner, request).await + }; Box::pin(fut) } } @@ -3907,8 +5592,14 @@ pub mod node_service_server { let method = GetNetInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3917,12 +5608,23 @@ pub mod node_service_server { "/node_service.NodeService/GetPartitions" => { #[allow(non_camel_case_types)] struct GetPartitionsSvc(pub Arc); - impl tonic::server::UnaryService for GetPartitionsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetPartitionsSvc { type Response = super::GetPartitionsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_partitions(&inner, request).await }; + let fut = async move { + ::get_partitions(&inner, request).await + }; Box::pin(fut) } } @@ -3935,8 +5637,14 @@ pub mod node_service_server { let method = GetPartitionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3945,12 +5653,23 @@ pub mod node_service_server { "/node_service.NodeService/GetOsInfo" => { #[allow(non_camel_case_types)] struct GetOsInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetOsInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetOsInfoSvc { type Response = super::GetOsInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_os_info(&inner, request).await }; + let fut = async move { + ::get_os_info(&inner, request).await + }; Box::pin(fut) } } @@ -3963,8 +5682,14 @@ pub mod node_service_server { let method = GetOsInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3973,12 +5698,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSELinuxInfo" => { #[allow(non_camel_case_types)] struct GetSELinuxInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetSELinuxInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSELinuxInfoSvc { type Response = super::GetSeLinuxInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_se_linux_info(&inner, request).await }; + let fut = async move { + ::get_se_linux_info(&inner, request).await + }; Box::pin(fut) } } @@ -3991,8 +5727,14 @@ pub mod node_service_server { let method = GetSELinuxInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4001,12 +5743,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSysConfig" => { #[allow(non_camel_case_types)] struct GetSysConfigSvc(pub Arc); - impl tonic::server::UnaryService for GetSysConfigSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSysConfigSvc { type Response = super::GetSysConfigResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_sys_config(&inner, request).await }; + let fut = async move { + ::get_sys_config(&inner, request).await + }; Box::pin(fut) } } @@ -4019,8 +5772,14 @@ pub mod node_service_server { let method = GetSysConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4029,12 +5788,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSysErrors" => { #[allow(non_camel_case_types)] struct GetSysErrorsSvc(pub Arc); - impl tonic::server::UnaryService for GetSysErrorsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSysErrorsSvc { type Response = super::GetSysErrorsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_sys_errors(&inner, request).await }; + let fut = async move { + ::get_sys_errors(&inner, request).await + }; Box::pin(fut) } } @@ -4047,8 +5817,14 @@ pub mod node_service_server { let method = GetSysErrorsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4057,12 +5833,23 @@ pub mod node_service_server { "/node_service.NodeService/GetMemInfo" => { #[allow(non_camel_case_types)] struct GetMemInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetMemInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetMemInfoSvc { type Response = super::GetMemInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_mem_info(&inner, request).await }; + let fut = async move { + ::get_mem_info(&inner, request).await + }; Box::pin(fut) } } @@ -4075,8 +5862,14 @@ pub mod node_service_server { let method = GetMemInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4085,12 +5878,23 @@ pub mod node_service_server { "/node_service.NodeService/GetMetrics" => { #[allow(non_camel_case_types)] struct GetMetricsSvc(pub Arc); - impl tonic::server::UnaryService for GetMetricsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetMetricsSvc { type Response = super::GetMetricsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_metrics(&inner, request).await }; + let fut = async move { + ::get_metrics(&inner, request).await + }; Box::pin(fut) } } @@ -4103,8 +5907,14 @@ pub mod node_service_server { let method = GetMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4113,12 +5923,23 @@ pub mod node_service_server { "/node_service.NodeService/GetProcInfo" => { #[allow(non_camel_case_types)] struct GetProcInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetProcInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetProcInfoSvc { type Response = super::GetProcInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_proc_info(&inner, request).await }; + let fut = async move { + ::get_proc_info(&inner, request).await + }; Box::pin(fut) } } @@ -4131,8 +5952,14 @@ pub mod node_service_server { let method = GetProcInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4141,12 +5968,23 @@ pub mod node_service_server { "/node_service.NodeService/StartProfiling" => { #[allow(non_camel_case_types)] struct StartProfilingSvc(pub Arc); - impl tonic::server::UnaryService for StartProfilingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for StartProfilingSvc { type Response = super::StartProfilingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::start_profiling(&inner, request).await }; + let fut = async move { + ::start_profiling(&inner, request).await + }; Box::pin(fut) } } @@ -4159,8 +5997,14 @@ pub mod node_service_server { let method = StartProfilingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4169,12 +6013,24 @@ pub mod node_service_server { "/node_service.NodeService/DownloadProfileData" => { #[allow(non_camel_case_types)] struct DownloadProfileDataSvc(pub Arc); - impl tonic::server::UnaryService for DownloadProfileDataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DownloadProfileDataSvc { type Response = super::DownloadProfileDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::download_profile_data(&inner, request).await }; + let fut = async move { + ::download_profile_data(&inner, request) + .await + }; Box::pin(fut) } } @@ -4187,8 +6043,14 @@ pub mod node_service_server { let method = DownloadProfileDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4197,12 +6059,23 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketStats" => { #[allow(non_camel_case_types)] struct GetBucketStatsSvc(pub Arc); - impl tonic::server::UnaryService for GetBucketStatsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetBucketStatsSvc { type Response = super::GetBucketStatsDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_bucket_stats(&inner, request).await }; + let fut = async move { + ::get_bucket_stats(&inner, request).await + }; Box::pin(fut) } } @@ -4215,8 +6088,14 @@ pub mod node_service_server { let method = GetBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4225,12 +6104,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSRMetrics" => { #[allow(non_camel_case_types)] struct GetSRMetricsSvc(pub Arc); - impl tonic::server::UnaryService for GetSRMetricsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSRMetricsSvc { type Response = super::GetSrMetricsDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_sr_metrics(&inner, request).await }; + let fut = async move { + ::get_sr_metrics(&inner, request).await + }; Box::pin(fut) } } @@ -4243,8 +6133,14 @@ pub mod node_service_server { let method = GetSRMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4253,12 +6149,24 @@ pub mod node_service_server { "/node_service.NodeService/GetAllBucketStats" => { #[allow(non_camel_case_types)] struct GetAllBucketStatsSvc(pub Arc); - impl tonic::server::UnaryService for GetAllBucketStatsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetAllBucketStatsSvc { type Response = super::GetAllBucketStatsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_all_bucket_stats(&inner, request).await }; + let fut = async move { + ::get_all_bucket_stats(&inner, request) + .await + }; Box::pin(fut) } } @@ -4271,8 +6179,14 @@ pub mod node_service_server { let method = GetAllBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4281,12 +6195,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadBucketMetadata" => { #[allow(non_camel_case_types)] struct LoadBucketMetadataSvc(pub Arc); - impl tonic::server::UnaryService for LoadBucketMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadBucketMetadataSvc { type Response = super::LoadBucketMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_bucket_metadata(&inner, request).await }; + let fut = async move { + ::load_bucket_metadata(&inner, request) + .await + }; Box::pin(fut) } } @@ -4299,8 +6225,14 @@ pub mod node_service_server { let method = LoadBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4309,12 +6241,24 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucketMetadata" => { #[allow(non_camel_case_types)] struct DeleteBucketMetadataSvc(pub Arc); - impl tonic::server::UnaryService for DeleteBucketMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteBucketMetadataSvc { type Response = super::DeleteBucketMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_bucket_metadata(&inner, request).await }; + let fut = async move { + ::delete_bucket_metadata(&inner, request) + .await + }; Box::pin(fut) } } @@ -4327,8 +6271,14 @@ pub mod node_service_server { let method = DeleteBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4337,12 +6287,23 @@ pub mod node_service_server { "/node_service.NodeService/DeletePolicy" => { #[allow(non_camel_case_types)] struct DeletePolicySvc(pub Arc); - impl tonic::server::UnaryService for DeletePolicySvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeletePolicySvc { type Response = super::DeletePolicyResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_policy(&inner, request).await }; + let fut = async move { + ::delete_policy(&inner, request).await + }; Box::pin(fut) } } @@ -4355,8 +6316,14 @@ pub mod node_service_server { let method = DeletePolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4365,12 +6332,23 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicy" => { #[allow(non_camel_case_types)] struct LoadPolicySvc(pub Arc); - impl tonic::server::UnaryService for LoadPolicySvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadPolicySvc { type Response = super::LoadPolicyResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_policy(&inner, request).await }; + let fut = async move { + ::load_policy(&inner, request).await + }; Box::pin(fut) } } @@ -4383,8 +6361,14 @@ pub mod node_service_server { let method = LoadPolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4393,12 +6377,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicyMapping" => { #[allow(non_camel_case_types)] struct LoadPolicyMappingSvc(pub Arc); - impl tonic::server::UnaryService for LoadPolicyMappingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadPolicyMappingSvc { type Response = super::LoadPolicyMappingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_policy_mapping(&inner, request).await }; + let fut = async move { + ::load_policy_mapping(&inner, request) + .await + }; Box::pin(fut) } } @@ -4411,8 +6407,14 @@ pub mod node_service_server { let method = LoadPolicyMappingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4421,12 +6423,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteUser" => { #[allow(non_camel_case_types)] struct DeleteUserSvc(pub Arc); - impl tonic::server::UnaryService for DeleteUserSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteUserSvc { type Response = super::DeleteUserResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_user(&inner, request).await }; + let fut = async move { + ::delete_user(&inner, request).await + }; Box::pin(fut) } } @@ -4439,8 +6452,14 @@ pub mod node_service_server { let method = DeleteUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4449,12 +6468,24 @@ pub mod node_service_server { "/node_service.NodeService/DeleteServiceAccount" => { #[allow(non_camel_case_types)] struct DeleteServiceAccountSvc(pub Arc); - impl tonic::server::UnaryService for DeleteServiceAccountSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteServiceAccountSvc { type Response = super::DeleteServiceAccountResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_service_account(&inner, request).await }; + let fut = async move { + ::delete_service_account(&inner, request) + .await + }; Box::pin(fut) } } @@ -4467,8 +6498,14 @@ pub mod node_service_server { let method = DeleteServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4477,12 +6514,23 @@ pub mod node_service_server { "/node_service.NodeService/LoadUser" => { #[allow(non_camel_case_types)] struct LoadUserSvc(pub Arc); - impl tonic::server::UnaryService for LoadUserSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadUserSvc { type Response = super::LoadUserResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_user(&inner, request).await }; + let fut = async move { + ::load_user(&inner, request).await + }; Box::pin(fut) } } @@ -4495,8 +6543,14 @@ pub mod node_service_server { let method = LoadUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4505,12 +6559,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadServiceAccount" => { #[allow(non_camel_case_types)] struct LoadServiceAccountSvc(pub Arc); - impl tonic::server::UnaryService for LoadServiceAccountSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadServiceAccountSvc { type Response = super::LoadServiceAccountResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_service_account(&inner, request).await }; + let fut = async move { + ::load_service_account(&inner, request) + .await + }; Box::pin(fut) } } @@ -4523,8 +6589,14 @@ pub mod node_service_server { let method = LoadServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4533,12 +6605,23 @@ pub mod node_service_server { "/node_service.NodeService/LoadGroup" => { #[allow(non_camel_case_types)] struct LoadGroupSvc(pub Arc); - impl tonic::server::UnaryService for LoadGroupSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadGroupSvc { type Response = super::LoadGroupResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_group(&inner, request).await }; + let fut = async move { + ::load_group(&inner, request).await + }; Box::pin(fut) } } @@ -4551,8 +6634,14 @@ pub mod node_service_server { let method = LoadGroupSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4561,14 +6650,30 @@ pub mod node_service_server { "/node_service.NodeService/ReloadSiteReplicationConfig" => { #[allow(non_camel_case_types)] struct ReloadSiteReplicationConfigSvc(pub Arc); - impl tonic::server::UnaryService - for ReloadSiteReplicationConfigSvc - { + impl< + T: NodeService, + > tonic::server::UnaryService< + super::ReloadSiteReplicationConfigRequest, + > for ReloadSiteReplicationConfigSvc { type Response = super::ReloadSiteReplicationConfigResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::ReloadSiteReplicationConfigRequest, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::reload_site_replication_config(&inner, request).await }; + let fut = async move { + ::reload_site_replication_config( + &inner, + request, + ) + .await + }; Box::pin(fut) } } @@ -4581,8 +6686,14 @@ pub mod node_service_server { let method = ReloadSiteReplicationConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4591,12 +6702,23 @@ pub mod node_service_server { "/node_service.NodeService/SignalService" => { #[allow(non_camel_case_types)] struct SignalServiceSvc(pub Arc); - impl tonic::server::UnaryService for SignalServiceSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for SignalServiceSvc { type Response = super::SignalServiceResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::signal_service(&inner, request).await }; + let fut = async move { + ::signal_service(&inner, request).await + }; Box::pin(fut) } } @@ -4609,8 +6731,14 @@ pub mod node_service_server { let method = SignalServiceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4619,12 +6747,24 @@ pub mod node_service_server { "/node_service.NodeService/BackgroundHealStatus" => { #[allow(non_camel_case_types)] struct BackgroundHealStatusSvc(pub Arc); - impl tonic::server::UnaryService for BackgroundHealStatusSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for BackgroundHealStatusSvc { type Response = super::BackgroundHealStatusResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::background_heal_status(&inner, request).await }; + let fut = async move { + ::background_heal_status(&inner, request) + .await + }; Box::pin(fut) } } @@ -4637,8 +6777,14 @@ pub mod node_service_server { let method = BackgroundHealStatusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4647,12 +6793,24 @@ pub mod node_service_server { "/node_service.NodeService/GetMetacacheListing" => { #[allow(non_camel_case_types)] struct GetMetacacheListingSvc(pub Arc); - impl tonic::server::UnaryService for GetMetacacheListingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetMetacacheListingSvc { type Response = super::GetMetacacheListingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_metacache_listing(&inner, request).await }; + let fut = async move { + ::get_metacache_listing(&inner, request) + .await + }; Box::pin(fut) } } @@ -4665,8 +6823,14 @@ pub mod node_service_server { let method = GetMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4675,12 +6839,27 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetacacheListing" => { #[allow(non_camel_case_types)] struct UpdateMetacacheListingSvc(pub Arc); - impl tonic::server::UnaryService for UpdateMetacacheListingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for UpdateMetacacheListingSvc { type Response = super::UpdateMetacacheListingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::update_metacache_listing(&inner, request).await }; + let fut = async move { + ::update_metacache_listing( + &inner, + request, + ) + .await + }; Box::pin(fut) } } @@ -4693,8 +6872,14 @@ pub mod node_service_server { let method = UpdateMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4703,12 +6888,23 @@ pub mod node_service_server { "/node_service.NodeService/ReloadPoolMeta" => { #[allow(non_camel_case_types)] struct ReloadPoolMetaSvc(pub Arc); - impl tonic::server::UnaryService for ReloadPoolMetaSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReloadPoolMetaSvc { type Response = super::ReloadPoolMetaResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::reload_pool_meta(&inner, request).await }; + let fut = async move { + ::reload_pool_meta(&inner, request).await + }; Box::pin(fut) } } @@ -4721,8 +6917,14 @@ pub mod node_service_server { let method = ReloadPoolMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4731,12 +6933,23 @@ pub mod node_service_server { "/node_service.NodeService/StopRebalance" => { #[allow(non_camel_case_types)] struct StopRebalanceSvc(pub Arc); - impl tonic::server::UnaryService for StopRebalanceSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for StopRebalanceSvc { type Response = super::StopRebalanceResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::stop_rebalance(&inner, request).await }; + let fut = async move { + ::stop_rebalance(&inner, request).await + }; Box::pin(fut) } } @@ -4749,8 +6962,14 @@ pub mod node_service_server { let method = StopRebalanceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4759,12 +6978,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadRebalanceMeta" => { #[allow(non_camel_case_types)] struct LoadRebalanceMetaSvc(pub Arc); - impl tonic::server::UnaryService for LoadRebalanceMetaSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadRebalanceMetaSvc { type Response = super::LoadRebalanceMetaResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_rebalance_meta(&inner, request).await }; + let fut = async move { + ::load_rebalance_meta(&inner, request) + .await + }; Box::pin(fut) } } @@ -4777,8 +7008,14 @@ pub mod node_service_server { let method = LoadRebalanceMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4787,12 +7024,29 @@ pub mod node_service_server { "/node_service.NodeService/LoadTransitionTierConfig" => { #[allow(non_camel_case_types)] struct LoadTransitionTierConfigSvc(pub Arc); - impl tonic::server::UnaryService for LoadTransitionTierConfigSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadTransitionTierConfigSvc { type Response = super::LoadTransitionTierConfigResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::LoadTransitionTierConfigRequest, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_transition_tier_config(&inner, request).await }; + let fut = async move { + ::load_transition_tier_config( + &inner, + request, + ) + .await + }; Box::pin(fut) } } @@ -4805,20 +7059,36 @@ pub mod node_service_server { let method = LoadTransitionTierConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert(tonic::Status::GRPC_STATUS, (tonic::Code::Unimplemented as i32).into()); - headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index f0c8d1185..fea12acba 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -20,6 +20,8 @@ log.workspace = true async-trait.workspace = true bytes.workspace = true clap.workspace = true +csv = "1.3.1" +datafusion = { workspace = true } common.workspace = true ecstore.workspace = true policy.workspace =true @@ -69,6 +71,8 @@ const-str = { version = "0.6.1", features = ["std", "proc"] } atoi = "2.0.0" serde_urlencoded = "0.7.1" crypto = { path = "../crypto" } +query = { path = "../s3select/query" } +api = { path = "../s3select/api" } iam = { path = "../iam" } jsonwebtoken = "9.3.0" tower-http = { version = "0.6.2", features = ["cors"] } diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 51cf0ea9c..65544be52 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -4,8 +4,11 @@ use super::options::extract_metadata; use super::options::put_opts; use crate::auth::get_condition_values; use crate::storage::access::ReqInfo; +use api::query::Context; +use api::query::Query; use bytes::Bytes; use common::error::Result; +use datafusion::arrow::json::writer::JsonArray; use ecstore::bucket::error::BucketMetadataError; use ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG; use ecstore::bucket::metadata::BUCKET_NOTIFICATION_CONFIG; @@ -39,6 +42,9 @@ use ecstore::xhttp; use futures::pin_mut; use futures::{Stream, StreamExt}; use http::HeaderMap; +use iam::policy::action::Action; +use api::server::dbms::DatabaseManagerSystem; +use iam::policy::action::S3Action; use lazy_static::lazy_static; use log::warn; use policy::auth; @@ -47,6 +53,7 @@ use policy::policy::action::S3Action; use policy::policy::BucketPolicy; use policy::policy::BucketPolicyArgs; use policy::policy::Validator; +use query::instance::make_cnosdbms; use s3s::dto::*; use s3s::s3_error; use s3s::S3Error; @@ -54,6 +61,8 @@ use s3s::S3ErrorCode; use s3s::S3Result; use s3s::S3; use s3s::{S3Request, S3Response}; +use tokio::sync::mpsc; +use tokio_stream::wrappers::ReceiverStream; use std::fmt::Debug; use std::str::FromStr; use tokio_util::io::ReaderStream; @@ -1859,6 +1868,70 @@ impl S3 for FS { } Ok(S3Response::new(PutObjectAclOutput::default())) } + + async fn select_object_content( + &self, + req: S3Request, + ) -> S3Result> { + info!("handle select_object_content"); + + let input = req.input; + info!("{:?}", input); + + let db = make_cnosdbms(input).await.map_err(|_| { + s3_error!(InternalError) + })?; + let query = Query::new(Context {input: input.clone()}, input.request.expression); + let result = db.execute(&query).await.map_err(|_| { + s3_error!(InternalError) + })?; + + let results = result.result().chunk_result().await.unwrap().to_vec(); + + let mut buffer = Vec::new(); + if input.request.output_serialization.csv.is_some() { + let mut csv_writer = CsvWriterBuilder::new().with_header(false).build(&mut buffer); + for batch in results { + csv_writer + .write(&batch) + .map_err(|e| s3_error!(InternalError, "cann't encode output to csv. e: {}", e.to_string()))?; + } + } else if input.request.output_serialization.json.is_some() { + let mut json_writer = JsonWriterBuilder::new() + .with_explicit_nulls(true) + .build::<_, JsonArray>(&mut buffer); + for batch in results { + json_writer + .write(&batch) + .map_err(|e| s3_error!(InternalError, "cann't encode output to json. e: {}", e.to_string()))?; + } + json_writer + .finish() + .map_err(|e| s3_error!(InternalError, "writer output into json error, e: {}", e.to_string()))?; + } else { + return Err(s3_error!(InvalidArgument, "unknow output format")); + } + + let (tx, rx) = mpsc::channel::>(2); + let stream = ReceiverStream::new(rx); + tokio::spawn(async move { + let _ = tx + .send(Ok(SelectObjectContentEvent::Cont(ContinuationEvent::default()))) + .await; + let _ = tx + .send(Ok(SelectObjectContentEvent::Records(RecordsEvent { + payload: Some(Bytes::from(buffer)), + }))) + .await; + let _ = tx.send(Ok(SelectObjectContentEvent::End(EndEvent::default()))).await; + + drop(tx); + }); + + Ok(S3Response::new(SelectObjectContentOutput { + payload: Some(SelectObjectContentEventStream::new(stream)), + })) + } } #[allow(dead_code)] diff --git a/s3select/api/Cargo.toml b/s3select/api/Cargo.toml index 26f65bace..0f147396c 100644 --- a/s3select/api/Cargo.toml +++ b/s3select/api/Cargo.toml @@ -5,6 +5,16 @@ edition.workspace = true [dependencies] async-trait.workspace = true +bytes.workspace = true +chrono.workspace = true datafusion = { workspace = true } +ecstore.workspace = true futures = { workspace = true } -snafu = { workspace = true, features = ["backtrace"] } \ No newline at end of file +futures-core = "0.3.31" +http.workspace = true +object_store = "0.11.2" +s3s.workspace = true +snafu = { workspace = true, features = ["backtrace"] } +tokio.workspace = true +tracing.workspace = true +url.workspace = true \ No newline at end of file diff --git a/s3select/api/src/lib.rs b/s3select/api/src/lib.rs index acf653932..9c61128b6 100644 --- a/s3select/api/src/lib.rs +++ b/s3select/api/src/lib.rs @@ -1,8 +1,9 @@ use std::fmt::Display; -use datafusion::common::DataFusionError; +use datafusion::{common::DataFusionError, sql::sqlparser::parser::ParserError}; use snafu::{Backtrace, Location, Snafu}; +pub mod object_store; pub mod query; pub mod server; @@ -16,6 +17,21 @@ pub enum QueryError { location: Location, backtrace: Backtrace, }, + + #[snafu(display("This feature is not implemented: {}", err))] + NotImplemented { err: String }, + + #[snafu(display("Multi-statement not allow, found num:{}, sql:{}", num, sql))] + MultiStatement { num: usize, sql: String }, + + #[snafu(display("Failed to build QueryDispatcher. err: {}", err))] + BuildQueryDispatcher { err: String }, + + #[snafu(display("The query has been canceled"))] + Cancel, + + #[snafu(display("{}", source))] + Parser { source: ParserError }, } impl From for QueryError { diff --git a/s3select/api/src/object_store.rs b/s3select/api/src/object_store.rs new file mode 100644 index 000000000..c10a26fa3 --- /dev/null +++ b/s3select/api/src/object_store.rs @@ -0,0 +1,150 @@ +use async_trait::async_trait; +use bytes::Bytes; +use chrono::Utc; +use ecstore::new_object_layer_fn; +use ecstore::store::ECStore; +use ecstore::store_api::ObjectIO; +use ecstore::store_api::ObjectOptions; +use ecstore::StorageAPI; +use futures::stream; +use futures::StreamExt; +use futures_core::stream::BoxStream; +use http::HeaderMap; +use object_store::path::Path; +use object_store::Attributes; +use object_store::GetOptions; +use object_store::GetResult; +use object_store::ListResult; +use object_store::MultipartUpload; +use object_store::ObjectMeta; +use object_store::ObjectStore; +use object_store::PutMultipartOpts; +use object_store::PutOptions; +use object_store::PutPayload; +use object_store::PutResult; +use object_store::{Error as o_Error, Result}; +use s3s::dto::SelectObjectContentInput; +use s3s::s3_error; +use s3s::S3Result; +use std::ops::Range; +use std::sync::Arc; +use tracing::info; + +#[derive(Debug)] +pub struct EcObjectStore { + input: SelectObjectContentInput, + + store: Arc, +} + +impl EcObjectStore { + pub fn new(input: SelectObjectContentInput) -> S3Result { + let Some(store) = new_object_layer_fn() else { + return Err(s3_error!(InternalError, "ec store not inited")); + }; + + Ok(Self { input, store }) + } +} + +impl std::fmt::Display for EcObjectStore { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("EcObjectStore") + } +} + +#[async_trait] +impl ObjectStore for EcObjectStore { + async fn put_opts(&self, _location: &Path, _payload: PutPayload, _opts: PutOptions) -> Result { + unimplemented!() + } + + async fn put_multipart_opts(&self, _location: &Path, _opts: PutMultipartOpts) -> Result> { + unimplemented!() + } + + async fn get_opts(&self, location: &Path, _options: GetOptions) -> Result { + info!("{:?}", location); + let opts = ObjectOptions::default(); + let h = HeaderMap::new(); + let reader = self + .store + .get_object_reader(&self.input.bucket, &self.input.key, None, h, &opts) + .await + .map_err(|_| o_Error::NotFound { + path: format!("{}/{}", self.input.bucket, self.input.key), + source: "can not get object info".into(), + })?; + + let stream = stream::unfold(reader.stream, |mut blob| async move { + match blob.next().await { + Some(Ok(chunk)) => { + let bytes = Bytes::from(chunk); + Some((Ok(bytes), blob)) + } + _ => None, + } + }) + .boxed(); + let meta = ObjectMeta { + location: location.clone(), + last_modified: Utc::now(), + size: reader.object_info.size, + e_tag: reader.object_info.etag, + version: None, + }; + let attributes = Attributes::default(); + + Ok(GetResult { + payload: object_store::GetResultPayload::Stream(stream), + meta, + range: 0..reader.object_info.size, + attributes, + }) + } + + async fn get_ranges(&self, _location: &Path, _ranges: &[Range]) -> Result> { + unimplemented!() + } + + async fn head(&self, location: &Path) -> Result { + info!("{:?}", location); + let opts = ObjectOptions::default(); + let info = self + .store + .get_object_info(&self.input.bucket, &self.input.key, &opts) + .await + .map_err(|_| o_Error::NotFound { + path: format!("{}/{}", self.input.bucket, self.input.key), + source: "can not get object info".into(), + })?; + + Ok(ObjectMeta { + location: location.clone(), + last_modified: Utc::now(), + size: info.size, + e_tag: info.etag, + version: None, + }) + } + + async fn delete(&self, _location: &Path) -> Result<()> { + unimplemented!() + } + + fn list(&self, _prefix: Option<&Path>) -> BoxStream<'_, Result> { + unimplemented!() + } + + async fn list_with_delimiter(&self, _prefix: Option<&Path>) -> Result { + unimplemented!() + } + + async fn copy(&self, _from: &Path, _to: &Path) -> Result<()> { + unimplemented!() + } + + async fn copy_if_not_exists(&self, _from: &Path, _too: &Path) -> Result<()> { + unimplemented!() + } +} diff --git a/s3select/api/src/query/analyzer.rs b/s3select/api/src/query/analyzer.rs new file mode 100644 index 000000000..db849566c --- /dev/null +++ b/s3select/api/src/query/analyzer.rs @@ -0,0 +1,12 @@ +use std::sync::Arc; + +use datafusion::logical_expr::LogicalPlan; + +use super::session::SessionCtx; +use crate::QueryResult; + +pub type AnalyzerRef = Arc; + +pub trait Analyzer { + fn analyze(&self, plan: &LogicalPlan, session: &SessionCtx) -> QueryResult; +} diff --git a/s3select/api/src/query/dispatcher.rs b/s3select/api/src/query/dispatcher.rs index baa1885f1..433ddf01e 100644 --- a/s3select/api/src/query/dispatcher.rs +++ b/s3select/api/src/query/dispatcher.rs @@ -12,10 +12,6 @@ use super::{ #[async_trait] pub trait QueryDispatcher: Send + Sync { - async fn start(&self) -> QueryResult<()>; - - fn stop(&self); - // fn create_query_id(&self) -> QueryId; // fn query_info(&self, id: &QueryId); diff --git a/s3select/api/src/query/execution.rs b/s3select/api/src/query/execution.rs index 94d9b46c1..10c48acc3 100644 --- a/s3select/api/src/query/execution.rs +++ b/s3select/api/src/query/execution.rs @@ -43,18 +43,6 @@ pub trait QueryExecution: Send + Sync { async fn start(&self) -> QueryResult; // 停止 fn cancel(&self) -> QueryResult<()>; - // query状态 - // 查询计划 - // 静态信息 - // fn info(&self) -> QueryInfo; - // 运行时信息 - // fn status(&self) -> QueryStatus; - // sql - // 资源占用(cpu时间/内存/吞吐量等) - // 是否需要持久化query信息 - fn need_persist(&self) -> bool { - false - } } pub enum Output { diff --git a/s3select/api/src/query/logical_planner.rs b/s3select/api/src/query/logical_planner.rs index 325be6c84..cef844b37 100644 --- a/s3select/api/src/query/logical_planner.rs +++ b/s3select/api/src/query/logical_planner.rs @@ -1,6 +1,12 @@ +use async_trait::async_trait; use datafusion::arrow::datatypes::SchemaRef; use datafusion::logical_expr::LogicalPlan as DFPlan; +use crate::QueryResult; + +use super::ast::ExtStatement; +use super::session::SessionCtx; + #[derive(Clone)] pub enum Plan { // only support query sql @@ -27,3 +33,8 @@ impl QueryPlan { matches!(self.df_plan, DFPlan::Explain(_) | DFPlan::Analyze(_)) } } + +#[async_trait] +pub trait LogicalPlanner { + async fn create_logical_plan(&self, statement: ExtStatement, session: &SessionCtx) -> QueryResult; +} diff --git a/s3select/api/src/query/mod.rs b/s3select/api/src/query/mod.rs index e93fc5751..6ddd2dc86 100644 --- a/s3select/api/src/query/mod.rs +++ b/s3select/api/src/query/mod.rs @@ -1,15 +1,22 @@ +use s3s::dto::SelectObjectContentInput; + +pub mod analyzer; pub mod ast; pub mod datasource; pub mod dispatcher; pub mod execution; pub mod function; pub mod logical_planner; +pub mod optimizer; pub mod parser; +pub mod physical_planner; +pub mod scheduler; pub mod session; #[derive(Clone)] pub struct Context { // maybe we need transfer some info? + pub input: SelectObjectContentInput, } #[derive(Clone)] @@ -17,3 +24,18 @@ pub struct Query { context: Context, content: String, } + +impl Query { + #[inline(always)] + pub fn new(context: Context, content: String) -> Self { + Self { context, content } + } + + pub fn context(&self) -> &Context { + &self.context + } + + pub fn content(&self) -> &str { + self.content.as_str() + } +} diff --git a/s3select/api/src/query/optimizer.rs b/s3select/api/src/query/optimizer.rs new file mode 100644 index 000000000..c2392eb92 --- /dev/null +++ b/s3select/api/src/query/optimizer.rs @@ -0,0 +1,15 @@ +use std::sync::Arc; + +use async_trait::async_trait; +use datafusion::physical_plan::ExecutionPlan; + +use super::logical_planner::QueryPlan; +use super::session::SessionCtx; +use crate::QueryResult; + +pub type OptimizerRef = Arc; + +#[async_trait] +pub trait Optimizer { + async fn optimize(&self, plan: &QueryPlan, session: &SessionCtx) -> QueryResult>; +} diff --git a/s3select/api/src/query/physical_planner.rs b/s3select/api/src/query/physical_planner.rs new file mode 100644 index 000000000..c71787e9c --- /dev/null +++ b/s3select/api/src/query/physical_planner.rs @@ -0,0 +1,21 @@ +use std::sync::Arc; + +use async_trait::async_trait; +use datafusion::logical_expr::LogicalPlan; +use datafusion::physical_plan::ExecutionPlan; +use datafusion::physical_planner::ExtensionPlanner; + +use super::session::SessionCtx; +use crate::QueryResult; + +#[async_trait] +pub trait PhysicalPlanner { + /// Given a `LogicalPlan`, create an `ExecutionPlan` suitable for execution + async fn create_physical_plan( + &self, + logical_plan: &LogicalPlan, + session_state: &SessionCtx, + ) -> QueryResult>; + + fn inject_physical_transform_rule(&mut self, rule: Arc); +} diff --git a/s3select/api/src/query/scheduler.rs b/s3select/api/src/query/scheduler.rs new file mode 100644 index 000000000..3dd49c225 --- /dev/null +++ b/s3select/api/src/query/scheduler.rs @@ -0,0 +1,32 @@ +use std::sync::Arc; + +use async_trait::async_trait; +use datafusion::common::Result; +use datafusion::execution::context::TaskContext; +use datafusion::physical_plan::{ExecutionPlan, SendableRecordBatchStream}; + +pub type SchedulerRef = Arc; + +#[async_trait] +pub trait Scheduler { + /// Schedule the provided [`ExecutionPlan`] on this [`Scheduler`]. + /// + /// Returns a [`ExecutionResults`] that can be used to receive results as they are produced, + /// as a [`futures::Stream`] of [`RecordBatch`] + async fn schedule(&self, plan: Arc, context: Arc) -> Result; +} + +pub struct ExecutionResults { + stream: SendableRecordBatchStream, +} + +impl ExecutionResults { + pub fn new(stream: SendableRecordBatchStream) -> Self { + Self { stream } + } + + /// Returns a [`SendableRecordBatchStream`] of this execution + pub fn stream(self) -> SendableRecordBatchStream { + self.stream + } +} diff --git a/s3select/api/src/query/session.rs b/s3select/api/src/query/session.rs index d387ff711..23e80e3c9 100644 --- a/s3select/api/src/query/session.rs +++ b/s3select/api/src/query/session.rs @@ -1,10 +1,17 @@ use std::sync::Arc; -use datafusion::execution::context::SessionState; +use datafusion::{ + execution::{context::SessionState, runtime_env::RuntimeEnvBuilder, SessionStateBuilder}, + prelude::SessionContext, +}; + +use crate::{object_store::EcObjectStore, QueryError, QueryResult}; + +use super::Context; #[derive(Clone)] pub struct SessionCtx { - desc: Arc, + _desc: Arc, inner: SessionState, } @@ -18,3 +25,33 @@ impl SessionCtx { pub struct SessionCtxDesc { // maybe we need some info } + +#[derive(Default)] +pub struct SessionCtxFactory {} + +impl SessionCtxFactory { + pub fn create_session_ctx(&self, context: &Context) -> QueryResult { + let df_session_ctx = self.build_df_session_context(context)?; + + Ok(SessionCtx { + _desc: Arc::new(SessionCtxDesc {}), + inner: df_session_ctx.state(), + }) + } + + fn build_df_session_context(&self, context: &Context) -> QueryResult { + let path = format!("s3://{}", context.input.bucket); + let store_url = url::Url::parse(&path).unwrap(); + let store = EcObjectStore::new(context.input.clone()).map_err(|_| QueryError::NotImplemented { err: String::new() })?; + + let rt = RuntimeEnvBuilder::new().build()?; + let df_session_state = SessionStateBuilder::new() + .with_runtime_env(Arc::new(rt)) + .with_object_store(&store_url, Arc::new(store)) + .with_default_features() + .build(); + let df_session_ctx = SessionContext::new_with_state(df_session_state); + + Ok(df_session_ctx) + } +} diff --git a/s3select/api/src/server/dbms.rs b/s3select/api/src/server/dbms.rs index dc9e195d2..85d320555 100644 --- a/s3select/api/src/server/dbms.rs +++ b/s3select/api/src/server/dbms.rs @@ -30,7 +30,6 @@ impl QueryHandle { #[async_trait] pub trait DatabaseManagerSystem { - async fn start(&self) -> QueryResult<()>; async fn execute(&self, query: &Query) -> QueryResult; async fn build_query_state_machine(&self, query: Query) -> QueryResult; async fn build_logical_plan(&self, query_state_machine: QueryStateMachineRef) -> QueryResult>; @@ -39,5 +38,4 @@ pub trait DatabaseManagerSystem { logical_plan: Plan, query_state_machine: QueryStateMachineRef, ) -> QueryResult; - fn metrics(&self) -> String; } diff --git a/s3select/query/Cargo.toml b/s3select/query/Cargo.toml index 218f5cee6..61b0b07b9 100644 --- a/s3select/query/Cargo.toml +++ b/s3select/query/Cargo.toml @@ -5,8 +5,13 @@ edition.workspace = true [dependencies] api = { path = "../api" } +async-recursion = { workspace = true } async-trait.workspace = true datafusion = { workspace = true } derive_builder = { workspace = true } +futures = { workspace = true } +parking_lot = { version = "0.12.1" } +s3s.workspace = true +snafu = { workspace = true, features = ["backtrace"] } tokio = { workspace = true } tracing = { workspace = true } \ No newline at end of file diff --git a/s3select/query/src/data_source/data_source.rs b/s3select/query/src/data_source/data_source.rs index a2c32f948..77df6e810 100644 --- a/s3select/query/src/data_source/data_source.rs +++ b/s3select/query/src/data_source/data_source.rs @@ -1,4 +1,5 @@ use std::any::Any; +use std::borrow::Cow; use std::fmt::Display; use std::sync::Arc; use std::write; @@ -10,7 +11,6 @@ use datafusion::datasource::listing::ListingTable; use datafusion::datasource::{provider_as_source, TableProvider}; use datafusion::error::DataFusionError; use datafusion::logical_expr::{LogicalPlan, LogicalPlanBuilder, TableProviderFilterPushDown, TableSource}; -use datafusion::physical_plan::ExecutionPlan; use datafusion::prelude::Expr; use datafusion::sql::TableReference; use tracing::debug; @@ -28,11 +28,9 @@ pub struct TableSourceAdapter { impl TableSourceAdapter { pub fn try_new( table_ref: impl Into, - database_name: impl Into, table_name: impl Into, table_handle: impl Into, ) -> Result { - let database_name = database_name.into(); let table_name: String = table_name.into(); let table_handle = table_handle.into(); @@ -46,7 +44,7 @@ impl TableSourceAdapter { TableHandle::TableProvider(t) => { let table_source = provider_as_source(t.clone()); if let Some(plan) = table_source.get_logical_plan() { - LogicalPlanBuilder::from(plan.clone()).build()? + LogicalPlanBuilder::from(plan.into_owned()).build()? } else { LogicalPlanBuilder::scan(table_ref, table_source, None)?.build()? } @@ -91,8 +89,8 @@ impl TableSource for TableSourceAdapter { } /// Called by [`InlineTableScan`] - fn get_logical_plan(&self) -> Option<&LogicalPlan> { - Some(&self.plan) + fn get_logical_plan(&self) -> Option> { + Some(Cow::Owned(self.plan.clone())) } } diff --git a/s3select/query/src/dispatcher/manager.rs b/s3select/query/src/dispatcher/manager.rs index bde400f4f..effe17bf3 100644 --- a/s3select/query/src/dispatcher/manager.rs +++ b/s3select/query/src/dispatcher/manager.rs @@ -1,51 +1,62 @@ use std::{ collections::HashMap, + pin::Pin, sync::{Arc, Mutex}, + task::{Context, Poll}, }; use api::{ query::{ + ast::ExtStatement, dispatcher::QueryDispatcher, execution::{Output, QueryStateMachine}, function::FuncMetaManagerRef, - logical_planner::Plan, + logical_planner::{LogicalPlanner, Plan}, parser::Parser, + session::{SessionCtx, SessionCtxFactory}, Query, }, QueryError, QueryResult, }; use async_trait::async_trait; +use datafusion::{ + arrow::{datatypes::SchemaRef, record_batch::RecordBatch}, + config::CsvOptions, + datasource::{ + file_format::{csv::CsvFormat, json::JsonFormat, parquet::ParquetFormat}, + listing::{ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl}, + }, + error::Result as DFResult, + execution::{RecordBatchStream, SendableRecordBatchStream}, +}; +use futures::{Stream, StreamExt}; +use s3s::dto::SelectObjectContentInput; use tokio::task::JoinHandle; -use crate::metadata::TableHandleProviderRef; +use crate::{ + execution::factory::QueryExecutionFactoryRef, + metadata::{ + base_table::BaseTableProvider, + ContextProviderExtension, MetadataProvider, TableHandleProviderRef, + }, + sql::logical::planner::DefaultLogicalPlanner, +}; #[derive(Clone)] pub struct SimpleQueryDispatcher { + input: SelectObjectContentInput, // client for default tenant default_table_provider: TableHandleProviderRef, - // memory pool - // memory_pool: MemoryPoolRef, - // query tracker + session_factory: Arc, // parser parser: Arc, // get query execution factory query_execution_factory: QueryExecutionFactoryRef, func_manager: FuncMetaManagerRef, - - async_task_joinhandle: Arc>>>, - failed_task_joinhandle: Arc>>>, } #[async_trait] impl QueryDispatcher for SimpleQueryDispatcher { - async fn start(&self) -> QueryResult<()> { - self.execute_persister_query(self.coord.node_id()).await - } - - fn stop(&self) { - // TODO - } - async fn execute_query(&self, query: &Query) -> QueryResult { let query_state_machine = { self.build_query_state_machine(query.clone()).await? }; @@ -66,7 +77,6 @@ impl QueryDispatcher for SimpleQueryDispatcher { let logical_planner = DefaultLogicalPlanner::new(&scheme_provider); - let span_recorder = session.get_child_span("parse sql"); let statements = self.parser.parse(query.content())?; // not allow multi statement @@ -82,8 +92,6 @@ impl QueryDispatcher for SimpleQueryDispatcher { None => return Ok(None), }; - drop(span_recorder); - let logical_plan = self .statement_to_logical_plan(stmt, &logical_planner, query_state_machine) .await?; @@ -95,9 +103,7 @@ impl QueryDispatcher for SimpleQueryDispatcher { } async fn build_query_state_machine(&self, query: Query) -> QueryResult> { - let session = self - .session_factory - .create_session_ctx(query.context(), self.memory_pool.clone(), self.coord.clone())?; + let session = self.session_factory.create_session_ctx(query.context())?; let query_state_machine = Arc::new(QueryStateMachine::begin(query, session)); Ok(query_state_machine) @@ -114,7 +120,7 @@ impl SimpleQueryDispatcher { // begin analyze query_state_machine.begin_analyze(); let logical_plan = logical_planner - .create_logical_plan(stmt, &query_state_machine.session, self.coord.get_config().query.auth_enabled) + .create_logical_plan(stmt, &query_state_machine.session) .await?; query_state_machine.end_analyze(); @@ -127,79 +133,85 @@ impl SimpleQueryDispatcher { .create_query_execution(logical_plan, query_state_machine.clone()) .await?; - // TrackedQuery.drop() is called implicitly when the value goes out of scope, - self.query_tracker - .try_track_query(query_state_machine.query_id, execution) - .await? - .start() - .await + match execution.start().await { + Ok(Output::StreamData(stream)) => Ok(Output::StreamData(Box::pin(TrackedRecordBatchStream { inner: stream }))), + Ok(nil @ Output::Nil(_)) => Ok(nil), + Err(err) => Err(err), + } } async fn build_scheme_provider(&self, session: &SessionCtx) -> QueryResult { - let meta_client = self.build_current_session_meta_client(session).await?; - let current_session_table_provider = self.build_table_handle_provider(meta_client.clone())?; - let metadata_provider = MetadataProvider::new( - self.coord.clone(), - meta_client, - current_session_table_provider, - self.default_table_provider.clone(), - self.func_manager.clone(), - self.query_tracker.clone(), - session.clone(), - ); + let path = format!("s3://{}/{}", self.input.bucket, self.input.key); + let table_path = ListingTableUrl::parse(path)?; + let listing_options = if self.input.request.input_serialization.csv.is_some() { + let file_format = CsvFormat::default().with_options(CsvOptions::default().with_has_header(false)); + ListingOptions::new(Arc::new(file_format)).with_file_extension(".csv") + } else if self.input.request.input_serialization.parquet.is_some() { + let file_format = ParquetFormat::new(); + ListingOptions::new(Arc::new(file_format)).with_file_extension(".parquet") + } else if self.input.request.input_serialization.json.is_some() { + let file_format = JsonFormat::default(); + ListingOptions::new(Arc::new(file_format)).with_file_extension(".json") + } else { + return Err(QueryError::NotImplemented { + err: "not support this file type".to_string(), + }); + }; + + let resolve_schema = listing_options.infer_schema(session.inner(), &table_path).await?; + let config = ListingTableConfig::new(table_path) + .with_listing_options(listing_options) + .with_schema(resolve_schema); + let provider = Arc::new(ListingTable::try_new(config)?); + let current_session_table_provider = self.build_table_handle_provider()?; + let metadata_provider = + MetadataProvider::new(provider, current_session_table_provider, self.func_manager.clone(), session.clone()); Ok(metadata_provider) } - async fn build_current_session_meta_client(&self, session: &SessionCtx) -> QueryResult { - let meta_client = self - .coord - .tenant_meta(session.tenant()) - .await - .ok_or_else(|| MetaError::TenantNotFound { - tenant: session.tenant().to_string(), - }) - .context(MetaSnafu)?; - - Ok(meta_client) - } - - fn build_table_handle_provider(&self, meta_client: MetaClientRef) -> QueryResult { - let current_session_table_provider: Arc = Arc::new(BaseTableProvider::new( - self.coord.clone(), - self.split_manager.clone(), - meta_client, - self.stream_provider_manager.clone(), - )); + fn build_table_handle_provider(&self) -> QueryResult { + let current_session_table_provider: Arc = Arc::new(BaseTableProvider::default()); Ok(current_session_table_provider) } } +pub struct TrackedRecordBatchStream { + inner: SendableRecordBatchStream, +} + +impl RecordBatchStream for TrackedRecordBatchStream { + fn schema(&self) -> SchemaRef { + self.inner.schema() + } +} + +impl Stream for TrackedRecordBatchStream { + type Item = DFResult; + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + self.inner.poll_next_unpin(cx) + } +} + #[derive(Default, Clone)] pub struct SimpleQueryDispatcherBuilder { - coord: Option, + input: Option, default_table_provider: Option, - split_manager: Option, session_factory: Option>, parser: Option>, query_execution_factory: Option, - query_tracker: Option>, - memory_pool: Option, // memory func_manager: Option, - stream_provider_manager: Option, - span_ctx: Option, - auth_cache: Option>>, } impl SimpleQueryDispatcherBuilder { - pub fn with_coord(mut self, coord: CoordinatorRef) -> Self { - self.coord = Some(coord); + pub fn with_input(mut self, input: SelectObjectContentInput) -> Self { + self.input = Some(input); self } - pub fn with_default_table_provider(mut self, default_table_provider: TableHandleProviderRef) -> Self { self.default_table_provider = Some(default_table_provider); self @@ -210,11 +222,6 @@ impl SimpleQueryDispatcherBuilder { self } - pub fn with_split_manager(mut self, split_manager: SplitManagerRef) -> Self { - self.split_manager = Some(split_manager); - self - } - pub fn with_parser(mut self, parser: Arc) -> Self { self.parser = Some(parser); self @@ -225,43 +232,14 @@ impl SimpleQueryDispatcherBuilder { self } - pub fn with_query_tracker(mut self, query_tracker: Arc) -> Self { - self.query_tracker = Some(query_tracker); - self - } - - pub fn with_memory_pool(mut self, memory_pool: MemoryPoolRef) -> Self { - self.memory_pool = Some(memory_pool); - self - } - pub fn with_func_manager(mut self, func_manager: FuncMetaManagerRef) -> Self { self.func_manager = Some(func_manager); self } - pub fn with_stream_provider_manager(mut self, stream_provider_manager: StreamProviderManagerRef) -> Self { - self.stream_provider_manager = Some(stream_provider_manager); - self - } - - pub fn with_span_ctx(mut self, span_ctx: Option) -> Self { - self.span_ctx = span_ctx; - self - } - - pub fn with_auth_cache(mut self, auth_cache: Arc>) -> Self { - self.auth_cache = Some(auth_cache); - self - } - pub fn build(self) -> QueryResult> { - let coord = self.coord.ok_or_else(|| QueryError::BuildQueryDispatcher { - err: "lost of coord".to_string(), - })?; - - let split_manager = self.split_manager.ok_or_else(|| QueryError::BuildQueryDispatcher { - err: "lost of split manager".to_string(), + let input = self.input.ok_or_else(|| QueryError::BuildQueryDispatcher { + err: "lost of input".to_string(), })?; let session_factory = self.session_factory.ok_or_else(|| QueryError::BuildQueryDispatcher { @@ -276,56 +254,23 @@ impl SimpleQueryDispatcherBuilder { err: "lost of query_execution_factory".to_string(), })?; - let query_tracker = self.query_tracker.ok_or_else(|| QueryError::BuildQueryDispatcher { - err: "lost of query_tracker".to_string(), - })?; - let func_manager = self.func_manager.ok_or_else(|| QueryError::BuildQueryDispatcher { err: "lost of func_manager".to_string(), })?; - let stream_provider_manager = self.stream_provider_manager.ok_or_else(|| QueryError::BuildQueryDispatcher { - err: "lost of stream_provider_manager".to_string(), - })?; - - let memory_pool = self.memory_pool.ok_or_else(|| QueryError::BuildQueryDispatcher { - err: "lost of memory pool".to_string(), - })?; - let default_table_provider = self.default_table_provider.ok_or_else(|| QueryError::BuildQueryDispatcher { err: "lost of default_table_provider".to_string(), })?; - let span_ctx = self.span_ctx; - - let auth_cache = self.auth_cache.ok_or_else(|| QueryError::BuildQueryDispatcher { - err: "lost of auth_cache".to_string(), - })?; - let dispatcher = Arc::new(SimpleQueryDispatcher { - coord, + input, default_table_provider, - split_manager, session_factory, - memory_pool, parser, query_execution_factory, - query_tracker, func_manager, - stream_provider_manager, - span_ctx, - async_task_joinhandle: Arc::new(Mutex::new(HashMap::new())), - failed_task_joinhandle: Arc::new(Mutex::new(HashMap::new())), - auth_cache, }); - let meta_task_receiver = dispatcher - .coord - .meta_manager() - .take_resourceinfo_rx() - .expect("meta resource channel only has one consumer"); - tokio::spawn(SimpleQueryDispatcher::recv_meta_modify(dispatcher.clone(), meta_task_receiver)); - Ok(dispatcher) } } diff --git a/s3select/query/src/execution/factory.rs b/s3select/query/src/execution/factory.rs index f6352eafb..9960d68a3 100644 --- a/s3select/query/src/execution/factory.rs +++ b/s3select/query/src/execution/factory.rs @@ -1,42 +1,29 @@ use std::sync::Arc; -use api::query::execution::QueryExecutionFactory; +use api::{ + query::{ + execution::{QueryExecutionFactory, QueryExecutionRef, QueryStateMachineRef}, + logical_planner::Plan, + optimizer::Optimizer, + scheduler::SchedulerRef, + }, + QueryError, +}; +use async_trait::async_trait; + +use super::query::SqlQueryExecution; pub type QueryExecutionFactoryRef = Arc; pub struct SqlQueryExecutionFactory { optimizer: Arc, scheduler: SchedulerRef, - query_tracker: Arc, - trigger_executor_factory: TriggerExecutorFactoryRef, - runtime: Arc, - stream_checker_manager: StreamCheckerManagerRef, } impl SqlQueryExecutionFactory { #[inline(always)] - pub fn new( - optimizer: Arc, - scheduler: SchedulerRef, - query_tracker: Arc, - stream_checker_manager: StreamCheckerManagerRef, - config: Arc, - ) -> Self { - // Only do periodic scheduling, no need for many threads - let trigger_executor_runtime = DedicatedExecutor::new("stream-trigger", config.stream_trigger_cpu); - let trigger_executor_factory = Arc::new(TriggerExecutorFactory::new(Arc::new(trigger_executor_runtime))); - - // perform stream-related preparations, not actual operator execution - let runtime = Arc::new(DedicatedExecutor::new("stream-executor", config.stream_executor_cpu)); - - Self { - optimizer, - scheduler, - query_tracker, - trigger_executor_factory, - runtime, - stream_checker_manager, - } + pub fn new(optimizer: Arc, scheduler: SchedulerRef) -> Self { + Self { optimizer, scheduler } } } @@ -48,62 +35,12 @@ impl QueryExecutionFactory for SqlQueryExecutionFactory { state_machine: QueryStateMachineRef, ) -> Result { match plan { - Plan::Query(query_plan) => { - // 获取执行计划中所有涉及到的stream source - let stream_providers = extract_stream_providers(&query_plan); - - // (含有流表, explain, dml) - match (!stream_providers.is_empty(), query_plan.is_explain(), is_dml(&query_plan)) { - (false, _, _) | (true, true, _) => Ok(Arc::new(SqlQueryExecution::new( - state_machine, - query_plan, - self.optimizer.clone(), - self.scheduler.clone(), - ))), - (true, false, true) => { - // 流操作 - // stream source + dml + !explain - let options = state_machine.session.inner().config().into(); - let exec = MicroBatchStreamExecutionBuilder::new(MicroBatchStreamExecutionDesc { - plan: Arc::new(query_plan), - options, - }) - .with_stream_providers(stream_providers) - .build( - state_machine, - self.scheduler.clone(), - self.trigger_executor_factory.clone(), - self.runtime.clone(), - ) - .await?; - - Ok(Arc::new(exec)) - } - (true, false, false) => { - // stream source + !dml + !explain - Err(QueryError::NotImplemented { - err: "Stream table can only be used as source table in insert select statements.".to_string(), - }) - } - } - } - Plan::DDL(ddl_plan) => Ok(Arc::new(DDLExecution::new(state_machine, self.stream_checker_manager.clone(), ddl_plan))), - Plan::DML(dml_plan) => Ok(Arc::new(DMLExecution::new(state_machine, dml_plan))), - Plan::SYSTEM(sys_plan) => Ok(Arc::new(SystemExecution::new(state_machine, sys_plan, self.query_tracker.clone()))), + Plan::Query(query_plan) => Ok(Arc::new(SqlQueryExecution::new( + state_machine, + query_plan, + self.optimizer.clone(), + self.scheduler.clone(), + ))), } } } - -fn is_dml(query_plan: &QueryPlan) -> bool { - match &query_plan.df_plan { - LogicalPlan::Dml(_) => true, - LogicalPlan::Extension(Extension { node }) => downcast_plan_node::(node.as_ref()).is_some(), - _ => false, - } -} - -impl Drop for SqlQueryExecutionFactory { - fn drop(&mut self) { - self.runtime.shutdown(); - } -} diff --git a/s3select/query/src/execution/mod.rs b/s3select/query/src/execution/mod.rs index a106d20ea..807faf3ea 100644 --- a/s3select/query/src/execution/mod.rs +++ b/s3select/query/src/execution/mod.rs @@ -1 +1,3 @@ pub mod factory; +pub mod query; +pub mod scheduler; diff --git a/s3select/query/src/execution/query.rs b/s3select/query/src/execution/query.rs new file mode 100644 index 000000000..15d6ef837 --- /dev/null +++ b/s3select/query/src/execution/query.rs @@ -0,0 +1,92 @@ +use std::sync::Arc; + +use api::query::execution::{Output, QueryExecution, QueryStateMachineRef}; +use api::query::logical_planner::QueryPlan; +use api::query::optimizer::Optimizer; +use api::query::scheduler::SchedulerRef; +use api::{QueryError, QueryResult}; +use async_trait::async_trait; +use futures::stream::AbortHandle; +use parking_lot::Mutex; +use tracing::debug; + +pub struct SqlQueryExecution { + query_state_machine: QueryStateMachineRef, + plan: QueryPlan, + optimizer: Arc, + scheduler: SchedulerRef, + + abort_handle: Mutex>, +} + +impl SqlQueryExecution { + pub fn new( + query_state_machine: QueryStateMachineRef, + plan: QueryPlan, + optimizer: Arc, + scheduler: SchedulerRef, + ) -> Self { + Self { + query_state_machine, + plan, + optimizer, + scheduler, + abort_handle: Mutex::new(None), + } + } + + async fn start(&self) -> QueryResult { + // begin optimize + self.query_state_machine.begin_optimize(); + let physical_plan = self.optimizer.optimize(&self.plan, &self.query_state_machine.session).await?; + self.query_state_machine.end_optimize(); + + // begin schedule + self.query_state_machine.begin_schedule(); + let stream = self + .scheduler + .schedule(physical_plan.clone(), self.query_state_machine.session.inner().task_ctx()) + .await? + .stream(); + + debug!("Success build result stream."); + self.query_state_machine.end_schedule(); + + Ok(Output::StreamData(stream)) + } +} + +#[async_trait] +impl QueryExecution for SqlQueryExecution { + async fn start(&self) -> QueryResult { + let (task, abort_handle) = futures::future::abortable(self.start()); + + { + *self.abort_handle.lock() = Some(abort_handle); + } + + task.await.map_err(|_| QueryError::Cancel)? + } + + fn cancel(&self) -> QueryResult<()> { + debug!( + "cancel sql query execution: sql: {}, state: {:?}", + self.query_state_machine.query.content(), + self.query_state_machine.state() + ); + + // change state + self.query_state_machine.cancel(); + // stop future task + if let Some(e) = self.abort_handle.lock().as_ref() { + e.abort() + }; + + debug!( + "canceled sql query execution: sql: {}, state: {:?}", + self.query_state_machine.query.content(), + self.query_state_machine.state() + ); + Ok(()) + } +} diff --git a/s3select/query/src/execution/scheduler/local.rs b/s3select/query/src/execution/scheduler/local.rs new file mode 100644 index 000000000..e105d4b93 --- /dev/null +++ b/s3select/query/src/execution/scheduler/local.rs @@ -0,0 +1,22 @@ +use std::sync::Arc; + +use api::query::scheduler::{ExecutionResults, Scheduler}; +use async_trait::async_trait; +use datafusion::error::DataFusionError; +use datafusion::execution::context::TaskContext; +use datafusion::physical_plan::{execute_stream, ExecutionPlan}; + +pub struct LocalScheduler {} + +#[async_trait] +impl Scheduler for LocalScheduler { + async fn schedule( + &self, + plan: Arc, + context: Arc, + ) -> Result { + let stream = execute_stream(plan, context)?; + + Ok(ExecutionResults::new(stream)) + } +} diff --git a/s3select/query/src/execution/scheduler/mod.rs b/s3select/query/src/execution/scheduler/mod.rs new file mode 100644 index 000000000..27099624c --- /dev/null +++ b/s3select/query/src/execution/scheduler/mod.rs @@ -0,0 +1 @@ +pub mod local; diff --git a/s3select/query/src/instance.rs b/s3select/query/src/instance.rs index e27eea21e..781a88f60 100644 --- a/s3select/query/src/instance.rs +++ b/s3select/query/src/instance.rs @@ -1,12 +1,22 @@ use std::sync::Arc; use api::{ - query::{dispatcher::QueryDispatcher, execution::QueryStateMachineRef, logical_planner::Plan, Query}, + query::{ + dispatcher::QueryDispatcher, execution::QueryStateMachineRef, logical_planner::Plan, session::SessionCtxFactory, Query, + }, server::dbms::{DatabaseManagerSystem, QueryHandle}, QueryResult, }; use async_trait::async_trait; use derive_builder::Builder; +use s3s::dto::SelectObjectContentInput; + +use crate::{ + dispatcher::manager::SimpleQueryDispatcherBuilder, + execution::{factory::SqlQueryExecutionFactory, scheduler::local::LocalScheduler}, + metadata::base_table::BaseTableProvider, + sql::{optimizer::CascadeOptimizerBuilder, parser::DefaultParser}, +}; #[derive(Builder)] pub struct RustFSms { @@ -19,10 +29,6 @@ impl DatabaseManagerSystem for RustFSms where D: QueryDispatcher, { - async fn start(&self) -> QueryResult<()> { - self.query_dispatcher.start().await - } - async fn execute(&self, query: &Query) -> QueryResult { let result = self.query_dispatcher.execute_query(query).await?; @@ -54,15 +60,31 @@ where Ok(QueryHandle::new(query.clone(), result)) } - - fn metrics(&self) -> String { - let infos = self.query_dispatcher.running_query_infos(); - let status = self.query_dispatcher.running_query_status(); - - format!( - "infos: {}\nstatus: {}\n", - infos.iter().map(|e| format!("{:?}", e)).collect::>().join(","), - status.iter().map(|e| format!("{:?}", e)).collect::>().join(",") - ) - } +} + +pub async fn make_cnosdbms(input: SelectObjectContentInput) -> QueryResult { + // TODO session config need load global system config + let session_factory = Arc::new(SessionCtxFactory {}); + let parser = Arc::new(DefaultParser::default()); + let optimizer = Arc::new(CascadeOptimizerBuilder::default().build()); + // TODO wrap, and num_threads configurable + let scheduler = Arc::new(LocalScheduler {}); + + let query_execution_factory = Arc::new(SqlQueryExecutionFactory::new(optimizer, scheduler)); + + let default_table_provider = Arc::new(BaseTableProvider::default()); + + let query_dispatcher = SimpleQueryDispatcherBuilder::default() + .with_input(input) + .with_default_table_provider(default_table_provider) + .with_session_factory(session_factory) + .with_parser(parser) + .with_query_execution_factory(query_execution_factory) + .build()?; + + let mut builder = RustFSmsBuilder::default(); + + let db_server = builder.query_dispatcher(query_dispatcher).build().expect("build db server"); + + Ok(db_server) } diff --git a/s3select/query/src/metadata/base_table.rs b/s3select/query/src/metadata/base_table.rs index 2a5180882..4796678b9 100644 --- a/s3select/query/src/metadata/base_table.rs +++ b/s3select/query/src/metadata/base_table.rs @@ -1,63 +1,17 @@ use std::sync::Arc; use datafusion::common::Result as DFResult; -use datafusion::config::{CsvOptions, JsonOptions}; -use datafusion::datasource::file_format::csv::CsvFormat; -use datafusion::datasource::file_format::json::JsonFormat; -use datafusion::datasource::file_format::parquet::ParquetFormat; -use datafusion::datasource::listing::{ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl}; -use datafusion::error::DataFusionError; -use datafusion::execution::SessionState; +use datafusion::datasource::listing::ListingTable; use crate::data_source::data_source::TableHandle; use super::TableHandleProvider; -pub enum FileType { - Csv, - Parquet, - Json, - Unknown, -} - #[derive(Default)] -pub struct BaseTableProvider { - file_type: FileType, -} - -impl BaseTableProvider { - pub fn new(file_type: FileType) -> Self { - Self { file_type } - } -} +pub struct BaseTableProvider {} impl TableHandleProvider for BaseTableProvider { - async fn build_table_handle(&self, session_state: &SessionState, table_name: &str) -> DFResult { - let table_path = ListingTableUrl::parse(table_name)?; - let listing_options = match self.file_type { - FileType::Csv => { - let file_format = CsvFormat::default().with_options(CsvOptions::default().with_has_header(false)); - ListingOptions::new(Arc::new(file_format)).with_file_extension(".csv") - } - FileType::Parquet => { - let file_format = ParquetFormat::new(); - ListingOptions::new(Arc::new(file_format)).with_file_extension(".parquet") - } - FileType::Json => { - let file_format = JsonFormat::default(); - ListingOptions::new(Arc::new(file_format)).with_file_extension(".json") - } - FileType::Unknown => { - return Err(DataFusionError::NotImplemented("not support this file type".to_string())); - } - }; - - let resolve_schema = listing_options.infer_schema(session_state, &table_path).await?; - let config = ListingTableConfig::new(table_path) - .with_listing_options(listing_options) - .with_schema(resolve_schema); - let provider = Arc::new(ListingTable::try_new(config)?); - + fn build_table_handle(&self, provider: Arc) -> DFResult { Ok(TableHandle::External(provider)) } } diff --git a/s3select/query/src/metadata/mod.rs b/s3select/query/src/metadata/mod.rs index 5f60298a2..e592460ef 100644 --- a/s3select/query/src/metadata/mod.rs +++ b/s3select/query/src/metadata/mod.rs @@ -5,10 +5,12 @@ use api::ResolvedTable; use async_trait::async_trait; use datafusion::arrow::datatypes::DataType; use datafusion::common::Result as DFResult; +use datafusion::datasource::listing::ListingTable; use datafusion::error::DataFusionError; use datafusion::execution::SessionState; use datafusion::logical_expr::var_provider::is_system_variables; use datafusion::logical_expr::{AggregateUDF, ScalarUDF, TableSource, WindowUDF}; +use datafusion::sql::ResolvedTableReference; use datafusion::variable::VarType; use datafusion::{ config::ConfigOptions, @@ -21,16 +23,17 @@ pub mod base_table; #[async_trait] pub trait ContextProviderExtension: ContextProvider { - fn get_table_source(&self, name: TableReference) -> datafusion::common::Result>; + fn get_table_source_(&self, name: TableReference) -> datafusion::common::Result>; } pub type TableHandleProviderRef = Arc; pub trait TableHandleProvider { - fn build_table_handle(&self, session_state: &SessionState, table_name: &str) -> DFResult; + fn build_table_handle(&self, provider: Arc) -> DFResult; } pub struct MetadataProvider { + provider: Arc, session: SessionCtx, config_options: ConfigOptions, func_manager: FuncMetaManagerRef, @@ -40,11 +43,13 @@ pub struct MetadataProvider { impl MetadataProvider { #[allow(clippy::too_many_arguments)] pub fn new( + provider: Arc, current_session_table_provider: TableHandleProviderRef, func_manager: FuncMetaManagerRef, session: SessionCtx, ) -> Self { Self { + provider, current_session_table_provider, config_options: session.inner().config_options().clone(), session, @@ -52,43 +57,22 @@ impl MetadataProvider { } } - fn build_table_handle(&self, name: &ResolvedTable) -> datafusion::common::Result { - let table_name = name.table(); - - self.current_session_table_provider.build_table_handle(table_name) + fn build_table_handle(&self) -> datafusion::common::Result { + self.current_session_table_provider + .build_table_handle(self.provider.clone()) } + + async fn init(&self) {} } -#[async_trait::async_trait] impl ContextProviderExtension for MetadataProvider { - fn get_table_source(&self, table_ref: TableReference) -> datafusion::common::Result> { - let name = table_ref - .clone() - .resolve_object(self.session.tenant(), self.session.default_database())?; + fn get_table_source_(&self, table_ref: TableReference) -> datafusion::common::Result> { + let name = table_ref.clone().resolve("", ""); + let table_name = &*name.table; - let table_name = name.table(); - let database_name = name.database(); - let tenant_name = name.tenant(); + let table_handle = self.build_table_handle()?; - // Cannot query across tenants - if self.session.tenant() != tenant_name { - return Err(DataFusionError::Plan(format!( - "Tenant conflict, the current connection's tenant is {}", - self.session.tenant() - ))); - } - - // save access table - self.access_databases.write().push_table(database_name, table_name); - - let table_handle = self.build_table_handle(&name)?; - - Ok(Arc::new(TableSourceAdapter::try_new( - table_ref.to_owned_reference(), - database_name, - table_name, - table_handle, - )?)) + Ok(Arc::new(TableSourceAdapter::try_new(table_ref.clone(), table_name, table_handle)?)) } } @@ -132,7 +116,7 @@ impl ContextProvider for MetadataProvider { } fn get_table_source(&self, name: TableReference) -> DFResult> { - Ok(self.get_table_source(name)?) + Ok(self.get_table_source_(name)?) } fn udf_names(&self) -> Vec { diff --git a/s3select/query/src/sql/analyzer.rs b/s3select/query/src/sql/analyzer.rs new file mode 100644 index 000000000..6507c8423 --- /dev/null +++ b/s3select/query/src/sql/analyzer.rs @@ -0,0 +1,33 @@ +use api::query::analyzer::Analyzer; +use api::query::session::SessionCtx; +use api::QueryResult; +use datafusion::logical_expr::LogicalPlan; +use datafusion::optimizer::analyzer::Analyzer as DFAnalyzer; + +pub struct DefaultAnalyzer { + inner: DFAnalyzer, +} + +impl DefaultAnalyzer { + pub fn new() -> Self { + let analyzer = DFAnalyzer::default(); + // we can add analyzer rule at here + + Self { inner: analyzer } + } +} + +impl Default for DefaultAnalyzer { + fn default() -> Self { + Self::new() + } +} + +impl Analyzer for DefaultAnalyzer { + fn analyze(&self, plan: &LogicalPlan, session: &SessionCtx) -> QueryResult { + let plan = self + .inner + .execute_and_check(plan.to_owned(), session.inner().config_options(), |_, _| {})?; + Ok(plan) + } +} diff --git a/s3select/query/src/sql/dialect.rs b/s3select/query/src/sql/dialect.rs new file mode 100644 index 000000000..332970938 --- /dev/null +++ b/s3select/query/src/sql/dialect.rs @@ -0,0 +1,18 @@ +use datafusion::sql::sqlparser::dialect::Dialect; + +#[derive(Debug, Default)] +pub struct RustFsDialect; + +impl Dialect for RustFsDialect { + fn is_identifier_start(&self, ch: char) -> bool { + ch.is_alphabetic() || ch == '_' || ch == '#' || ch == '@' + } + + fn is_identifier_part(&self, ch: char) -> bool { + ch.is_alphabetic() || ch.is_ascii_digit() || ch == '@' || ch == '$' || ch == '#' || ch == '_' + } + + fn supports_group_by_expr(&self) -> bool { + true + } +} diff --git a/s3select/query/src/sql/logical/mod.rs b/s3select/query/src/sql/logical/mod.rs index 5e480858b..1ecfae43a 100644 --- a/s3select/query/src/sql/logical/mod.rs +++ b/s3select/query/src/sql/logical/mod.rs @@ -1 +1,2 @@ +pub mod optimizer; pub mod planner; diff --git a/s3select/query/src/sql/logical/optimizer.rs b/s3select/query/src/sql/logical/optimizer.rs new file mode 100644 index 000000000..375667ca9 --- /dev/null +++ b/s3select/query/src/sql/logical/optimizer.rs @@ -0,0 +1,115 @@ +use std::sync::Arc; + +use api::{ + query::{analyzer::AnalyzerRef, logical_planner::QueryPlan, session::SessionCtx}, + QueryResult, +}; +use datafusion::{ + execution::SessionStateBuilder, + logical_expr::LogicalPlan, + optimizer::{ + common_subexpr_eliminate::CommonSubexprEliminate, decorrelate_predicate_subquery::DecorrelatePredicateSubquery, + eliminate_cross_join::EliminateCrossJoin, eliminate_duplicated_expr::EliminateDuplicatedExpr, + eliminate_filter::EliminateFilter, eliminate_join::EliminateJoin, eliminate_limit::EliminateLimit, + eliminate_outer_join::EliminateOuterJoin, extract_equijoin_predicate::ExtractEquijoinPredicate, + filter_null_join_keys::FilterNullJoinKeys, propagate_empty_relation::PropagateEmptyRelation, + push_down_filter::PushDownFilter, push_down_limit::PushDownLimit, + replace_distinct_aggregate::ReplaceDistinctWithAggregate, scalar_subquery_to_join::ScalarSubqueryToJoin, + simplify_expressions::SimplifyExpressions, single_distinct_to_groupby::SingleDistinctToGroupBy, + unwrap_cast_in_comparison::UnwrapCastInComparison, OptimizerRule, + }, +}; +use tracing::debug; + +use crate::sql::analyzer::DefaultAnalyzer; + +const PUSH_DOWN_PROJECTION_INDEX: usize = 24; + +pub trait LogicalOptimizer: Send + Sync { + fn optimize(&self, plan: &QueryPlan, session: &SessionCtx) -> QueryResult; + + fn inject_optimizer_rule(&mut self, optimizer_rule: Arc); +} + +pub struct DefaultLogicalOptimizer { + // fit datafusion + // TODO refactor + analyzer: AnalyzerRef, + rules: Vec>, +} + +impl DefaultLogicalOptimizer { + #[allow(dead_code)] + fn with_optimizer_rules(mut self, rules: Vec>) -> Self { + self.rules = rules; + self + } +} + +impl Default for DefaultLogicalOptimizer { + fn default() -> Self { + let analyzer = Arc::new(DefaultAnalyzer::default()); + + // additional optimizer rule + let rules: Vec> = vec![ + // df default rules start + Arc::new(SimplifyExpressions::new()), + Arc::new(UnwrapCastInComparison::new()), + Arc::new(ReplaceDistinctWithAggregate::new()), + Arc::new(EliminateJoin::new()), + Arc::new(DecorrelatePredicateSubquery::new()), + Arc::new(ScalarSubqueryToJoin::new()), + Arc::new(ExtractEquijoinPredicate::new()), + // simplify expressions does not simplify expressions in subqueries, so we + // run it again after running the optimizations that potentially converted + // subqueries to joins + Arc::new(SimplifyExpressions::new()), + Arc::new(EliminateDuplicatedExpr::new()), + Arc::new(EliminateFilter::new()), + Arc::new(EliminateCrossJoin::new()), + Arc::new(CommonSubexprEliminate::new()), + Arc::new(EliminateLimit::new()), + Arc::new(PropagateEmptyRelation::new()), + Arc::new(FilterNullJoinKeys::default()), + Arc::new(EliminateOuterJoin::new()), + // Filters can't be pushed down past Limits, we should do PushDownFilter after PushDownLimit + Arc::new(PushDownLimit::new()), + Arc::new(PushDownFilter::new()), + Arc::new(SingleDistinctToGroupBy::new()), + // The previous optimizations added expressions and projections, + // that might benefit from the following rules + Arc::new(SimplifyExpressions::new()), + Arc::new(UnwrapCastInComparison::new()), + Arc::new(CommonSubexprEliminate::new()), + // PushDownProjection can pushdown Projections through Limits, do PushDownLimit again. + Arc::new(PushDownLimit::new()), + // df default rules end + // custom rules can add at here + ]; + + Self { analyzer, rules } + } +} + +impl LogicalOptimizer for DefaultLogicalOptimizer { + fn optimize(&self, plan: &QueryPlan, session: &SessionCtx) -> QueryResult { + let analyzed_plan = { self.analyzer.analyze(&plan.df_plan, session).map(|p| p).map_err(|e| e)? }; + + debug!("Analyzed logical plan:\n{}\n", plan.df_plan.display_indent_schema(),); + + let optimizeed_plan = { + SessionStateBuilder::new_from_existing(session.inner().clone()) + .with_optimizer_rules(self.rules.clone()) + .build() + .optimize(&analyzed_plan) + .map(|p| p) + .map_err(|e| e)? + }; + + Ok(optimizeed_plan) + } + + fn inject_optimizer_rule(&mut self, optimizer_rule: Arc) { + self.rules.push(optimizer_rule); + } +} diff --git a/s3select/query/src/sql/mod.rs b/s3select/query/src/sql/mod.rs index 74b97905f..151fc83de 100644 --- a/s3select/query/src/sql/mod.rs +++ b/s3select/query/src/sql/mod.rs @@ -1,3 +1,7 @@ +pub mod analyzer; +pub mod dialect; pub mod logical; +pub mod optimizer; +pub mod parser; pub mod physical; pub mod planner; diff --git a/s3select/query/src/sql/optimizer.rs b/s3select/query/src/sql/optimizer.rs new file mode 100644 index 000000000..2b546547e --- /dev/null +++ b/s3select/query/src/sql/optimizer.rs @@ -0,0 +1,89 @@ +use std::sync::Arc; + +use api::{ + query::{logical_planner::QueryPlan, optimizer::Optimizer, physical_planner::PhysicalPlanner, session::SessionCtx}, + QueryResult, +}; +use async_trait::async_trait; +use datafusion::physical_plan::{displayable, ExecutionPlan}; +use tracing::debug; + +use super::{ + logical::optimizer::{DefaultLogicalOptimizer, LogicalOptimizer}, + physical::{optimizer::PhysicalOptimizer, planner::DefaultPhysicalPlanner}, +}; + +pub struct CascadeOptimizer { + logical_optimizer: Arc, + physical_planner: Arc, + physical_optimizer: Arc, +} + +#[async_trait] +impl Optimizer for CascadeOptimizer { + async fn optimize(&self, plan: &QueryPlan, session: &SessionCtx) -> QueryResult> { + debug!("Original logical plan:\n{}\n", plan.df_plan.display_indent_schema(),); + + let optimized_logical_plan = self.logical_optimizer.optimize(plan, session)?; + + debug!("Final logical plan:\n{}\n", optimized_logical_plan.display_indent_schema(),); + + let physical_plan = { + self.physical_planner + .create_physical_plan(&optimized_logical_plan, session) + .await + .map(|p| p) + .map_err(|err| err)? + }; + + debug!("Original physical plan:\n{}\n", displayable(physical_plan.as_ref()).indent(false)); + + let optimized_physical_plan = { + self.physical_optimizer + .optimize(physical_plan, session) + .map(|p| p) + .map_err(|err| err)? + }; + + Ok(optimized_physical_plan) + } +} + +#[derive(Default)] +pub struct CascadeOptimizerBuilder { + logical_optimizer: Option>, + physical_planner: Option>, + physical_optimizer: Option>, +} + +impl CascadeOptimizerBuilder { + pub fn with_logical_optimizer(mut self, logical_optimizer: Arc) -> Self { + self.logical_optimizer = Some(logical_optimizer); + self + } + + pub fn with_physical_planner(mut self, physical_planner: Arc) -> Self { + self.physical_planner = Some(physical_planner); + self + } + + pub fn with_physical_optimizer(mut self, physical_optimizer: Arc) -> Self { + self.physical_optimizer = Some(physical_optimizer); + self + } + + pub fn build(self) -> CascadeOptimizer { + let default_logical_optimizer = Arc::new(DefaultLogicalOptimizer::default()); + let default_physical_planner = Arc::new(DefaultPhysicalPlanner::default()); + + let logical_optimizer = self.logical_optimizer.unwrap_or(default_logical_optimizer); + let physical_planner = self.physical_planner.unwrap_or_else(|| default_physical_planner.clone()); + let physical_optimizer = self.physical_optimizer.unwrap_or(default_physical_planner); + + CascadeOptimizer { + logical_optimizer, + physical_planner, + physical_optimizer, + } + } +} diff --git a/s3select/query/src/sql/parser.rs b/s3select/query/src/sql/parser.rs new file mode 100644 index 000000000..80f8d0db7 --- /dev/null +++ b/s3select/query/src/sql/parser.rs @@ -0,0 +1,97 @@ +use std::{collections::VecDeque, fmt::Display}; + +use api::{ + query::{ast::ExtStatement, parser::Parser as RustFsParser}, + ParserSnafu, +}; +use datafusion::sql::sqlparser::{ + dialect::Dialect, + parser::{Parser, ParserError}, + tokenizer::{Token, Tokenizer}, +}; +use snafu::ResultExt; + +use super::dialect::RustFsDialect; + +pub type Result = std::result::Result; + +// Use `Parser::expected` instead, if possible +macro_rules! parser_err { + ($MSG:expr) => { + Err(ParserError::ParserError($MSG.to_string())) + }; +} + +#[derive(Default)] +pub struct DefaultParser {} + +impl RustFsParser for DefaultParser { + fn parse(&self, sql: &str) -> api::QueryResult> { + ExtParser::parse_sql(sql).context(ParserSnafu) + } +} + +/// SQL Parser +pub struct ExtParser<'a> { + parser: Parser<'a>, +} + +impl<'a> ExtParser<'a> { + /// Parse the specified tokens with dialect + fn new_with_dialect(sql: &str, dialect: &'a dyn Dialect) -> Result { + let mut tokenizer = Tokenizer::new(dialect, sql); + let tokens = tokenizer.tokenize()?; + Ok(ExtParser { + parser: Parser::new(dialect).with_tokens(tokens), + }) + } + + /// Parse a SQL statement and produce a set of statements + pub fn parse_sql(sql: &str) -> Result> { + let dialect = &RustFsDialect {}; + ExtParser::parse_sql_with_dialect(sql, dialect) + } + + /// Parse a SQL statement and produce a set of statements + pub fn parse_sql_with_dialect(sql: &str, dialect: &dyn Dialect) -> Result> { + let mut parser = ExtParser::new_with_dialect(sql, dialect)?; + let mut stmts = VecDeque::new(); + let mut expecting_statement_delimiter = false; + loop { + // ignore empty statements (between successive statement delimiters) + while parser.parser.consume_token(&Token::SemiColon) { + expecting_statement_delimiter = false; + } + + if parser.parser.peek_token() == Token::EOF { + break; + } + if expecting_statement_delimiter { + return parser.expected("end of statement", parser.parser.peek_token()); + } + + let statement = parser.parse_statement()?; + stmts.push_back(statement); + expecting_statement_delimiter = true; + } + + // debug!("Parser sql: {}, stmts: {:#?}", sql, stmts); + + Ok(stmts) + } + + /// Parse a new expression + fn parse_statement(&mut self) -> Result { + match self.parser.peek_token().token { + Token::Word(w) => match w.keyword { + _ => Ok(ExtStatement::SqlStatement(Box::new(self.parser.parse_statement()?))), + }, + _ => Ok(ExtStatement::SqlStatement(Box::new(self.parser.parse_statement()?))), + } + } + + // Report unexpected token + fn expected(&self, expected: &str, found: impl Display) -> Result { + parser_err!(format!("Expected {}, found: {}", expected, found)) + } +} diff --git a/s3select/query/src/sql/physical/mod.rs b/s3select/query/src/sql/physical/mod.rs index 8b1378917..1ecfae43a 100644 --- a/s3select/query/src/sql/physical/mod.rs +++ b/s3select/query/src/sql/physical/mod.rs @@ -1 +1,2 @@ - +pub mod optimizer; +pub mod planner; diff --git a/s3select/query/src/sql/physical/optimizer.rs b/s3select/query/src/sql/physical/optimizer.rs new file mode 100644 index 000000000..12f16e3dc --- /dev/null +++ b/s3select/query/src/sql/physical/optimizer.rs @@ -0,0 +1,12 @@ +use std::sync::Arc; + +use api::query::session::SessionCtx; +use api::QueryResult; +use datafusion::physical_optimizer::PhysicalOptimizerRule; +use datafusion::physical_plan::ExecutionPlan; + +pub trait PhysicalOptimizer { + fn optimize(&self, plan: Arc, session: &SessionCtx) -> QueryResult>; + + fn inject_optimizer_rule(&mut self, optimizer_rule: Arc); +} diff --git a/s3select/query/src/sql/physical/planner.rs b/s3select/query/src/sql/physical/planner.rs new file mode 100644 index 000000000..254c198d6 --- /dev/null +++ b/s3select/query/src/sql/physical/planner.rs @@ -0,0 +1,104 @@ +use std::sync::Arc; + +use api::query::physical_planner::PhysicalPlanner; +use api::query::session::SessionCtx; +use api::QueryResult; +use async_trait::async_trait; +use datafusion::execution::SessionStateBuilder; +use datafusion::logical_expr::LogicalPlan; +use datafusion::physical_optimizer::aggregate_statistics::AggregateStatistics; +use datafusion::physical_optimizer::coalesce_batches::CoalesceBatches; +use datafusion::physical_optimizer::join_selection::JoinSelection; +use datafusion::physical_optimizer::PhysicalOptimizerRule; +use datafusion::physical_plan::ExecutionPlan; +use datafusion::physical_planner::{ + DefaultPhysicalPlanner as DFDefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner as DFPhysicalPlanner, +}; + +use super::optimizer::PhysicalOptimizer; + +pub struct DefaultPhysicalPlanner { + ext_physical_transform_rules: Vec>, + /// Responsible for optimizing a physical execution plan + ext_physical_optimizer_rules: Vec>, +} + +impl DefaultPhysicalPlanner { + #[allow(dead_code)] + fn with_physical_transform_rules(mut self, rules: Vec>) -> Self { + self.ext_physical_transform_rules = rules; + self + } +} + +impl DefaultPhysicalPlanner { + #[allow(dead_code)] + fn with_optimizer_rules(mut self, rules: Vec>) -> Self { + self.ext_physical_optimizer_rules = rules; + self + } +} + +impl Default for DefaultPhysicalPlanner { + fn default() -> Self { + let ext_physical_transform_rules: Vec> = vec![ + // can add rules at here + ]; + + // We need to take care of the rule ordering. They may influence each other. + let ext_physical_optimizer_rules: Vec> = vec![ + Arc::new(AggregateStatistics::new()), + // Statistics-based join selection will change the Auto mode to a real join implementation, + // like collect left, or hash join, or future sort merge join, which will influence the + // EnforceDistribution and EnforceSorting rules as they decide whether to add additional + // repartitioning and local sorting steps to meet distribution and ordering requirements. + // Therefore, it should run before EnforceDistribution and EnforceSorting. + Arc::new(JoinSelection::new()), + // The CoalesceBatches rule will not influence the distribution and ordering of the + // whole plan tree. Therefore, to avoid influencing other rules, it should run last. + Arc::new(CoalesceBatches::new()), + ]; + + Self { + ext_physical_transform_rules, + ext_physical_optimizer_rules, + } + } +} + +#[async_trait] +impl PhysicalPlanner for DefaultPhysicalPlanner { + async fn create_physical_plan( + &self, + logical_plan: &LogicalPlan, + session: &SessionCtx, + ) -> QueryResult> { + // 将扩展的物理计划优化规则注入df 的 session state + let new_state = SessionStateBuilder::new_from_existing(session.inner().clone()) + .with_physical_optimizer_rules(self.ext_physical_optimizer_rules.clone()) + .build(); + + // 通过扩展的物理计划转换规则构造df 的 Physical Planner + let planner = DFDefaultPhysicalPlanner::with_extension_planners(self.ext_physical_transform_rules.clone()); + + // 执行df的物理计划规划及优化 + planner + .create_physical_plan(logical_plan, &new_state) + .await + .map_err(|e| e.into()) + } + + fn inject_physical_transform_rule(&mut self, rule: Arc) { + self.ext_physical_transform_rules.push(rule) + } +} + +impl PhysicalOptimizer for DefaultPhysicalPlanner { + fn optimize(&self, plan: Arc, _session: &SessionCtx) -> QueryResult> { + Ok(plan) + } + + fn inject_optimizer_rule(&mut self, optimizer_rule: Arc) { + self.ext_physical_optimizer_rules.push(optimizer_rule); + } +} diff --git a/s3select/query/src/sql/planner.rs b/s3select/query/src/sql/planner.rs index 0d4688437..be6b314de 100644 --- a/s3select/query/src/sql/planner.rs +++ b/s3select/query/src/sql/planner.rs @@ -1,4 +1,14 @@ -use datafusion::sql::planner::SqlToRel; +use api::{ + query::{ + ast::ExtStatement, + logical_planner::{LogicalPlanner, Plan, QueryPlan}, + session::SessionCtx, + }, + QueryError, QueryResult, +}; +use async_recursion::async_recursion; +use async_trait::async_trait; +use datafusion::sql::{planner::SqlToRel, sqlparser::ast::Statement}; use crate::metadata::ContextProviderExtension; @@ -6,3 +16,45 @@ pub struct SqlPlanner<'a, S: ContextProviderExtension> { schema_provider: &'a S, df_planner: SqlToRel<'a, S>, } + +#[async_trait] +impl<'a, S: ContextProviderExtension + Send + Sync> LogicalPlanner for SqlPlanner<'a, S> { + async fn create_logical_plan(&self, statement: ExtStatement, session: &SessionCtx) -> QueryResult { + let plan = { self.statement_to_plan(statement, session).await.map_err(|err| err)? }; + + Ok(plan) + } +} + +impl<'a, S: ContextProviderExtension + Send + Sync + 'a> SqlPlanner<'a, S> { + /// Create a new query planner + pub fn new(schema_provider: &'a S) -> Self { + SqlPlanner { + schema_provider, + df_planner: SqlToRel::new(schema_provider), + } + } + + /// Generate a logical plan from an Extent SQL statement + #[async_recursion] + pub(crate) async fn statement_to_plan(&self, statement: ExtStatement, session: &SessionCtx) -> QueryResult { + match statement { + ExtStatement::SqlStatement(stmt) => self.df_sql_to_plan(*stmt, session).await, + } + } + + async fn df_sql_to_plan(&self, stmt: Statement, _session: &SessionCtx) -> QueryResult { + match stmt { + Statement::Query(_) => { + let df_plan = self.df_planner.sql_statement_to_plan(stmt)?; + let plan = Plan::Query(QueryPlan { + df_plan, + is_tag_scan: false, + }); + + Ok(plan) + } + _ => Err(QueryError::NotImplemented { err: stmt.to_string() }), + } + } +} From 83e2c8f69fa2c59543389ce12e209ef316a13539 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Fri, 14 Mar 2025 03:26:32 +0000 Subject: [PATCH 031/103] tmp3 Signed-off-by: junxiang Mu <1948535941@qq.com> --- ecstore/src/utils/os/linux.rs | 5 +- rustfs/src/storage/ecfs.rs | 17 ++--- s3select/api/src/lib.rs | 6 ++ s3select/api/src/object_store.rs | 2 +- s3select/query/src/data_source/mod.rs | 2 +- .../{data_source.rs => table_source.rs} | 0 s3select/query/src/dispatcher/manager.rs | 13 ++-- s3select/query/src/function/mod.rs | 1 + .../query/src/function/simple_func_manager.rs | 63 +++++++++++++++++++ s3select/query/src/instance.rs | 4 ++ s3select/query/src/lib.rs | 1 + s3select/query/src/metadata/base_table.rs | 2 +- s3select/query/src/metadata/mod.rs | 11 +--- s3select/query/src/sql/logical/optimizer.rs | 8 +-- s3select/query/src/sql/optimizer.rs | 8 +-- s3select/query/src/sql/parser.rs | 7 +-- s3select/query/src/sql/planner.rs | 8 +-- 17 files changed, 105 insertions(+), 53 deletions(-) rename s3select/query/src/data_source/{data_source.rs => table_source.rs} (100%) create mode 100644 s3select/query/src/function/mod.rs create mode 100644 s3select/query/src/function/simple_func_manager.rs diff --git a/ecstore/src/utils/os/linux.rs b/ecstore/src/utils/os/linux.rs index ca64f8186..064b74ae5 100644 --- a/ecstore/src/utils/os/linux.rs +++ b/ecstore/src/utils/os/linux.rs @@ -151,7 +151,7 @@ fn read_drive_stats(stats_file: &str) -> Result { fn read_stat(file_name: &str) -> Result> { // 打开文件 let path = Path::new(file_name); - let file = File::open(&path)?; + let file = File::open(path)?; // 创建一个 BufReader let reader = io::BufReader::new(file); @@ -161,7 +161,8 @@ fn read_stat(file_name: &str) -> Result> { if let Some(line) = reader.lines().next() { let line = line?; // 分割行并解析为 u64 - for token in line.trim().split_whitespace() { + // https://rust-lang.github.io/rust-clippy/master/index.html#trim_split_whitespace + for token in line.split_whitespace() { let ui64: u64 = token.parse()?; stats.push(ui64); } diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 65544be52..6a83beae5 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -6,9 +6,12 @@ use crate::auth::get_condition_values; use crate::storage::access::ReqInfo; use api::query::Context; use api::query::Query; +use api::server::dbms::DatabaseManagerSystem; use bytes::Bytes; use common::error::Result; +use datafusion::arrow::csv::WriterBuilder as CsvWriterBuilder; use datafusion::arrow::json::writer::JsonArray; +use datafusion::arrow::json::WriterBuilder as JsonWriterBuilder; use ecstore::bucket::error::BucketMetadataError; use ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG; use ecstore::bucket::metadata::BUCKET_NOTIFICATION_CONFIG; @@ -43,7 +46,6 @@ use futures::pin_mut; use futures::{Stream, StreamExt}; use http::HeaderMap; use iam::policy::action::Action; -use api::server::dbms::DatabaseManagerSystem; use iam::policy::action::S3Action; use lazy_static::lazy_static; use log::warn; @@ -61,10 +63,10 @@ use s3s::S3ErrorCode; use s3s::S3Result; use s3s::S3; use s3s::{S3Request, S3Response}; -use tokio::sync::mpsc; -use tokio_stream::wrappers::ReceiverStream; use std::fmt::Debug; use std::str::FromStr; +use tokio::sync::mpsc; +use tokio_stream::wrappers::ReceiverStream; use tokio_util::io::ReaderStream; use tokio_util::io::StreamReader; use tracing::debug; @@ -1878,13 +1880,12 @@ impl S3 for FS { let input = req.input; info!("{:?}", input); - let db = make_cnosdbms(input).await.map_err(|_| { - s3_error!(InternalError) - })?; - let query = Query::new(Context {input: input.clone()}, input.request.expression); - let result = db.execute(&query).await.map_err(|_| { + let db = make_cnosdbms(input.clone()).await.map_err(|e| { + error!("make db failed, {}", e.to_string()); s3_error!(InternalError) })?; + let query = Query::new(Context { input: input.clone() }, input.request.expression); + let result = db.execute(&query).await.map_err(|_| s3_error!(InternalError))?; let results = result.result().chunk_result().await.unwrap().to_vec(); diff --git a/s3select/api/src/lib.rs b/s3select/api/src/lib.rs index 9c61128b6..72a9e9c77 100644 --- a/s3select/api/src/lib.rs +++ b/s3select/api/src/lib.rs @@ -32,6 +32,12 @@ pub enum QueryError { #[snafu(display("{}", source))] Parser { source: ParserError }, + + #[snafu(display("Udf not exists, name:{}.", name))] + FunctionNotExists { name: String }, + + #[snafu(display("Udf already exists, name:{}.", name))] + FunctionExists { name: String }, } impl From for QueryError { diff --git a/s3select/api/src/object_store.rs b/s3select/api/src/object_store.rs index c10a26fa3..bb9273cdf 100644 --- a/s3select/api/src/object_store.rs +++ b/s3select/api/src/object_store.rs @@ -79,7 +79,7 @@ impl ObjectStore for EcObjectStore { let stream = stream::unfold(reader.stream, |mut blob| async move { match blob.next().await { Some(Ok(chunk)) => { - let bytes = Bytes::from(chunk); + let bytes = chunk; Some((Ok(bytes), blob)) } _ => None, diff --git a/s3select/query/src/data_source/mod.rs b/s3select/query/src/data_source/mod.rs index 5b53f15a4..b0704130e 100644 --- a/s3select/query/src/data_source/mod.rs +++ b/s3select/query/src/data_source/mod.rs @@ -1 +1 @@ -pub mod data_source; +pub mod table_source; diff --git a/s3select/query/src/data_source/data_source.rs b/s3select/query/src/data_source/table_source.rs similarity index 100% rename from s3select/query/src/data_source/data_source.rs rename to s3select/query/src/data_source/table_source.rs diff --git a/s3select/query/src/dispatcher/manager.rs b/s3select/query/src/dispatcher/manager.rs index effe17bf3..3975c4e50 100644 --- a/s3select/query/src/dispatcher/manager.rs +++ b/s3select/query/src/dispatcher/manager.rs @@ -1,7 +1,6 @@ use std::{ - collections::HashMap, pin::Pin, - sync::{Arc, Mutex}, + sync::Arc, task::{Context, Poll}, }; @@ -31,14 +30,10 @@ use datafusion::{ }; use futures::{Stream, StreamExt}; use s3s::dto::SelectObjectContentInput; -use tokio::task::JoinHandle; use crate::{ execution::factory::QueryExecutionFactoryRef, - metadata::{ - base_table::BaseTableProvider, - ContextProviderExtension, MetadataProvider, TableHandleProviderRef, - }, + metadata::{base_table::BaseTableProvider, ContextProviderExtension, MetadataProvider, TableHandleProviderRef}, sql::logical::planner::DefaultLogicalPlanner, }; @@ -46,7 +41,7 @@ use crate::{ pub struct SimpleQueryDispatcher { input: SelectObjectContentInput, // client for default tenant - default_table_provider: TableHandleProviderRef, + _default_table_provider: TableHandleProviderRef, session_factory: Arc, // parser parser: Arc, @@ -264,7 +259,7 @@ impl SimpleQueryDispatcherBuilder { let dispatcher = Arc::new(SimpleQueryDispatcher { input, - default_table_provider, + _default_table_provider: default_table_provider, session_factory, parser, query_execution_factory, diff --git a/s3select/query/src/function/mod.rs b/s3select/query/src/function/mod.rs new file mode 100644 index 000000000..e76614a0b --- /dev/null +++ b/s3select/query/src/function/mod.rs @@ -0,0 +1 @@ +pub mod simple_func_manager; diff --git a/s3select/query/src/function/simple_func_manager.rs b/s3select/query/src/function/simple_func_manager.rs new file mode 100644 index 000000000..129efacff --- /dev/null +++ b/s3select/query/src/function/simple_func_manager.rs @@ -0,0 +1,63 @@ +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; + +use api::query::function::FunctionMetadataManager; +use api::{QueryError, QueryResult}; +use datafusion::logical_expr::{AggregateUDF, ScalarUDF, WindowUDF}; + +pub type SimpleFunctionMetadataManagerRef = Arc; + +#[derive(Debug, Default)] +pub struct SimpleFunctionMetadataManager { + /// Scalar functions that are registered with the context + pub scalar_functions: HashMap>, + /// Aggregate functions registered in the context + pub aggregate_functions: HashMap>, + /// Window functions registered in the context + pub window_functions: HashMap>, +} + +impl FunctionMetadataManager for SimpleFunctionMetadataManager { + fn register_udf(&mut self, f: ScalarUDF) -> QueryResult<()> { + self.scalar_functions.insert(f.inner().name().to_uppercase(), Arc::new(f)); + Ok(()) + } + + fn register_udaf(&mut self, f: AggregateUDF) -> QueryResult<()> { + self.aggregate_functions.insert(f.inner().name().to_uppercase(), Arc::new(f)); + Ok(()) + } + + fn register_udwf(&mut self, f: WindowUDF) -> QueryResult<()> { + self.window_functions.insert(f.inner().name().to_uppercase(), Arc::new(f)); + Ok(()) + } + + fn udf(&self, name: &str) -> QueryResult> { + let result = self.scalar_functions.get(&name.to_uppercase()); + + result + .cloned() + .ok_or_else(|| QueryError::FunctionExists { name: name.to_string() }) + } + + fn udaf(&self, name: &str) -> QueryResult> { + let result = self.aggregate_functions.get(&name.to_uppercase()); + + result + .cloned() + .ok_or_else(|| QueryError::FunctionNotExists { name: name.to_string() }) + } + + fn udwf(&self, name: &str) -> QueryResult> { + let result = self.window_functions.get(&name.to_uppercase()); + + result + .cloned() + .ok_or_else(|| QueryError::FunctionNotExists { name: name.to_string() }) + } + + fn udfs(&self) -> HashSet { + self.scalar_functions.keys().cloned().collect() + } +} diff --git a/s3select/query/src/instance.rs b/s3select/query/src/instance.rs index 781a88f60..9f4b601b6 100644 --- a/s3select/query/src/instance.rs +++ b/s3select/query/src/instance.rs @@ -14,6 +14,7 @@ use s3s::dto::SelectObjectContentInput; use crate::{ dispatcher::manager::SimpleQueryDispatcherBuilder, execution::{factory::SqlQueryExecutionFactory, scheduler::local::LocalScheduler}, + function::simple_func_manager::SimpleFunctionMetadataManager, metadata::base_table::BaseTableProvider, sql::{optimizer::CascadeOptimizerBuilder, parser::DefaultParser}, }; @@ -63,6 +64,8 @@ where } pub async fn make_cnosdbms(input: SelectObjectContentInput) -> QueryResult { + // init Function Manager, we can define some UDF if need + let func_manager = SimpleFunctionMetadataManager::default(); // TODO session config need load global system config let session_factory = Arc::new(SessionCtxFactory {}); let parser = Arc::new(DefaultParser::default()); @@ -76,6 +79,7 @@ pub async fn make_cnosdbms(input: SelectObjectContentInput) -> QueryResult datafusion::common::Result { - self.current_session_table_provider - .build_table_handle(self.provider.clone()) + self.current_session_table_provider.build_table_handle(self.provider.clone()) } - - async fn init(&self) {} } impl ContextProviderExtension for MetadataProvider { diff --git a/s3select/query/src/sql/logical/optimizer.rs b/s3select/query/src/sql/logical/optimizer.rs index 375667ca9..e97e29674 100644 --- a/s3select/query/src/sql/logical/optimizer.rs +++ b/s3select/query/src/sql/logical/optimizer.rs @@ -23,8 +23,6 @@ use tracing::debug; use crate::sql::analyzer::DefaultAnalyzer; -const PUSH_DOWN_PROJECTION_INDEX: usize = 24; - pub trait LogicalOptimizer: Send + Sync { fn optimize(&self, plan: &QueryPlan, session: &SessionCtx) -> QueryResult; @@ -93,7 +91,7 @@ impl Default for DefaultLogicalOptimizer { impl LogicalOptimizer for DefaultLogicalOptimizer { fn optimize(&self, plan: &QueryPlan, session: &SessionCtx) -> QueryResult { - let analyzed_plan = { self.analyzer.analyze(&plan.df_plan, session).map(|p| p).map_err(|e| e)? }; + let analyzed_plan = { self.analyzer.analyze(&plan.df_plan, session)? }; debug!("Analyzed logical plan:\n{}\n", plan.df_plan.display_indent_schema(),); @@ -101,9 +99,7 @@ impl LogicalOptimizer for DefaultLogicalOptimizer { SessionStateBuilder::new_from_existing(session.inner().clone()) .with_optimizer_rules(self.rules.clone()) .build() - .optimize(&analyzed_plan) - .map(|p| p) - .map_err(|e| e)? + .optimize(&analyzed_plan)? }; Ok(optimizeed_plan) diff --git a/s3select/query/src/sql/optimizer.rs b/s3select/query/src/sql/optimizer.rs index 2b546547e..13da4eb39 100644 --- a/s3select/query/src/sql/optimizer.rs +++ b/s3select/query/src/sql/optimizer.rs @@ -31,18 +31,14 @@ impl Optimizer for CascadeOptimizer { let physical_plan = { self.physical_planner .create_physical_plan(&optimized_logical_plan, session) - .await - .map(|p| p) - .map_err(|err| err)? + .await? }; debug!("Original physical plan:\n{}\n", displayable(physical_plan.as_ref()).indent(false)); let optimized_physical_plan = { self.physical_optimizer - .optimize(physical_plan, session) - .map(|p| p) - .map_err(|err| err)? + .optimize(physical_plan, session)? }; Ok(optimized_physical_plan) diff --git a/s3select/query/src/sql/parser.rs b/s3select/query/src/sql/parser.rs index 80f8d0db7..ebd2b5d45 100644 --- a/s3select/query/src/sql/parser.rs +++ b/s3select/query/src/sql/parser.rs @@ -82,12 +82,7 @@ impl<'a> ExtParser<'a> { /// Parse a new expression fn parse_statement(&mut self) -> Result { - match self.parser.peek_token().token { - Token::Word(w) => match w.keyword { - _ => Ok(ExtStatement::SqlStatement(Box::new(self.parser.parse_statement()?))), - }, - _ => Ok(ExtStatement::SqlStatement(Box::new(self.parser.parse_statement()?))), - } + Ok(ExtStatement::SqlStatement(Box::new(self.parser.parse_statement()?))) } // Report unexpected token diff --git a/s3select/query/src/sql/planner.rs b/s3select/query/src/sql/planner.rs index be6b314de..a6c9f8c1a 100644 --- a/s3select/query/src/sql/planner.rs +++ b/s3select/query/src/sql/planner.rs @@ -13,14 +13,14 @@ use datafusion::sql::{planner::SqlToRel, sqlparser::ast::Statement}; use crate::metadata::ContextProviderExtension; pub struct SqlPlanner<'a, S: ContextProviderExtension> { - schema_provider: &'a S, + _schema_provider: &'a S, df_planner: SqlToRel<'a, S>, } #[async_trait] -impl<'a, S: ContextProviderExtension + Send + Sync> LogicalPlanner for SqlPlanner<'a, S> { +impl LogicalPlanner for SqlPlanner<'_, S> { async fn create_logical_plan(&self, statement: ExtStatement, session: &SessionCtx) -> QueryResult { - let plan = { self.statement_to_plan(statement, session).await.map_err(|err| err)? }; + let plan = { self.statement_to_plan(statement, session).await? }; Ok(plan) } @@ -30,7 +30,7 @@ impl<'a, S: ContextProviderExtension + Send + Sync + 'a> SqlPlanner<'a, S> { /// Create a new query planner pub fn new(schema_provider: &'a S) -> Self { SqlPlanner { - schema_provider, + _schema_provider: schema_provider, df_planner: SqlToRel::new(schema_provider), } } From 9d9bc150f6183bfc1d3cca44ef596814854b9d7e Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Fri, 14 Mar 2025 04:35:36 +0000 Subject: [PATCH 032/103] add test case Signed-off-by: junxiang Mu <1948535941@qq.com> --- .../generated/flatbuffers_generated/models.rs | 207 +- .../src/generated/proto_gen/node_service.rs | 3836 ++++------------- rustfs/src/storage/ecfs.rs | 2 +- s3select/api/src/lib.rs | 3 + s3select/api/src/query/session.rs | 47 +- s3select/query/src/dispatcher/manager.rs | 2 +- s3select/query/src/instance.rs | 74 +- s3select/query/src/sql/optimizer.rs | 5 +- 8 files changed, 1003 insertions(+), 3173 deletions(-) diff --git a/common/protos/src/generated/flatbuffers_generated/models.rs b/common/protos/src/generated/flatbuffers_generated/models.rs index aa1f6ae2f..e4949fdcf 100644 --- a/common/protos/src/generated/flatbuffers_generated/models.rs +++ b/common/protos/src/generated/flatbuffers_generated/models.rs @@ -1,10 +1,9 @@ // automatically generated by the FlatBuffers compiler, do not modify - // @generated -use core::mem; use core::cmp::Ordering; +use core::mem; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -12,112 +11,114 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod models { - use core::mem; - use core::cmp::Ordering; + use core::cmp::Ordering; + use core::mem; - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; -pub enum PingBodyOffset {} -#[derive(Copy, Clone, PartialEq)] + 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: 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> { - let mut builder = PingBodyBuilder::new(_fbb); - if let Some(x) = args.payload { builder.add_payload(x); } - builder.finish() - } - - - #[inline] - pub fn payload(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? - .finish(); - Ok(()) - } -} -pub struct PingBodyArgs<'a> { - pub payload: Option>>, -} -impl<'a> Default for PingBodyArgs<'a> { - #[inline] - fn default() -> Self { - PingBodyArgs { - payload: None, + pub struct PingBody<'a> { + pub _tab: flatbuffers::Table<'a>, } - } -} -pub struct PingBodyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { - #[inline] - pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(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, + 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: flatbuffers::Table::new(buf, loc), + } + } } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - 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 + 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> { + let mut builder = PingBodyBuilder::new(_fbb); + if let Some(x) = args.payload { + builder.add_payload(x); + } + builder.finish() + } + + #[inline] + pub fn payload(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? + .finish(); + Ok(()) + } + } + pub struct PingBodyArgs<'a> { + pub payload: Option>>, + } + 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, + } + impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { + #[inline] + pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { + self.fbb_ + .push_slot_always::>(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> { + 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 diff --git a/common/protos/src/generated/proto_gen/node_service.rs b/common/protos/src/generated/proto_gen/node_service.rs index 88f7b3ab0..000d5b486 100644 --- a/common/protos/src/generated/proto_gen/node_service.rs +++ b/common/protos/src/generated/proto_gen/node_service.rs @@ -622,10 +622,7 @@ pub struct GenerallyLockResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct Mss { #[prost(map = "string, string", tag = "1")] - pub value: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub value: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LocalStorageInfoRequest { @@ -789,10 +786,7 @@ pub struct DownloadProfileDataResponse { #[prost(bool, tag = "1")] pub success: bool, #[prost(map = "string, bytes", tag = "2")] - pub data: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::vec::Vec, - >, + pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec>, #[prost(string, optional, tag = "3")] pub error_info: ::core::option::Option<::prost::alloc::string::String>, } @@ -1059,15 +1053,9 @@ pub struct LoadTransitionTierConfigResponse { } /// Generated client implementations. pub mod node_service_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; + #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct NodeServiceClient { inner: tonic::client::Grpc, @@ -1098,22 +1086,16 @@ pub mod node_service_client { let inner = tonic::client::Grpc::with_origin(inner, origin); Self { inner } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> NodeServiceClient> + pub fn with_interceptor(inner: T, interceptor: F) -> NodeServiceClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, - Response = http::Response< - >::ResponseBody, - >, + Response = http::Response<>::ResponseBody>, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { NodeServiceClient::new(InterceptedService::new(inner, interceptor)) } @@ -1156,15 +1138,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Ping", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Ping"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Ping")); @@ -1173,22 +1149,13 @@ pub mod node_service_client { pub async fn heal_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/HealBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/HealBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "HealBucket")); @@ -1197,22 +1164,13 @@ pub mod node_service_client { pub async fn list_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListBucket")); @@ -1221,22 +1179,13 @@ pub mod node_service_client { pub async fn make_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeBucket")); @@ -1245,22 +1194,13 @@ pub mod node_service_client { pub async fn get_bucket_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetBucketInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketInfo")); @@ -1269,22 +1209,13 @@ pub mod node_service_client { pub async fn delete_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucket")); @@ -1293,22 +1224,13 @@ pub mod node_service_client { pub async fn read_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadAll", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAll"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAll")); @@ -1317,22 +1239,13 @@ pub mod node_service_client { pub async fn write_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteAll", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteAll"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteAll")); @@ -1345,15 +1258,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Delete", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Delete"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Delete")); @@ -1362,22 +1269,13 @@ pub mod node_service_client { pub async fn verify_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/VerifyFile", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/VerifyFile"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "VerifyFile")); @@ -1386,22 +1284,13 @@ pub mod node_service_client { pub async fn check_parts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/CheckParts", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/CheckParts"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "CheckParts")); @@ -1410,22 +1299,13 @@ pub mod node_service_client { pub async fn rename_part( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenamePart", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenamePart"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenamePart")); @@ -1434,22 +1314,13 @@ pub mod node_service_client { pub async fn rename_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenameFile", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameFile"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameFile")); @@ -1462,15 +1333,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Write", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Write"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Write")); @@ -1479,22 +1344,13 @@ pub mod node_service_client { pub async fn write_stream( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteStream", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteStream"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteStream")); @@ -1504,22 +1360,13 @@ pub mod node_service_client { pub async fn read_at( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadAt", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAt"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAt")); @@ -1528,22 +1375,13 @@ pub mod node_service_client { pub async fn list_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListDir", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListDir"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListDir")); @@ -1552,22 +1390,13 @@ pub mod node_service_client { pub async fn walk_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WalkDir", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WalkDir"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WalkDir")); @@ -1576,22 +1405,13 @@ pub mod node_service_client { pub async fn rename_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenameData", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameData"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameData")); @@ -1600,22 +1420,13 @@ pub mod node_service_client { pub async fn make_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeVolumes", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolumes"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolumes")); @@ -1624,22 +1435,13 @@ pub mod node_service_client { pub async fn make_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolume")); @@ -1648,22 +1450,13 @@ pub mod node_service_client { pub async fn list_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListVolumes", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListVolumes"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListVolumes")); @@ -1672,22 +1465,13 @@ pub mod node_service_client { pub async fn stat_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StatVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StatVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StatVolume")); @@ -1696,22 +1480,13 @@ pub mod node_service_client { pub async fn delete_paths( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeletePaths", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePaths"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePaths")); @@ -1720,22 +1495,13 @@ pub mod node_service_client { pub async fn update_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UpdateMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetadata"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetadata")); @@ -1744,22 +1510,13 @@ pub mod node_service_client { pub async fn write_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteMetadata"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteMetadata")); @@ -1768,22 +1525,13 @@ pub mod node_service_client { pub async fn read_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadVersion", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadVersion"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadVersion")); @@ -1796,15 +1544,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadXL", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadXL"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadXL")); @@ -1813,22 +1555,13 @@ pub mod node_service_client { pub async fn delete_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVersion", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersion"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersion")); @@ -1837,22 +1570,13 @@ pub mod node_service_client { pub async fn delete_versions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVersions", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersions"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersions")); @@ -1861,22 +1585,13 @@ pub mod node_service_client { pub async fn read_multiple( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadMultiple", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadMultiple"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadMultiple")); @@ -1885,22 +1600,13 @@ pub mod node_service_client { pub async fn delete_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVolume")); @@ -1909,22 +1615,13 @@ pub mod node_service_client { pub async fn disk_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DiskInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DiskInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DiskInfo")); @@ -1933,22 +1630,13 @@ pub mod node_service_client { pub async fn ns_scanner( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/NsScanner", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/NsScanner"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "NsScanner")); @@ -1957,22 +1645,13 @@ pub mod node_service_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Lock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Lock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Lock")); @@ -1981,22 +1660,13 @@ pub mod node_service_client { pub async fn un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UnLock")); @@ -2005,22 +1675,13 @@ pub mod node_service_client { pub async fn r_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RLock")); @@ -2029,22 +1690,13 @@ pub mod node_service_client { pub async fn r_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RUnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RUnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RUnLock")); @@ -2053,22 +1705,13 @@ pub mod node_service_client { pub async fn force_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ForceUnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ForceUnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ForceUnLock")); @@ -2077,22 +1720,13 @@ pub mod node_service_client { pub async fn refresh( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Refresh", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Refresh"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Refresh")); @@ -2101,22 +1735,13 @@ pub mod node_service_client { pub async fn local_storage_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LocalStorageInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LocalStorageInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LocalStorageInfo")); @@ -2125,22 +1750,13 @@ pub mod node_service_client { pub async fn server_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ServerInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ServerInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ServerInfo")); @@ -2149,22 +1765,13 @@ pub mod node_service_client { pub async fn get_cpus( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetCpus", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetCpus"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetCpus")); @@ -2173,22 +1780,13 @@ pub mod node_service_client { pub async fn get_net_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetNetInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetNetInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetNetInfo")); @@ -2197,22 +1795,13 @@ pub mod node_service_client { pub async fn get_partitions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetPartitions", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetPartitions"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetPartitions")); @@ -2221,22 +1810,13 @@ pub mod node_service_client { pub async fn get_os_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetOsInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetOsInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetOsInfo")); @@ -2245,22 +1825,13 @@ pub mod node_service_client { pub async fn get_se_linux_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSELinuxInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSELinuxInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSELinuxInfo")); @@ -2269,22 +1840,13 @@ pub mod node_service_client { pub async fn get_sys_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSysConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysConfig"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysConfig")); @@ -2293,22 +1855,13 @@ pub mod node_service_client { pub async fn get_sys_errors( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSysErrors", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysErrors"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysErrors")); @@ -2317,22 +1870,13 @@ pub mod node_service_client { pub async fn get_mem_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMemInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMemInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMemInfo")); @@ -2341,22 +1885,13 @@ pub mod node_service_client { pub async fn get_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMetrics", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetrics"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMetrics")); @@ -2365,22 +1900,13 @@ pub mod node_service_client { pub async fn get_proc_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetProcInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetProcInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetProcInfo")); @@ -2389,22 +1915,13 @@ pub mod node_service_client { pub async fn start_profiling( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StartProfiling", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StartProfiling"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StartProfiling")); @@ -2413,48 +1930,28 @@ pub mod node_service_client { pub async fn download_profile_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DownloadProfileData", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DownloadProfileData"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DownloadProfileData"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DownloadProfileData")); self.inner.unary(req, path, codec).await } pub async fn get_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetBucketStats", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketStats"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketStats")); @@ -2463,22 +1960,13 @@ pub mod node_service_client { pub async fn get_sr_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSRMetrics", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSRMetrics"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSRMetrics")); @@ -2487,100 +1975,58 @@ pub mod node_service_client { pub async fn get_all_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetAllBucketStats", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetAllBucketStats"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "GetAllBucketStats"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "GetAllBucketStats")); self.inner.unary(req, path, codec).await } pub async fn load_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadBucketMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadBucketMetadata"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata")); self.inner.unary(req, path, codec).await } pub async fn delete_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteBucketMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucketMetadata"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata")); self.inner.unary(req, path, codec).await } pub async fn delete_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeletePolicy", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePolicy"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePolicy")); @@ -2589,22 +2035,13 @@ pub mod node_service_client { pub async fn load_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadPolicy", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicy"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicy")); @@ -2613,48 +2050,28 @@ pub mod node_service_client { pub async fn load_policy_mapping( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadPolicyMapping", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicyMapping"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping")); self.inner.unary(req, path, codec).await } pub async fn delete_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteUser", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteUser"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteUser")); @@ -2663,48 +2080,28 @@ pub mod node_service_client { pub async fn delete_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteServiceAccount", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteServiceAccount"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount")); self.inner.unary(req, path, codec).await } pub async fn load_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadUser", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadUser"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadUser")); @@ -2713,48 +2110,28 @@ pub mod node_service_client { pub async fn load_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadServiceAccount", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadServiceAccount"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadServiceAccount"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadServiceAccount")); self.inner.unary(req, path, codec).await } pub async fn load_group( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadGroup", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadGroup"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadGroup")); @@ -2763,30 +2140,16 @@ pub mod node_service_client { pub async fn reload_site_replication_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReloadSiteReplicationConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadSiteReplicationConfig"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new( - "node_service.NodeService", - "ReloadSiteReplicationConfig", - ), - ); + .insert(GrpcMethod::new("node_service.NodeService", "ReloadSiteReplicationConfig")); self.inner.unary(req, path, codec).await } /// rpc VerifyBinary() returns () {}; @@ -2794,22 +2157,13 @@ pub mod node_service_client { pub async fn signal_service( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/SignalService", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/SignalService"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "SignalService")); @@ -2818,100 +2172,58 @@ pub mod node_service_client { pub async fn background_heal_status( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/BackgroundHealStatus", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/BackgroundHealStatus"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus")); self.inner.unary(req, path, codec).await } pub async fn get_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMetacacheListing", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetacacheListing"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "GetMetacacheListing"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "GetMetacacheListing")); self.inner.unary(req, path, codec).await } pub async fn update_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UpdateMetacacheListing", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetacacheListing"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing")); self.inner.unary(req, path, codec).await } pub async fn reload_pool_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReloadPoolMeta", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadPoolMeta"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReloadPoolMeta")); @@ -2920,22 +2232,13 @@ pub mod node_service_client { pub async fn stop_rebalance( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StopRebalance", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StopRebalance"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StopRebalance")); @@ -2944,69 +2247,38 @@ pub mod node_service_client { pub async fn load_rebalance_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadRebalanceMeta", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadRebalanceMeta"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta")); self.inner.unary(req, path, codec).await } pub async fn load_transition_tier_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadTransitionTierConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadTransitionTierConfig"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new( - "node_service.NodeService", - "LoadTransitionTierConfig", - ), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadTransitionTierConfig")); self.inner.unary(req, path, codec).await } } } /// Generated server implementations. pub mod node_service_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] + #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with NodeServiceServer. #[async_trait] @@ -3019,38 +2291,23 @@ pub mod node_service_server { async fn heal_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn list_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_bucket_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_all( &self, request: tonic::Request, @@ -3058,10 +2315,7 @@ pub mod node_service_server { async fn write_all( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete( &self, request: tonic::Request, @@ -3069,52 +2323,33 @@ pub mod node_service_server { async fn verify_file( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn check_parts( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn rename_part( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn rename_file( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn write( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WriteStream method. - type WriteStreamStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type WriteStreamStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn write_stream( &self, request: tonic::Request>, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the ReadAt method. - type ReadAtStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type ReadAtStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; /// rpc Append(AppendRequest) returns (AppendResponse) {}; @@ -3127,9 +2362,7 @@ pub mod node_service_server { request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WalkDir method. - type WalkDirStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type WalkDirStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn walk_dir( @@ -3139,66 +2372,39 @@ pub mod node_service_server { async fn rename_data( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_volumes( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn list_volumes( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn stat_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_paths( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn update_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn write_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_version( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_xl( &self, request: tonic::Request, @@ -3206,42 +2412,25 @@ pub mod node_service_server { async fn delete_version( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_versions( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_multiple( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn disk_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the NsScanner method. - type NsScannerStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type NsScannerStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn ns_scanner( @@ -3251,59 +2440,35 @@ pub mod node_service_server { async fn lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn r_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn r_un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn force_un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn refresh( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn local_storage_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn server_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_cpus( &self, request: tonic::Request, @@ -3311,236 +2476,137 @@ pub mod node_service_server { async fn get_net_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_partitions( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_os_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_se_linux_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sys_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sys_errors( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_mem_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_metrics( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_proc_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn start_profiling( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn download_profile_data( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sr_metrics( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_all_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_policy( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_policy( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_policy_mapping( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_user( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_service_account( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_user( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_service_account( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_group( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn reload_site_replication_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// rpc VerifyBinary() returns () {}; /// rpc CommitBinary() returns () {}; async fn signal_service( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn background_heal_status( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn update_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn reload_pool_meta( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn stop_rebalance( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_rebalance_meta( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_transition_tier_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct NodeServiceServer { @@ -3563,10 +2629,7 @@ pub mod node_service_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -3610,10 +2673,7 @@ pub mod node_service_server { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -3621,21 +2681,12 @@ pub mod node_service_server { "/node_service.NodeService/Ping" => { #[allow(non_camel_case_types)] struct PingSvc(pub Arc); - impl tonic::server::UnaryService - for PingSvc { + impl tonic::server::UnaryService for PingSvc { type Response = super::PingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::ping(&inner, request).await - }; + let fut = async move { ::ping(&inner, request).await }; Box::pin(fut) } } @@ -3648,14 +2699,8 @@ pub mod node_service_server { let method = PingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3664,23 +2709,12 @@ pub mod node_service_server { "/node_service.NodeService/HealBucket" => { #[allow(non_camel_case_types)] struct HealBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for HealBucketSvc { + impl tonic::server::UnaryService for HealBucketSvc { type Response = super::HealBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::heal_bucket(&inner, request).await - }; + let fut = async move { ::heal_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3693,14 +2727,8 @@ pub mod node_service_server { let method = HealBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3709,23 +2737,12 @@ pub mod node_service_server { "/node_service.NodeService/ListBucket" => { #[allow(non_camel_case_types)] struct ListBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListBucketSvc { + impl tonic::server::UnaryService for ListBucketSvc { type Response = super::ListBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_bucket(&inner, request).await - }; + let fut = async move { ::list_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3738,14 +2755,8 @@ pub mod node_service_server { let method = ListBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3754,23 +2765,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeBucket" => { #[allow(non_camel_case_types)] struct MakeBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeBucketSvc { + impl tonic::server::UnaryService for MakeBucketSvc { type Response = super::MakeBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_bucket(&inner, request).await - }; + let fut = async move { ::make_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3783,14 +2783,8 @@ pub mod node_service_server { let method = MakeBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3799,23 +2793,12 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketInfo" => { #[allow(non_camel_case_types)] struct GetBucketInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetBucketInfoSvc { + impl tonic::server::UnaryService for GetBucketInfoSvc { type Response = super::GetBucketInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_bucket_info(&inner, request).await - }; + let fut = async move { ::get_bucket_info(&inner, request).await }; Box::pin(fut) } } @@ -3828,14 +2811,8 @@ pub mod node_service_server { let method = GetBucketInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3844,23 +2821,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucket" => { #[allow(non_camel_case_types)] struct DeleteBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteBucketSvc { + impl tonic::server::UnaryService for DeleteBucketSvc { type Response = super::DeleteBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_bucket(&inner, request).await - }; + let fut = async move { ::delete_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3873,14 +2839,8 @@ pub mod node_service_server { let method = DeleteBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3889,23 +2849,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadAll" => { #[allow(non_camel_case_types)] struct ReadAllSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadAllSvc { + impl tonic::server::UnaryService for ReadAllSvc { type Response = super::ReadAllResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_all(&inner, request).await - }; + let fut = async move { ::read_all(&inner, request).await }; Box::pin(fut) } } @@ -3918,14 +2867,8 @@ pub mod node_service_server { let method = ReadAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3934,23 +2877,12 @@ pub mod node_service_server { "/node_service.NodeService/WriteAll" => { #[allow(non_camel_case_types)] struct WriteAllSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for WriteAllSvc { + impl tonic::server::UnaryService for WriteAllSvc { type Response = super::WriteAllResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_all(&inner, request).await - }; + let fut = async move { ::write_all(&inner, request).await }; Box::pin(fut) } } @@ -3963,14 +2895,8 @@ pub mod node_service_server { let method = WriteAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3979,23 +2905,12 @@ pub mod node_service_server { "/node_service.NodeService/Delete" => { #[allow(non_camel_case_types)] struct DeleteSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteSvc { + impl tonic::server::UnaryService for DeleteSvc { type Response = super::DeleteResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete(&inner, request).await - }; + let fut = async move { ::delete(&inner, request).await }; Box::pin(fut) } } @@ -4008,14 +2923,8 @@ pub mod node_service_server { let method = DeleteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4024,23 +2933,12 @@ pub mod node_service_server { "/node_service.NodeService/VerifyFile" => { #[allow(non_camel_case_types)] struct VerifyFileSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for VerifyFileSvc { + impl tonic::server::UnaryService for VerifyFileSvc { type Response = super::VerifyFileResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::verify_file(&inner, request).await - }; + let fut = async move { ::verify_file(&inner, request).await }; Box::pin(fut) } } @@ -4053,14 +2951,8 @@ pub mod node_service_server { let method = VerifyFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4069,23 +2961,12 @@ pub mod node_service_server { "/node_service.NodeService/CheckParts" => { #[allow(non_camel_case_types)] struct CheckPartsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for CheckPartsSvc { + impl tonic::server::UnaryService for CheckPartsSvc { type Response = super::CheckPartsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::check_parts(&inner, request).await - }; + let fut = async move { ::check_parts(&inner, request).await }; Box::pin(fut) } } @@ -4098,14 +2979,8 @@ pub mod node_service_server { let method = CheckPartsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4114,23 +2989,12 @@ pub mod node_service_server { "/node_service.NodeService/RenamePart" => { #[allow(non_camel_case_types)] struct RenamePartSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenamePartSvc { + impl tonic::server::UnaryService for RenamePartSvc { type Response = super::RenamePartResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_part(&inner, request).await - }; + let fut = async move { ::rename_part(&inner, request).await }; Box::pin(fut) } } @@ -4143,14 +3007,8 @@ pub mod node_service_server { let method = RenamePartSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4159,23 +3017,12 @@ pub mod node_service_server { "/node_service.NodeService/RenameFile" => { #[allow(non_camel_case_types)] struct RenameFileSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenameFileSvc { + impl tonic::server::UnaryService for RenameFileSvc { type Response = super::RenameFileResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_file(&inner, request).await - }; + let fut = async move { ::rename_file(&inner, request).await }; Box::pin(fut) } } @@ -4188,14 +3035,8 @@ pub mod node_service_server { let method = RenameFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4204,21 +3045,12 @@ pub mod node_service_server { "/node_service.NodeService/Write" => { #[allow(non_camel_case_types)] struct WriteSvc(pub Arc); - impl tonic::server::UnaryService - for WriteSvc { + impl tonic::server::UnaryService for WriteSvc { type Response = super::WriteResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write(&inner, request).await - }; + let fut = async move { ::write(&inner, request).await }; Box::pin(fut) } } @@ -4231,14 +3063,8 @@ pub mod node_service_server { let method = WriteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4247,26 +3073,13 @@ pub mod node_service_server { "/node_service.NodeService/WriteStream" => { #[allow(non_camel_case_types)] struct WriteStreamSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for WriteStreamSvc { + impl tonic::server::StreamingService for WriteStreamSvc { type Response = super::WriteResponse; type ResponseStream = T::WriteStreamStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_stream(&inner, request).await - }; + let fut = async move { ::write_stream(&inner, request).await }; Box::pin(fut) } } @@ -4279,14 +3092,8 @@ pub mod node_service_server { let method = WriteStreamSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -4295,26 +3102,13 @@ pub mod node_service_server { "/node_service.NodeService/ReadAt" => { #[allow(non_camel_case_types)] struct ReadAtSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for ReadAtSvc { + impl tonic::server::StreamingService for ReadAtSvc { type Response = super::ReadAtResponse; type ResponseStream = T::ReadAtStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_at(&inner, request).await - }; + let fut = async move { ::read_at(&inner, request).await }; Box::pin(fut) } } @@ -4327,14 +3121,8 @@ pub mod node_service_server { let method = ReadAtSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -4343,23 +3131,12 @@ pub mod node_service_server { "/node_service.NodeService/ListDir" => { #[allow(non_camel_case_types)] struct ListDirSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListDirSvc { + impl tonic::server::UnaryService for ListDirSvc { type Response = super::ListDirResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_dir(&inner, request).await - }; + let fut = async move { ::list_dir(&inner, request).await }; Box::pin(fut) } } @@ -4372,14 +3149,8 @@ pub mod node_service_server { let method = ListDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4388,24 +3159,13 @@ pub mod node_service_server { "/node_service.NodeService/WalkDir" => { #[allow(non_camel_case_types)] struct WalkDirSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::ServerStreamingService - for WalkDirSvc { + impl tonic::server::ServerStreamingService for WalkDirSvc { type Response = super::WalkDirResponse; type ResponseStream = T::WalkDirStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::walk_dir(&inner, request).await - }; + let fut = async move { ::walk_dir(&inner, request).await }; Box::pin(fut) } } @@ -4418,14 +3178,8 @@ pub mod node_service_server { let method = WalkDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.server_streaming(method, req).await; Ok(res) }; @@ -4434,23 +3188,12 @@ pub mod node_service_server { "/node_service.NodeService/RenameData" => { #[allow(non_camel_case_types)] struct RenameDataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenameDataSvc { + impl tonic::server::UnaryService for RenameDataSvc { type Response = super::RenameDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_data(&inner, request).await - }; + let fut = async move { ::rename_data(&inner, request).await }; Box::pin(fut) } } @@ -4463,14 +3206,8 @@ pub mod node_service_server { let method = RenameDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4479,23 +3216,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolumes" => { #[allow(non_camel_case_types)] struct MakeVolumesSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeVolumesSvc { + impl tonic::server::UnaryService for MakeVolumesSvc { type Response = super::MakeVolumesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_volumes(&inner, request).await - }; + let fut = async move { ::make_volumes(&inner, request).await }; Box::pin(fut) } } @@ -4508,14 +3234,8 @@ pub mod node_service_server { let method = MakeVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4524,23 +3244,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolume" => { #[allow(non_camel_case_types)] struct MakeVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeVolumeSvc { + impl tonic::server::UnaryService for MakeVolumeSvc { type Response = super::MakeVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_volume(&inner, request).await - }; + let fut = async move { ::make_volume(&inner, request).await }; Box::pin(fut) } } @@ -4553,14 +3262,8 @@ pub mod node_service_server { let method = MakeVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4569,23 +3272,12 @@ pub mod node_service_server { "/node_service.NodeService/ListVolumes" => { #[allow(non_camel_case_types)] struct ListVolumesSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListVolumesSvc { + impl tonic::server::UnaryService for ListVolumesSvc { type Response = super::ListVolumesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_volumes(&inner, request).await - }; + let fut = async move { ::list_volumes(&inner, request).await }; Box::pin(fut) } } @@ -4598,14 +3290,8 @@ pub mod node_service_server { let method = ListVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4614,23 +3300,12 @@ pub mod node_service_server { "/node_service.NodeService/StatVolume" => { #[allow(non_camel_case_types)] struct StatVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StatVolumeSvc { + impl tonic::server::UnaryService for StatVolumeSvc { type Response = super::StatVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::stat_volume(&inner, request).await - }; + let fut = async move { ::stat_volume(&inner, request).await }; Box::pin(fut) } } @@ -4643,14 +3318,8 @@ pub mod node_service_server { let method = StatVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4659,23 +3328,12 @@ pub mod node_service_server { "/node_service.NodeService/DeletePaths" => { #[allow(non_camel_case_types)] struct DeletePathsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeletePathsSvc { + impl tonic::server::UnaryService for DeletePathsSvc { type Response = super::DeletePathsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_paths(&inner, request).await - }; + let fut = async move { ::delete_paths(&inner, request).await }; Box::pin(fut) } } @@ -4688,14 +3346,8 @@ pub mod node_service_server { let method = DeletePathsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4704,23 +3356,12 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetadata" => { #[allow(non_camel_case_types)] struct UpdateMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UpdateMetadataSvc { + impl tonic::server::UnaryService for UpdateMetadataSvc { type Response = super::UpdateMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::update_metadata(&inner, request).await - }; + let fut = async move { ::update_metadata(&inner, request).await }; Box::pin(fut) } } @@ -4733,14 +3374,8 @@ pub mod node_service_server { let method = UpdateMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4749,23 +3384,12 @@ pub mod node_service_server { "/node_service.NodeService/WriteMetadata" => { #[allow(non_camel_case_types)] struct WriteMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for WriteMetadataSvc { + impl tonic::server::UnaryService for WriteMetadataSvc { type Response = super::WriteMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_metadata(&inner, request).await - }; + let fut = async move { ::write_metadata(&inner, request).await }; Box::pin(fut) } } @@ -4778,14 +3402,8 @@ pub mod node_service_server { let method = WriteMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4794,23 +3412,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadVersion" => { #[allow(non_camel_case_types)] struct ReadVersionSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadVersionSvc { + impl tonic::server::UnaryService for ReadVersionSvc { type Response = super::ReadVersionResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_version(&inner, request).await - }; + let fut = async move { ::read_version(&inner, request).await }; Box::pin(fut) } } @@ -4823,14 +3430,8 @@ pub mod node_service_server { let method = ReadVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4839,23 +3440,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadXL" => { #[allow(non_camel_case_types)] struct ReadXLSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadXLSvc { + impl tonic::server::UnaryService for ReadXLSvc { type Response = super::ReadXlResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_xl(&inner, request).await - }; + let fut = async move { ::read_xl(&inner, request).await }; Box::pin(fut) } } @@ -4868,14 +3458,8 @@ pub mod node_service_server { let method = ReadXLSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4884,23 +3468,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersion" => { #[allow(non_camel_case_types)] struct DeleteVersionSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVersionSvc { + impl tonic::server::UnaryService for DeleteVersionSvc { type Response = super::DeleteVersionResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_version(&inner, request).await - }; + let fut = async move { ::delete_version(&inner, request).await }; Box::pin(fut) } } @@ -4913,14 +3486,8 @@ pub mod node_service_server { let method = DeleteVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4929,23 +3496,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersions" => { #[allow(non_camel_case_types)] struct DeleteVersionsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVersionsSvc { + impl tonic::server::UnaryService for DeleteVersionsSvc { type Response = super::DeleteVersionsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_versions(&inner, request).await - }; + let fut = async move { ::delete_versions(&inner, request).await }; Box::pin(fut) } } @@ -4958,14 +3514,8 @@ pub mod node_service_server { let method = DeleteVersionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4974,23 +3524,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadMultiple" => { #[allow(non_camel_case_types)] struct ReadMultipleSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadMultipleSvc { + impl tonic::server::UnaryService for ReadMultipleSvc { type Response = super::ReadMultipleResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_multiple(&inner, request).await - }; + let fut = async move { ::read_multiple(&inner, request).await }; Box::pin(fut) } } @@ -5003,14 +3542,8 @@ pub mod node_service_server { let method = ReadMultipleSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5019,23 +3552,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVolume" => { #[allow(non_camel_case_types)] struct DeleteVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVolumeSvc { + impl tonic::server::UnaryService for DeleteVolumeSvc { type Response = super::DeleteVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_volume(&inner, request).await - }; + let fut = async move { ::delete_volume(&inner, request).await }; Box::pin(fut) } } @@ -5048,14 +3570,8 @@ pub mod node_service_server { let method = DeleteVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5064,23 +3580,12 @@ pub mod node_service_server { "/node_service.NodeService/DiskInfo" => { #[allow(non_camel_case_types)] struct DiskInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DiskInfoSvc { + impl tonic::server::UnaryService for DiskInfoSvc { type Response = super::DiskInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::disk_info(&inner, request).await - }; + let fut = async move { ::disk_info(&inner, request).await }; Box::pin(fut) } } @@ -5093,14 +3598,8 @@ pub mod node_service_server { let method = DiskInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5109,26 +3608,13 @@ pub mod node_service_server { "/node_service.NodeService/NsScanner" => { #[allow(non_camel_case_types)] struct NsScannerSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for NsScannerSvc { + impl tonic::server::StreamingService for NsScannerSvc { type Response = super::NsScannerResponse; type ResponseStream = T::NsScannerStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::ns_scanner(&inner, request).await - }; + let fut = async move { ::ns_scanner(&inner, request).await }; Box::pin(fut) } } @@ -5141,14 +3627,8 @@ pub mod node_service_server { let method = NsScannerSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -5157,23 +3637,12 @@ pub mod node_service_server { "/node_service.NodeService/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LockSvc { + impl tonic::server::UnaryService for LockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::lock(&inner, request).await - }; + let fut = async move { ::lock(&inner, request).await }; Box::pin(fut) } } @@ -5186,14 +3655,8 @@ pub mod node_service_server { let method = LockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5202,23 +3665,12 @@ pub mod node_service_server { "/node_service.NodeService/UnLock" => { #[allow(non_camel_case_types)] struct UnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UnLockSvc { + impl tonic::server::UnaryService for UnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::un_lock(&inner, request).await - }; + let fut = async move { ::un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5231,14 +3683,8 @@ pub mod node_service_server { let method = UnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5247,23 +3693,12 @@ pub mod node_service_server { "/node_service.NodeService/RLock" => { #[allow(non_camel_case_types)] struct RLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RLockSvc { + impl tonic::server::UnaryService for RLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::r_lock(&inner, request).await - }; + let fut = async move { ::r_lock(&inner, request).await }; Box::pin(fut) } } @@ -5276,14 +3711,8 @@ pub mod node_service_server { let method = RLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5292,23 +3721,12 @@ pub mod node_service_server { "/node_service.NodeService/RUnLock" => { #[allow(non_camel_case_types)] struct RUnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RUnLockSvc { + impl tonic::server::UnaryService for RUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::r_un_lock(&inner, request).await - }; + let fut = async move { ::r_un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5321,14 +3739,8 @@ pub mod node_service_server { let method = RUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5337,23 +3749,12 @@ pub mod node_service_server { "/node_service.NodeService/ForceUnLock" => { #[allow(non_camel_case_types)] struct ForceUnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ForceUnLockSvc { + impl tonic::server::UnaryService for ForceUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::force_un_lock(&inner, request).await - }; + let fut = async move { ::force_un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5366,14 +3767,8 @@ pub mod node_service_server { let method = ForceUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5382,23 +3777,12 @@ pub mod node_service_server { "/node_service.NodeService/Refresh" => { #[allow(non_camel_case_types)] struct RefreshSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RefreshSvc { + impl tonic::server::UnaryService for RefreshSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::refresh(&inner, request).await - }; + let fut = async move { ::refresh(&inner, request).await }; Box::pin(fut) } } @@ -5411,14 +3795,8 @@ pub mod node_service_server { let method = RefreshSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5427,24 +3805,12 @@ pub mod node_service_server { "/node_service.NodeService/LocalStorageInfo" => { #[allow(non_camel_case_types)] struct LocalStorageInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LocalStorageInfoSvc { + impl tonic::server::UnaryService for LocalStorageInfoSvc { type Response = super::LocalStorageInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::local_storage_info(&inner, request) - .await - }; + let fut = async move { ::local_storage_info(&inner, request).await }; Box::pin(fut) } } @@ -5457,14 +3823,8 @@ pub mod node_service_server { let method = LocalStorageInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5473,23 +3833,12 @@ pub mod node_service_server { "/node_service.NodeService/ServerInfo" => { #[allow(non_camel_case_types)] struct ServerInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ServerInfoSvc { + impl tonic::server::UnaryService for ServerInfoSvc { type Response = super::ServerInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::server_info(&inner, request).await - }; + let fut = async move { ::server_info(&inner, request).await }; Box::pin(fut) } } @@ -5502,14 +3851,8 @@ pub mod node_service_server { let method = ServerInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5518,23 +3861,12 @@ pub mod node_service_server { "/node_service.NodeService/GetCpus" => { #[allow(non_camel_case_types)] struct GetCpusSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetCpusSvc { + impl tonic::server::UnaryService for GetCpusSvc { type Response = super::GetCpusResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_cpus(&inner, request).await - }; + let fut = async move { ::get_cpus(&inner, request).await }; Box::pin(fut) } } @@ -5547,14 +3879,8 @@ pub mod node_service_server { let method = GetCpusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5563,23 +3889,12 @@ pub mod node_service_server { "/node_service.NodeService/GetNetInfo" => { #[allow(non_camel_case_types)] struct GetNetInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetNetInfoSvc { + impl tonic::server::UnaryService for GetNetInfoSvc { type Response = super::GetNetInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_net_info(&inner, request).await - }; + let fut = async move { ::get_net_info(&inner, request).await }; Box::pin(fut) } } @@ -5592,14 +3907,8 @@ pub mod node_service_server { let method = GetNetInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5608,23 +3917,12 @@ pub mod node_service_server { "/node_service.NodeService/GetPartitions" => { #[allow(non_camel_case_types)] struct GetPartitionsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetPartitionsSvc { + impl tonic::server::UnaryService for GetPartitionsSvc { type Response = super::GetPartitionsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_partitions(&inner, request).await - }; + let fut = async move { ::get_partitions(&inner, request).await }; Box::pin(fut) } } @@ -5637,14 +3935,8 @@ pub mod node_service_server { let method = GetPartitionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5653,23 +3945,12 @@ pub mod node_service_server { "/node_service.NodeService/GetOsInfo" => { #[allow(non_camel_case_types)] struct GetOsInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetOsInfoSvc { + impl tonic::server::UnaryService for GetOsInfoSvc { type Response = super::GetOsInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_os_info(&inner, request).await - }; + let fut = async move { ::get_os_info(&inner, request).await }; Box::pin(fut) } } @@ -5682,14 +3963,8 @@ pub mod node_service_server { let method = GetOsInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5698,23 +3973,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSELinuxInfo" => { #[allow(non_camel_case_types)] struct GetSELinuxInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSELinuxInfoSvc { + impl tonic::server::UnaryService for GetSELinuxInfoSvc { type Response = super::GetSeLinuxInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_se_linux_info(&inner, request).await - }; + let fut = async move { ::get_se_linux_info(&inner, request).await }; Box::pin(fut) } } @@ -5727,14 +3991,8 @@ pub mod node_service_server { let method = GetSELinuxInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5743,23 +4001,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSysConfig" => { #[allow(non_camel_case_types)] struct GetSysConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSysConfigSvc { + impl tonic::server::UnaryService for GetSysConfigSvc { type Response = super::GetSysConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sys_config(&inner, request).await - }; + let fut = async move { ::get_sys_config(&inner, request).await }; Box::pin(fut) } } @@ -5772,14 +4019,8 @@ pub mod node_service_server { let method = GetSysConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5788,23 +4029,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSysErrors" => { #[allow(non_camel_case_types)] struct GetSysErrorsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSysErrorsSvc { + impl tonic::server::UnaryService for GetSysErrorsSvc { type Response = super::GetSysErrorsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sys_errors(&inner, request).await - }; + let fut = async move { ::get_sys_errors(&inner, request).await }; Box::pin(fut) } } @@ -5817,14 +4047,8 @@ pub mod node_service_server { let method = GetSysErrorsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5833,23 +4057,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMemInfo" => { #[allow(non_camel_case_types)] struct GetMemInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMemInfoSvc { + impl tonic::server::UnaryService for GetMemInfoSvc { type Response = super::GetMemInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_mem_info(&inner, request).await - }; + let fut = async move { ::get_mem_info(&inner, request).await }; Box::pin(fut) } } @@ -5862,14 +4075,8 @@ pub mod node_service_server { let method = GetMemInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5878,23 +4085,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMetrics" => { #[allow(non_camel_case_types)] struct GetMetricsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMetricsSvc { + impl tonic::server::UnaryService for GetMetricsSvc { type Response = super::GetMetricsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_metrics(&inner, request).await - }; + let fut = async move { ::get_metrics(&inner, request).await }; Box::pin(fut) } } @@ -5907,14 +4103,8 @@ pub mod node_service_server { let method = GetMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5923,23 +4113,12 @@ pub mod node_service_server { "/node_service.NodeService/GetProcInfo" => { #[allow(non_camel_case_types)] struct GetProcInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetProcInfoSvc { + impl tonic::server::UnaryService for GetProcInfoSvc { type Response = super::GetProcInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proc_info(&inner, request).await - }; + let fut = async move { ::get_proc_info(&inner, request).await }; Box::pin(fut) } } @@ -5952,14 +4131,8 @@ pub mod node_service_server { let method = GetProcInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5968,23 +4141,12 @@ pub mod node_service_server { "/node_service.NodeService/StartProfiling" => { #[allow(non_camel_case_types)] struct StartProfilingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StartProfilingSvc { + impl tonic::server::UnaryService for StartProfilingSvc { type Response = super::StartProfilingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::start_profiling(&inner, request).await - }; + let fut = async move { ::start_profiling(&inner, request).await }; Box::pin(fut) } } @@ -5997,14 +4159,8 @@ pub mod node_service_server { let method = StartProfilingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6013,24 +4169,12 @@ pub mod node_service_server { "/node_service.NodeService/DownloadProfileData" => { #[allow(non_camel_case_types)] struct DownloadProfileDataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DownloadProfileDataSvc { + impl tonic::server::UnaryService for DownloadProfileDataSvc { type Response = super::DownloadProfileDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::download_profile_data(&inner, request) - .await - }; + let fut = async move { ::download_profile_data(&inner, request).await }; Box::pin(fut) } } @@ -6043,14 +4187,8 @@ pub mod node_service_server { let method = DownloadProfileDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6059,23 +4197,12 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketStats" => { #[allow(non_camel_case_types)] struct GetBucketStatsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetBucketStatsSvc { + impl tonic::server::UnaryService for GetBucketStatsSvc { type Response = super::GetBucketStatsDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_bucket_stats(&inner, request).await - }; + let fut = async move { ::get_bucket_stats(&inner, request).await }; Box::pin(fut) } } @@ -6088,14 +4215,8 @@ pub mod node_service_server { let method = GetBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6104,23 +4225,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSRMetrics" => { #[allow(non_camel_case_types)] struct GetSRMetricsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSRMetricsSvc { + impl tonic::server::UnaryService for GetSRMetricsSvc { type Response = super::GetSrMetricsDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sr_metrics(&inner, request).await - }; + let fut = async move { ::get_sr_metrics(&inner, request).await }; Box::pin(fut) } } @@ -6133,14 +4243,8 @@ pub mod node_service_server { let method = GetSRMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6149,24 +4253,12 @@ pub mod node_service_server { "/node_service.NodeService/GetAllBucketStats" => { #[allow(non_camel_case_types)] struct GetAllBucketStatsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetAllBucketStatsSvc { + impl tonic::server::UnaryService for GetAllBucketStatsSvc { type Response = super::GetAllBucketStatsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_all_bucket_stats(&inner, request) - .await - }; + let fut = async move { ::get_all_bucket_stats(&inner, request).await }; Box::pin(fut) } } @@ -6179,14 +4271,8 @@ pub mod node_service_server { let method = GetAllBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6195,24 +4281,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadBucketMetadata" => { #[allow(non_camel_case_types)] struct LoadBucketMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadBucketMetadataSvc { + impl tonic::server::UnaryService for LoadBucketMetadataSvc { type Response = super::LoadBucketMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_bucket_metadata(&inner, request) - .await - }; + let fut = async move { ::load_bucket_metadata(&inner, request).await }; Box::pin(fut) } } @@ -6225,14 +4299,8 @@ pub mod node_service_server { let method = LoadBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6241,24 +4309,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucketMetadata" => { #[allow(non_camel_case_types)] struct DeleteBucketMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteBucketMetadataSvc { + impl tonic::server::UnaryService for DeleteBucketMetadataSvc { type Response = super::DeleteBucketMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_bucket_metadata(&inner, request) - .await - }; + let fut = async move { ::delete_bucket_metadata(&inner, request).await }; Box::pin(fut) } } @@ -6271,14 +4327,8 @@ pub mod node_service_server { let method = DeleteBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6287,23 +4337,12 @@ pub mod node_service_server { "/node_service.NodeService/DeletePolicy" => { #[allow(non_camel_case_types)] struct DeletePolicySvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeletePolicySvc { + impl tonic::server::UnaryService for DeletePolicySvc { type Response = super::DeletePolicyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_policy(&inner, request).await - }; + let fut = async move { ::delete_policy(&inner, request).await }; Box::pin(fut) } } @@ -6316,14 +4355,8 @@ pub mod node_service_server { let method = DeletePolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6332,23 +4365,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicy" => { #[allow(non_camel_case_types)] struct LoadPolicySvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadPolicySvc { + impl tonic::server::UnaryService for LoadPolicySvc { type Response = super::LoadPolicyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_policy(&inner, request).await - }; + let fut = async move { ::load_policy(&inner, request).await }; Box::pin(fut) } } @@ -6361,14 +4383,8 @@ pub mod node_service_server { let method = LoadPolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6377,24 +4393,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicyMapping" => { #[allow(non_camel_case_types)] struct LoadPolicyMappingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadPolicyMappingSvc { + impl tonic::server::UnaryService for LoadPolicyMappingSvc { type Response = super::LoadPolicyMappingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_policy_mapping(&inner, request) - .await - }; + let fut = async move { ::load_policy_mapping(&inner, request).await }; Box::pin(fut) } } @@ -6407,14 +4411,8 @@ pub mod node_service_server { let method = LoadPolicyMappingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6423,23 +4421,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteUser" => { #[allow(non_camel_case_types)] struct DeleteUserSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteUserSvc { + impl tonic::server::UnaryService for DeleteUserSvc { type Response = super::DeleteUserResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_user(&inner, request).await - }; + let fut = async move { ::delete_user(&inner, request).await }; Box::pin(fut) } } @@ -6452,14 +4439,8 @@ pub mod node_service_server { let method = DeleteUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6468,24 +4449,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteServiceAccount" => { #[allow(non_camel_case_types)] struct DeleteServiceAccountSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteServiceAccountSvc { + impl tonic::server::UnaryService for DeleteServiceAccountSvc { type Response = super::DeleteServiceAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_service_account(&inner, request) - .await - }; + let fut = async move { ::delete_service_account(&inner, request).await }; Box::pin(fut) } } @@ -6498,14 +4467,8 @@ pub mod node_service_server { let method = DeleteServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6514,23 +4477,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadUser" => { #[allow(non_camel_case_types)] struct LoadUserSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadUserSvc { + impl tonic::server::UnaryService for LoadUserSvc { type Response = super::LoadUserResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_user(&inner, request).await - }; + let fut = async move { ::load_user(&inner, request).await }; Box::pin(fut) } } @@ -6543,14 +4495,8 @@ pub mod node_service_server { let method = LoadUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6559,24 +4505,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadServiceAccount" => { #[allow(non_camel_case_types)] struct LoadServiceAccountSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadServiceAccountSvc { + impl tonic::server::UnaryService for LoadServiceAccountSvc { type Response = super::LoadServiceAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_service_account(&inner, request) - .await - }; + let fut = async move { ::load_service_account(&inner, request).await }; Box::pin(fut) } } @@ -6589,14 +4523,8 @@ pub mod node_service_server { let method = LoadServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6605,23 +4533,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadGroup" => { #[allow(non_camel_case_types)] struct LoadGroupSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadGroupSvc { + impl tonic::server::UnaryService for LoadGroupSvc { type Response = super::LoadGroupResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_group(&inner, request).await - }; + let fut = async move { ::load_group(&inner, request).await }; Box::pin(fut) } } @@ -6634,14 +4551,8 @@ pub mod node_service_server { let method = LoadGroupSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6650,30 +4561,14 @@ pub mod node_service_server { "/node_service.NodeService/ReloadSiteReplicationConfig" => { #[allow(non_camel_case_types)] struct ReloadSiteReplicationConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService< - super::ReloadSiteReplicationConfigRequest, - > for ReloadSiteReplicationConfigSvc { + impl tonic::server::UnaryService + for ReloadSiteReplicationConfigSvc + { type Response = super::ReloadSiteReplicationConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::ReloadSiteReplicationConfigRequest, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::reload_site_replication_config( - &inner, - request, - ) - .await - }; + let fut = async move { ::reload_site_replication_config(&inner, request).await }; Box::pin(fut) } } @@ -6686,14 +4581,8 @@ pub mod node_service_server { let method = ReloadSiteReplicationConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6702,23 +4591,12 @@ pub mod node_service_server { "/node_service.NodeService/SignalService" => { #[allow(non_camel_case_types)] struct SignalServiceSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for SignalServiceSvc { + impl tonic::server::UnaryService for SignalServiceSvc { type Response = super::SignalServiceResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::signal_service(&inner, request).await - }; + let fut = async move { ::signal_service(&inner, request).await }; Box::pin(fut) } } @@ -6731,14 +4609,8 @@ pub mod node_service_server { let method = SignalServiceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6747,24 +4619,12 @@ pub mod node_service_server { "/node_service.NodeService/BackgroundHealStatus" => { #[allow(non_camel_case_types)] struct BackgroundHealStatusSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for BackgroundHealStatusSvc { + impl tonic::server::UnaryService for BackgroundHealStatusSvc { type Response = super::BackgroundHealStatusResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::background_heal_status(&inner, request) - .await - }; + let fut = async move { ::background_heal_status(&inner, request).await }; Box::pin(fut) } } @@ -6777,14 +4637,8 @@ pub mod node_service_server { let method = BackgroundHealStatusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6793,24 +4647,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMetacacheListing" => { #[allow(non_camel_case_types)] struct GetMetacacheListingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMetacacheListingSvc { + impl tonic::server::UnaryService for GetMetacacheListingSvc { type Response = super::GetMetacacheListingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_metacache_listing(&inner, request) - .await - }; + let fut = async move { ::get_metacache_listing(&inner, request).await }; Box::pin(fut) } } @@ -6823,14 +4665,8 @@ pub mod node_service_server { let method = GetMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6839,27 +4675,12 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetacacheListing" => { #[allow(non_camel_case_types)] struct UpdateMetacacheListingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UpdateMetacacheListingSvc { + impl tonic::server::UnaryService for UpdateMetacacheListingSvc { type Response = super::UpdateMetacacheListingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::update_metacache_listing( - &inner, - request, - ) - .await - }; + let fut = async move { ::update_metacache_listing(&inner, request).await }; Box::pin(fut) } } @@ -6872,14 +4693,8 @@ pub mod node_service_server { let method = UpdateMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6888,23 +4703,12 @@ pub mod node_service_server { "/node_service.NodeService/ReloadPoolMeta" => { #[allow(non_camel_case_types)] struct ReloadPoolMetaSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReloadPoolMetaSvc { + impl tonic::server::UnaryService for ReloadPoolMetaSvc { type Response = super::ReloadPoolMetaResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::reload_pool_meta(&inner, request).await - }; + let fut = async move { ::reload_pool_meta(&inner, request).await }; Box::pin(fut) } } @@ -6917,14 +4721,8 @@ pub mod node_service_server { let method = ReloadPoolMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6933,23 +4731,12 @@ pub mod node_service_server { "/node_service.NodeService/StopRebalance" => { #[allow(non_camel_case_types)] struct StopRebalanceSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StopRebalanceSvc { + impl tonic::server::UnaryService for StopRebalanceSvc { type Response = super::StopRebalanceResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::stop_rebalance(&inner, request).await - }; + let fut = async move { ::stop_rebalance(&inner, request).await }; Box::pin(fut) } } @@ -6962,14 +4749,8 @@ pub mod node_service_server { let method = StopRebalanceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6978,24 +4759,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadRebalanceMeta" => { #[allow(non_camel_case_types)] struct LoadRebalanceMetaSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadRebalanceMetaSvc { + impl tonic::server::UnaryService for LoadRebalanceMetaSvc { type Response = super::LoadRebalanceMetaResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_rebalance_meta(&inner, request) - .await - }; + let fut = async move { ::load_rebalance_meta(&inner, request).await }; Box::pin(fut) } } @@ -7008,14 +4777,8 @@ pub mod node_service_server { let method = LoadRebalanceMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -7024,29 +4787,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadTransitionTierConfig" => { #[allow(non_camel_case_types)] struct LoadTransitionTierConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadTransitionTierConfigSvc { + impl tonic::server::UnaryService for LoadTransitionTierConfigSvc { type Response = super::LoadTransitionTierConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::LoadTransitionTierConfigRequest, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_transition_tier_config( - &inner, - request, - ) - .await - }; + let fut = async move { ::load_transition_tier_config(&inner, request).await }; Box::pin(fut) } } @@ -7059,36 +4805,20 @@ pub mod node_service_server { let method = LoadTransitionTierConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers.insert(tonic::Status::GRPC_STATUS, (tonic::Code::Unimplemented as i32).into()); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 6a83beae5..928a154ae 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -1880,7 +1880,7 @@ impl S3 for FS { let input = req.input; info!("{:?}", input); - let db = make_cnosdbms(input.clone()).await.map_err(|e| { + let db = make_cnosdbms(input.clone(), false).await.map_err(|e| { error!("make db failed, {}", e.to_string()); s3_error!(InternalError) })?; diff --git a/s3select/api/src/lib.rs b/s3select/api/src/lib.rs index 72a9e9c77..acaead722 100644 --- a/s3select/api/src/lib.rs +++ b/s3select/api/src/lib.rs @@ -38,6 +38,9 @@ pub enum QueryError { #[snafu(display("Udf already exists, name:{}.", name))] FunctionExists { name: String }, + + #[snafu(display("Store Error, e:{}.", e))] + StoreError { e: String }, } impl From for QueryError { diff --git a/s3select/api/src/query/session.rs b/s3select/api/src/query/session.rs index 23e80e3c9..c9d91f51d 100644 --- a/s3select/api/src/query/session.rs +++ b/s3select/api/src/query/session.rs @@ -1,9 +1,12 @@ use std::sync::Arc; +use bytes::Bytes; use datafusion::{ execution::{context::SessionState, runtime_env::RuntimeEnvBuilder, SessionStateBuilder}, prelude::SessionContext, }; +use object_store::{memory::InMemory, path::Path, ObjectStore}; +use tracing::error; use crate::{object_store::EcObjectStore, QueryError, QueryResult}; @@ -27,11 +30,13 @@ pub struct SessionCtxDesc { } #[derive(Default)] -pub struct SessionCtxFactory {} +pub struct SessionCtxFactory { + pub is_test: bool, +} impl SessionCtxFactory { - pub fn create_session_ctx(&self, context: &Context) -> QueryResult { - let df_session_ctx = self.build_df_session_context(context)?; + pub async fn create_session_ctx(&self, context: &Context) -> QueryResult { + let df_session_ctx = self.build_df_session_context(context).await?; Ok(SessionCtx { _desc: Arc::new(SessionCtxDesc {}), @@ -39,17 +44,41 @@ impl SessionCtxFactory { }) } - fn build_df_session_context(&self, context: &Context) -> QueryResult { + async fn build_df_session_context(&self, context: &Context) -> QueryResult { let path = format!("s3://{}", context.input.bucket); let store_url = url::Url::parse(&path).unwrap(); - let store = EcObjectStore::new(context.input.clone()).map_err(|_| QueryError::NotImplemented { err: String::new() })?; - let rt = RuntimeEnvBuilder::new().build()?; let df_session_state = SessionStateBuilder::new() .with_runtime_env(Arc::new(rt)) - .with_object_store(&store_url, Arc::new(store)) - .with_default_features() - .build(); + .with_default_features(); + + let df_session_state = if self.is_test { + let store: Arc = Arc::new(InMemory::new()); + let data = b"id,name,age,department,salary + 1,Alice,25,HR,5000 + 2,Bob,30,IT,6000 + 3,Charlie,35,Finance,7000 + 4,Diana,22,Marketing,4500 + 5,Eve,28,IT,5500 + 6,Frank,40,Finance,8000 + 7,Grace,26,HR,5200 + 8,Henry,32,IT,6200 + 9,Ivy,24,Marketing,4800 + 10,Jack,38,Finance,7500"; + let data_bytes = Bytes::from(data.to_vec()); + let path = Path::from(context.input.key.clone()); + store.put(&path, data_bytes.into()).await.map_err(|e| { + error!("put data into memory failed: {}", e.to_string()); + QueryError::StoreError { e: e.to_string() } + })?; + + df_session_state.with_object_store(&store_url, Arc::new(store)).build() + } else { + let store = + EcObjectStore::new(context.input.clone()).map_err(|_| QueryError::NotImplemented { err: String::new() })?; + df_session_state.with_object_store(&store_url, Arc::new(store)).build() + }; + let df_session_ctx = SessionContext::new_with_state(df_session_state); Ok(df_session_ctx) diff --git a/s3select/query/src/dispatcher/manager.rs b/s3select/query/src/dispatcher/manager.rs index 3975c4e50..4abc4cec2 100644 --- a/s3select/query/src/dispatcher/manager.rs +++ b/s3select/query/src/dispatcher/manager.rs @@ -98,7 +98,7 @@ impl QueryDispatcher for SimpleQueryDispatcher { } async fn build_query_state_machine(&self, query: Query) -> QueryResult> { - let session = self.session_factory.create_session_ctx(query.context())?; + let session = self.session_factory.create_session_ctx(query.context()).await?; let query_state_machine = Arc::new(QueryStateMachine::begin(query, session)); Ok(query_state_machine) diff --git a/s3select/query/src/instance.rs b/s3select/query/src/instance.rs index 9f4b601b6..a0b645ced 100644 --- a/s3select/query/src/instance.rs +++ b/s3select/query/src/instance.rs @@ -63,11 +63,11 @@ where } } -pub async fn make_cnosdbms(input: SelectObjectContentInput) -> QueryResult { +pub async fn make_cnosdbms(input: SelectObjectContentInput, is_test: bool) -> QueryResult { // init Function Manager, we can define some UDF if need let func_manager = SimpleFunctionMetadataManager::default(); // TODO session config need load global system config - let session_factory = Arc::new(SessionCtxFactory {}); + let session_factory = Arc::new(SessionCtxFactory { is_test }); let parser = Arc::new(DefaultParser::default()); let optimizer = Arc::new(CascadeOptimizerBuilder::default().build()); // TODO wrap, and num_threads configurable @@ -92,3 +92,73 @@ pub async fn make_cnosdbms(input: SelectObjectContentInput) -> QueryResult Date: Mon, 31 Mar 2025 06:32:05 +0000 Subject: [PATCH 033/103] rebase to main Signed-off-by: junxiang Mu <1948535941@qq.com> --- Cargo.lock | 2 + Cargo.toml | 1 + .../generated/flatbuffers_generated/models.rs | 207 +- .../src/generated/proto_gen/node_service.rs | 3836 +++++++++++++---- rustfs/Cargo.toml | 2 +- rustfs/src/storage/ecfs.rs | 2 - s3select/api/Cargo.toml | 2 + s3select/api/src/object_store.rs | 53 +- 8 files changed, 3202 insertions(+), 903 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ba596d60..8dbf614de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,7 +194,9 @@ dependencies = [ "s3s", "snafu", "tokio", + "tokio-util", "tracing", + "transform-stream", "url", ] diff --git a/Cargo.toml b/Cargo.toml index 28d28347c..adae86503 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,6 +99,7 @@ tonic = { version = "0.12.3", features = ["gzip"] } tonic-build = "0.12.3" tonic-reflection = "0.12" tokio-stream = "0.1.17" +tokio-util = { version = "0.7.13", features = ["io", "compat"] } tower = { version = "0.5.2", features = ["timeout"] } tracing = "0.1.41" tracing-error = "0.2.1" diff --git a/common/protos/src/generated/flatbuffers_generated/models.rs b/common/protos/src/generated/flatbuffers_generated/models.rs index e4949fdcf..aa1f6ae2f 100644 --- a/common/protos/src/generated/flatbuffers_generated/models.rs +++ b/common/protos/src/generated/flatbuffers_generated/models.rs @@ -1,9 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify + // @generated -use core::cmp::Ordering; use core::mem; +use core::cmp::Ordering; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -11,114 +12,112 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod models { - use core::cmp::Ordering; - use core::mem; + use core::mem; + use core::cmp::Ordering; - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; - pub enum PingBodyOffset {} - #[derive(Copy, Clone, PartialEq)] +pub enum PingBodyOffset {} +#[derive(Copy, Clone, PartialEq)] - pub struct PingBody<'a> { - pub _tab: flatbuffers::Table<'a>, +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: 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> { + let mut builder = PingBodyBuilder::new(_fbb); + if let Some(x) = args.payload { builder.add_payload(x); } + builder.finish() + } + + + #[inline] + pub fn payload(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? + .finish(); + Ok(()) + } +} +pub struct PingBodyArgs<'a> { + pub payload: Option>>, +} +impl<'a> Default for PingBodyArgs<'a> { + #[inline] + fn default() -> Self { + PingBodyArgs { + payload: None, } + } +} - 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: flatbuffers::Table::new(buf, loc), - } - } +pub struct PingBodyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { + #[inline] + pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::>(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> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} - impl<'a> PingBody<'a> { - pub const VT_PAYLOAD: flatbuffers::VOffsetT = 4; +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 - 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> { - let mut builder = PingBodyBuilder::new(_fbb); - if let Some(x) = args.payload { - builder.add_payload(x); - } - builder.finish() - } - - #[inline] - pub fn payload(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { - self._tab - .get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? - .finish(); - Ok(()) - } - } - pub struct PingBodyArgs<'a> { - pub payload: Option>>, - } - 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, - } - impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { - #[inline] - pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { - self.fbb_ - .push_slot_always::>(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> { - 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 diff --git a/common/protos/src/generated/proto_gen/node_service.rs b/common/protos/src/generated/proto_gen/node_service.rs index 000d5b486..88f7b3ab0 100644 --- a/common/protos/src/generated/proto_gen/node_service.rs +++ b/common/protos/src/generated/proto_gen/node_service.rs @@ -622,7 +622,10 @@ pub struct GenerallyLockResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct Mss { #[prost(map = "string, string", tag = "1")] - pub value: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + pub value: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::string::String, + >, } #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LocalStorageInfoRequest { @@ -786,7 +789,10 @@ pub struct DownloadProfileDataResponse { #[prost(bool, tag = "1")] pub success: bool, #[prost(map = "string, bytes", tag = "2")] - pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec>, + pub data: ::std::collections::HashMap< + ::prost::alloc::string::String, + ::prost::alloc::vec::Vec, + >, #[prost(string, optional, tag = "3")] pub error_info: ::core::option::Option<::prost::alloc::string::String>, } @@ -1053,9 +1059,15 @@ pub struct LoadTransitionTierConfigResponse { } /// Generated client implementations. pub mod node_service_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] - use tonic::codegen::http::Uri; + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct NodeServiceClient { inner: tonic::client::Grpc, @@ -1086,16 +1098,22 @@ pub mod node_service_client { let inner = tonic::client::Grpc::with_origin(inner, origin); Self { inner } } - pub fn with_interceptor(inner: T, interceptor: F) -> NodeServiceClient> + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> NodeServiceClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, - Response = http::Response<>::ResponseBody>, + Response = http::Response< + >::ResponseBody, + >, >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, { NodeServiceClient::new(InterceptedService::new(inner, interceptor)) } @@ -1138,9 +1156,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Ping"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Ping", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Ping")); @@ -1149,13 +1173,22 @@ pub mod node_service_client { pub async fn heal_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/HealBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/HealBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "HealBucket")); @@ -1164,13 +1197,22 @@ pub mod node_service_client { pub async fn list_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ListBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListBucket")); @@ -1179,13 +1221,22 @@ pub mod node_service_client { pub async fn make_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/MakeBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeBucket")); @@ -1194,13 +1245,22 @@ pub mod node_service_client { pub async fn get_bucket_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetBucketInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketInfo")); @@ -1209,13 +1269,22 @@ pub mod node_service_client { pub async fn delete_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucket"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteBucket", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucket")); @@ -1224,13 +1293,22 @@ pub mod node_service_client { pub async fn read_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAll"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadAll", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAll")); @@ -1239,13 +1317,22 @@ pub mod node_service_client { pub async fn write_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteAll"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WriteAll", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteAll")); @@ -1258,9 +1345,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Delete"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Delete", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Delete")); @@ -1269,13 +1362,22 @@ pub mod node_service_client { pub async fn verify_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/VerifyFile"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/VerifyFile", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "VerifyFile")); @@ -1284,13 +1386,22 @@ pub mod node_service_client { pub async fn check_parts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/CheckParts"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/CheckParts", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "CheckParts")); @@ -1299,13 +1410,22 @@ pub mod node_service_client { pub async fn rename_part( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenamePart"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RenamePart", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenamePart")); @@ -1314,13 +1434,22 @@ pub mod node_service_client { pub async fn rename_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameFile"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RenameFile", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameFile")); @@ -1333,9 +1462,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Write"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Write", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Write")); @@ -1344,13 +1479,22 @@ pub mod node_service_client { pub async fn write_stream( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteStream"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WriteStream", + ); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteStream")); @@ -1360,13 +1504,22 @@ pub mod node_service_client { pub async fn read_at( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAt"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadAt", + ); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAt")); @@ -1375,13 +1528,22 @@ pub mod node_service_client { pub async fn list_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListDir"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ListDir", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListDir")); @@ -1390,13 +1552,22 @@ pub mod node_service_client { pub async fn walk_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WalkDir"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WalkDir", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WalkDir")); @@ -1405,13 +1576,22 @@ pub mod node_service_client { pub async fn rename_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameData"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RenameData", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameData")); @@ -1420,13 +1600,22 @@ pub mod node_service_client { pub async fn make_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolumes"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/MakeVolumes", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolumes")); @@ -1435,13 +1624,22 @@ pub mod node_service_client { pub async fn make_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolume"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/MakeVolume", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolume")); @@ -1450,13 +1648,22 @@ pub mod node_service_client { pub async fn list_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListVolumes"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ListVolumes", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListVolumes")); @@ -1465,13 +1672,22 @@ pub mod node_service_client { pub async fn stat_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StatVolume"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/StatVolume", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StatVolume")); @@ -1480,13 +1696,22 @@ pub mod node_service_client { pub async fn delete_paths( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePaths"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeletePaths", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePaths")); @@ -1495,13 +1720,22 @@ pub mod node_service_client { pub async fn update_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/UpdateMetadata", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetadata")); @@ -1510,13 +1744,22 @@ pub mod node_service_client { pub async fn write_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/WriteMetadata", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteMetadata")); @@ -1525,13 +1768,22 @@ pub mod node_service_client { pub async fn read_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadVersion"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadVersion", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadVersion")); @@ -1544,9 +1796,15 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadXL"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadXL", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadXL")); @@ -1555,13 +1813,22 @@ pub mod node_service_client { pub async fn delete_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersion"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteVersion", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersion")); @@ -1570,13 +1837,22 @@ pub mod node_service_client { pub async fn delete_versions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersions"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteVersions", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersions")); @@ -1585,13 +1861,22 @@ pub mod node_service_client { pub async fn read_multiple( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadMultiple"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReadMultiple", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadMultiple")); @@ -1600,13 +1885,22 @@ pub mod node_service_client { pub async fn delete_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVolume"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteVolume", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVolume")); @@ -1615,13 +1909,22 @@ pub mod node_service_client { pub async fn disk_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DiskInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DiskInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DiskInfo")); @@ -1630,13 +1933,22 @@ pub mod node_service_client { pub async fn ns_scanner( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result>, tonic::Status> { + ) -> std::result::Result< + tonic::Response>, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/NsScanner"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/NsScanner", + ); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "NsScanner")); @@ -1645,13 +1957,22 @@ pub mod node_service_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Lock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Lock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Lock")); @@ -1660,13 +1981,22 @@ pub mod node_service_client { pub async fn un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UnLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/UnLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UnLock")); @@ -1675,13 +2005,22 @@ pub mod node_service_client { pub async fn r_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RLock")); @@ -1690,13 +2029,22 @@ pub mod node_service_client { pub async fn r_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RUnLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/RUnLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RUnLock")); @@ -1705,13 +2053,22 @@ pub mod node_service_client { pub async fn force_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ForceUnLock"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ForceUnLock", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ForceUnLock")); @@ -1720,13 +2077,22 @@ pub mod node_service_client { pub async fn refresh( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Refresh"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/Refresh", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Refresh")); @@ -1735,13 +2101,22 @@ pub mod node_service_client { pub async fn local_storage_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LocalStorageInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LocalStorageInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LocalStorageInfo")); @@ -1750,13 +2125,22 @@ pub mod node_service_client { pub async fn server_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ServerInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ServerInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ServerInfo")); @@ -1765,13 +2149,22 @@ pub mod node_service_client { pub async fn get_cpus( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetCpus"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetCpus", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetCpus")); @@ -1780,13 +2173,22 @@ pub mod node_service_client { pub async fn get_net_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetNetInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetNetInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetNetInfo")); @@ -1795,13 +2197,22 @@ pub mod node_service_client { pub async fn get_partitions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetPartitions"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetPartitions", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetPartitions")); @@ -1810,13 +2221,22 @@ pub mod node_service_client { pub async fn get_os_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetOsInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetOsInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetOsInfo")); @@ -1825,13 +2245,22 @@ pub mod node_service_client { pub async fn get_se_linux_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSELinuxInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSELinuxInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSELinuxInfo")); @@ -1840,13 +2269,22 @@ pub mod node_service_client { pub async fn get_sys_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysConfig"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSysConfig", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysConfig")); @@ -1855,13 +2293,22 @@ pub mod node_service_client { pub async fn get_sys_errors( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysErrors"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSysErrors", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysErrors")); @@ -1870,13 +2317,22 @@ pub mod node_service_client { pub async fn get_mem_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMemInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetMemInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMemInfo")); @@ -1885,13 +2341,22 @@ pub mod node_service_client { pub async fn get_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetrics"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetMetrics", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMetrics")); @@ -1900,13 +2365,22 @@ pub mod node_service_client { pub async fn get_proc_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetProcInfo"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetProcInfo", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetProcInfo")); @@ -1915,13 +2389,22 @@ pub mod node_service_client { pub async fn start_profiling( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StartProfiling"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/StartProfiling", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StartProfiling")); @@ -1930,28 +2413,48 @@ pub mod node_service_client { pub async fn download_profile_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DownloadProfileData"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DownloadProfileData", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "DownloadProfileData")); + .insert( + GrpcMethod::new("node_service.NodeService", "DownloadProfileData"), + ); self.inner.unary(req, path, codec).await } pub async fn get_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketStats"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetBucketStats", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketStats")); @@ -1960,13 +2463,22 @@ pub mod node_service_client { pub async fn get_sr_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSRMetrics"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetSRMetrics", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSRMetrics")); @@ -1975,58 +2487,100 @@ pub mod node_service_client { pub async fn get_all_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetAllBucketStats"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetAllBucketStats", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "GetAllBucketStats")); + .insert( + GrpcMethod::new("node_service.NodeService", "GetAllBucketStats"), + ); self.inner.unary(req, path, codec).await } pub async fn load_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadBucketMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadBucketMetadata", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata"), + ); self.inner.unary(req, path, codec).await } pub async fn delete_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucketMetadata"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteBucketMetadata", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata")); + .insert( + GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata"), + ); self.inner.unary(req, path, codec).await } pub async fn delete_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePolicy"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeletePolicy", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePolicy")); @@ -2035,13 +2589,22 @@ pub mod node_service_client { pub async fn load_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicy"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadPolicy", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicy")); @@ -2050,28 +2613,48 @@ pub mod node_service_client { pub async fn load_policy_mapping( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicyMapping"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadPolicyMapping", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping"), + ); self.inner.unary(req, path, codec).await } pub async fn delete_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteUser"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteUser", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteUser")); @@ -2080,28 +2663,48 @@ pub mod node_service_client { pub async fn delete_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteServiceAccount"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/DeleteServiceAccount", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount")); + .insert( + GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount"), + ); self.inner.unary(req, path, codec).await } pub async fn load_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadUser"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadUser", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadUser")); @@ -2110,28 +2713,48 @@ pub mod node_service_client { pub async fn load_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadServiceAccount"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadServiceAccount", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadServiceAccount")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadServiceAccount"), + ); self.inner.unary(req, path, codec).await } pub async fn load_group( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadGroup"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadGroup", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadGroup")); @@ -2140,16 +2763,30 @@ pub mod node_service_client { pub async fn reload_site_replication_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadSiteReplicationConfig"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReloadSiteReplicationConfig", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "ReloadSiteReplicationConfig")); + .insert( + GrpcMethod::new( + "node_service.NodeService", + "ReloadSiteReplicationConfig", + ), + ); self.inner.unary(req, path, codec).await } /// rpc VerifyBinary() returns () {}; @@ -2157,13 +2794,22 @@ pub mod node_service_client { pub async fn signal_service( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/SignalService"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/SignalService", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "SignalService")); @@ -2172,58 +2818,100 @@ pub mod node_service_client { pub async fn background_heal_status( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/BackgroundHealStatus"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/BackgroundHealStatus", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus")); + .insert( + GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus"), + ); self.inner.unary(req, path, codec).await } pub async fn get_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetacacheListing"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/GetMetacacheListing", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "GetMetacacheListing")); + .insert( + GrpcMethod::new("node_service.NodeService", "GetMetacacheListing"), + ); self.inner.unary(req, path, codec).await } pub async fn update_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetacacheListing"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/UpdateMetacacheListing", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing")); + .insert( + GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing"), + ); self.inner.unary(req, path, codec).await } pub async fn reload_pool_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadPoolMeta"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/ReloadPoolMeta", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReloadPoolMeta")); @@ -2232,13 +2920,22 @@ pub mod node_service_client { pub async fn stop_rebalance( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StopRebalance"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/StopRebalance", + ); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StopRebalance")); @@ -2247,38 +2944,69 @@ pub mod node_service_client { pub async fn load_rebalance_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadRebalanceMeta"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadRebalanceMeta", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta")); + .insert( + GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta"), + ); self.inner.unary(req, path, codec).await } pub async fn load_transition_tier_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await - .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadTransitionTierConfig"); + let path = http::uri::PathAndQuery::from_static( + "/node_service.NodeService/LoadTransitionTierConfig", + ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("node_service.NodeService", "LoadTransitionTierConfig")); + .insert( + GrpcMethod::new( + "node_service.NodeService", + "LoadTransitionTierConfig", + ), + ); self.inner.unary(req, path, codec).await } } } /// Generated server implementations. pub mod node_service_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with NodeServiceServer. #[async_trait] @@ -2291,23 +3019,38 @@ pub mod node_service_server { async fn heal_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn list_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn make_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_bucket_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_bucket( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_all( &self, request: tonic::Request, @@ -2315,7 +3058,10 @@ pub mod node_service_server { async fn write_all( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete( &self, request: tonic::Request, @@ -2323,33 +3069,52 @@ pub mod node_service_server { async fn verify_file( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn check_parts( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn rename_part( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn rename_file( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn write( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WriteStream method. - type WriteStreamStream: tonic::codegen::tokio_stream::Stream> + type WriteStreamStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; async fn write_stream( &self, request: tonic::Request>, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Server streaming response type for the ReadAt method. - type ReadAtStream: tonic::codegen::tokio_stream::Stream> + type ReadAtStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; /// rpc Append(AppendRequest) returns (AppendResponse) {}; @@ -2362,7 +3127,9 @@ pub mod node_service_server { request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WalkDir method. - type WalkDirStream: tonic::codegen::tokio_stream::Stream> + type WalkDirStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; async fn walk_dir( @@ -2372,39 +3139,66 @@ pub mod node_service_server { async fn rename_data( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn make_volumes( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn make_volume( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn list_volumes( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn stat_volume( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_paths( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn update_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn write_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_version( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_xl( &self, request: tonic::Request, @@ -2412,25 +3206,42 @@ pub mod node_service_server { async fn delete_version( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_versions( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn read_multiple( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_volume( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn disk_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// Server streaming response type for the NsScanner method. - type NsScannerStream: tonic::codegen::tokio_stream::Stream> + type NsScannerStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + std::marker::Send + 'static; async fn ns_scanner( @@ -2440,35 +3251,59 @@ pub mod node_service_server { async fn lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn un_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn r_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn r_un_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn force_un_lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn refresh( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn local_storage_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn server_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_cpus( &self, request: tonic::Request, @@ -2476,137 +3311,236 @@ pub mod node_service_server { async fn get_net_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_partitions( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_os_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_se_linux_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_sys_config( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_sys_errors( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_mem_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_metrics( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_proc_info( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn start_profiling( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn download_profile_data( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_sr_metrics( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_all_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_policy( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_policy( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_policy_mapping( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_user( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn delete_service_account( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_user( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_service_account( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_group( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn reload_site_replication_config( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; /// rpc VerifyBinary() returns () {}; /// rpc CommitBinary() returns () {}; async fn signal_service( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn background_heal_status( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn get_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn update_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn reload_pool_meta( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn stop_rebalance( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_rebalance_meta( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn load_transition_tier_config( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct NodeServiceServer { @@ -2629,7 +3563,10 @@ pub mod node_service_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -2673,7 +3610,10 @@ pub mod node_service_server { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; - fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -2681,12 +3621,21 @@ pub mod node_service_server { "/node_service.NodeService/Ping" => { #[allow(non_camel_case_types)] struct PingSvc(pub Arc); - impl tonic::server::UnaryService for PingSvc { + impl tonic::server::UnaryService + for PingSvc { type Response = super::PingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::ping(&inner, request).await }; + let fut = async move { + ::ping(&inner, request).await + }; Box::pin(fut) } } @@ -2699,8 +3648,14 @@ pub mod node_service_server { let method = PingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2709,12 +3664,23 @@ pub mod node_service_server { "/node_service.NodeService/HealBucket" => { #[allow(non_camel_case_types)] struct HealBucketSvc(pub Arc); - impl tonic::server::UnaryService for HealBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for HealBucketSvc { type Response = super::HealBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::heal_bucket(&inner, request).await }; + let fut = async move { + ::heal_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2727,8 +3693,14 @@ pub mod node_service_server { let method = HealBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2737,12 +3709,23 @@ pub mod node_service_server { "/node_service.NodeService/ListBucket" => { #[allow(non_camel_case_types)] struct ListBucketSvc(pub Arc); - impl tonic::server::UnaryService for ListBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ListBucketSvc { type Response = super::ListBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::list_bucket(&inner, request).await }; + let fut = async move { + ::list_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2755,8 +3738,14 @@ pub mod node_service_server { let method = ListBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2765,12 +3754,23 @@ pub mod node_service_server { "/node_service.NodeService/MakeBucket" => { #[allow(non_camel_case_types)] struct MakeBucketSvc(pub Arc); - impl tonic::server::UnaryService for MakeBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for MakeBucketSvc { type Response = super::MakeBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::make_bucket(&inner, request).await }; + let fut = async move { + ::make_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2783,8 +3783,14 @@ pub mod node_service_server { let method = MakeBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2793,12 +3799,23 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketInfo" => { #[allow(non_camel_case_types)] struct GetBucketInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetBucketInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetBucketInfoSvc { type Response = super::GetBucketInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_bucket_info(&inner, request).await }; + let fut = async move { + ::get_bucket_info(&inner, request).await + }; Box::pin(fut) } } @@ -2811,8 +3828,14 @@ pub mod node_service_server { let method = GetBucketInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2821,12 +3844,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucket" => { #[allow(non_camel_case_types)] struct DeleteBucketSvc(pub Arc); - impl tonic::server::UnaryService for DeleteBucketSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteBucketSvc { type Response = super::DeleteBucketResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_bucket(&inner, request).await }; + let fut = async move { + ::delete_bucket(&inner, request).await + }; Box::pin(fut) } } @@ -2839,8 +3873,14 @@ pub mod node_service_server { let method = DeleteBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2849,12 +3889,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadAll" => { #[allow(non_camel_case_types)] struct ReadAllSvc(pub Arc); - impl tonic::server::UnaryService for ReadAllSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadAllSvc { type Response = super::ReadAllResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_all(&inner, request).await }; + let fut = async move { + ::read_all(&inner, request).await + }; Box::pin(fut) } } @@ -2867,8 +3918,14 @@ pub mod node_service_server { let method = ReadAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2877,12 +3934,23 @@ pub mod node_service_server { "/node_service.NodeService/WriteAll" => { #[allow(non_camel_case_types)] struct WriteAllSvc(pub Arc); - impl tonic::server::UnaryService for WriteAllSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for WriteAllSvc { type Response = super::WriteAllResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write_all(&inner, request).await }; + let fut = async move { + ::write_all(&inner, request).await + }; Box::pin(fut) } } @@ -2895,8 +3963,14 @@ pub mod node_service_server { let method = WriteAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2905,12 +3979,23 @@ pub mod node_service_server { "/node_service.NodeService/Delete" => { #[allow(non_camel_case_types)] struct DeleteSvc(pub Arc); - impl tonic::server::UnaryService for DeleteSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteSvc { type Response = super::DeleteResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete(&inner, request).await }; + let fut = async move { + ::delete(&inner, request).await + }; Box::pin(fut) } } @@ -2923,8 +4008,14 @@ pub mod node_service_server { let method = DeleteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2933,12 +4024,23 @@ pub mod node_service_server { "/node_service.NodeService/VerifyFile" => { #[allow(non_camel_case_types)] struct VerifyFileSvc(pub Arc); - impl tonic::server::UnaryService for VerifyFileSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for VerifyFileSvc { type Response = super::VerifyFileResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::verify_file(&inner, request).await }; + let fut = async move { + ::verify_file(&inner, request).await + }; Box::pin(fut) } } @@ -2951,8 +4053,14 @@ pub mod node_service_server { let method = VerifyFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2961,12 +4069,23 @@ pub mod node_service_server { "/node_service.NodeService/CheckParts" => { #[allow(non_camel_case_types)] struct CheckPartsSvc(pub Arc); - impl tonic::server::UnaryService for CheckPartsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for CheckPartsSvc { type Response = super::CheckPartsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::check_parts(&inner, request).await }; + let fut = async move { + ::check_parts(&inner, request).await + }; Box::pin(fut) } } @@ -2979,8 +4098,14 @@ pub mod node_service_server { let method = CheckPartsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -2989,12 +4114,23 @@ pub mod node_service_server { "/node_service.NodeService/RenamePart" => { #[allow(non_camel_case_types)] struct RenamePartSvc(pub Arc); - impl tonic::server::UnaryService for RenamePartSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RenamePartSvc { type Response = super::RenamePartResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::rename_part(&inner, request).await }; + let fut = async move { + ::rename_part(&inner, request).await + }; Box::pin(fut) } } @@ -3007,8 +4143,14 @@ pub mod node_service_server { let method = RenamePartSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3017,12 +4159,23 @@ pub mod node_service_server { "/node_service.NodeService/RenameFile" => { #[allow(non_camel_case_types)] struct RenameFileSvc(pub Arc); - impl tonic::server::UnaryService for RenameFileSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RenameFileSvc { type Response = super::RenameFileResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::rename_file(&inner, request).await }; + let fut = async move { + ::rename_file(&inner, request).await + }; Box::pin(fut) } } @@ -3035,8 +4188,14 @@ pub mod node_service_server { let method = RenameFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3045,12 +4204,21 @@ pub mod node_service_server { "/node_service.NodeService/Write" => { #[allow(non_camel_case_types)] struct WriteSvc(pub Arc); - impl tonic::server::UnaryService for WriteSvc { + impl tonic::server::UnaryService + for WriteSvc { type Response = super::WriteResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write(&inner, request).await }; + let fut = async move { + ::write(&inner, request).await + }; Box::pin(fut) } } @@ -3063,8 +4231,14 @@ pub mod node_service_server { let method = WriteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3073,13 +4247,26 @@ pub mod node_service_server { "/node_service.NodeService/WriteStream" => { #[allow(non_camel_case_types)] struct WriteStreamSvc(pub Arc); - impl tonic::server::StreamingService for WriteStreamSvc { + impl< + T: NodeService, + > tonic::server::StreamingService + for WriteStreamSvc { type Response = super::WriteResponse; type ResponseStream = T::WriteStreamStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request>) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write_stream(&inner, request).await }; + let fut = async move { + ::write_stream(&inner, request).await + }; Box::pin(fut) } } @@ -3092,8 +4279,14 @@ pub mod node_service_server { let method = WriteStreamSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -3102,13 +4295,26 @@ pub mod node_service_server { "/node_service.NodeService/ReadAt" => { #[allow(non_camel_case_types)] struct ReadAtSvc(pub Arc); - impl tonic::server::StreamingService for ReadAtSvc { + impl< + T: NodeService, + > tonic::server::StreamingService + for ReadAtSvc { type Response = super::ReadAtResponse; type ResponseStream = T::ReadAtStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request>) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_at(&inner, request).await }; + let fut = async move { + ::read_at(&inner, request).await + }; Box::pin(fut) } } @@ -3121,8 +4327,14 @@ pub mod node_service_server { let method = ReadAtSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -3131,12 +4343,23 @@ pub mod node_service_server { "/node_service.NodeService/ListDir" => { #[allow(non_camel_case_types)] struct ListDirSvc(pub Arc); - impl tonic::server::UnaryService for ListDirSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ListDirSvc { type Response = super::ListDirResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::list_dir(&inner, request).await }; + let fut = async move { + ::list_dir(&inner, request).await + }; Box::pin(fut) } } @@ -3149,8 +4372,14 @@ pub mod node_service_server { let method = ListDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3159,13 +4388,24 @@ pub mod node_service_server { "/node_service.NodeService/WalkDir" => { #[allow(non_camel_case_types)] struct WalkDirSvc(pub Arc); - impl tonic::server::ServerStreamingService for WalkDirSvc { + impl< + T: NodeService, + > tonic::server::ServerStreamingService + for WalkDirSvc { type Response = super::WalkDirResponse; type ResponseStream = T::WalkDirStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::walk_dir(&inner, request).await }; + let fut = async move { + ::walk_dir(&inner, request).await + }; Box::pin(fut) } } @@ -3178,8 +4418,14 @@ pub mod node_service_server { let method = WalkDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.server_streaming(method, req).await; Ok(res) }; @@ -3188,12 +4434,23 @@ pub mod node_service_server { "/node_service.NodeService/RenameData" => { #[allow(non_camel_case_types)] struct RenameDataSvc(pub Arc); - impl tonic::server::UnaryService for RenameDataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RenameDataSvc { type Response = super::RenameDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::rename_data(&inner, request).await }; + let fut = async move { + ::rename_data(&inner, request).await + }; Box::pin(fut) } } @@ -3206,8 +4463,14 @@ pub mod node_service_server { let method = RenameDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3216,12 +4479,23 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolumes" => { #[allow(non_camel_case_types)] struct MakeVolumesSvc(pub Arc); - impl tonic::server::UnaryService for MakeVolumesSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for MakeVolumesSvc { type Response = super::MakeVolumesResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::make_volumes(&inner, request).await }; + let fut = async move { + ::make_volumes(&inner, request).await + }; Box::pin(fut) } } @@ -3234,8 +4508,14 @@ pub mod node_service_server { let method = MakeVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3244,12 +4524,23 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolume" => { #[allow(non_camel_case_types)] struct MakeVolumeSvc(pub Arc); - impl tonic::server::UnaryService for MakeVolumeSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for MakeVolumeSvc { type Response = super::MakeVolumeResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::make_volume(&inner, request).await }; + let fut = async move { + ::make_volume(&inner, request).await + }; Box::pin(fut) } } @@ -3262,8 +4553,14 @@ pub mod node_service_server { let method = MakeVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3272,12 +4569,23 @@ pub mod node_service_server { "/node_service.NodeService/ListVolumes" => { #[allow(non_camel_case_types)] struct ListVolumesSvc(pub Arc); - impl tonic::server::UnaryService for ListVolumesSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ListVolumesSvc { type Response = super::ListVolumesResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::list_volumes(&inner, request).await }; + let fut = async move { + ::list_volumes(&inner, request).await + }; Box::pin(fut) } } @@ -3290,8 +4598,14 @@ pub mod node_service_server { let method = ListVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3300,12 +4614,23 @@ pub mod node_service_server { "/node_service.NodeService/StatVolume" => { #[allow(non_camel_case_types)] struct StatVolumeSvc(pub Arc); - impl tonic::server::UnaryService for StatVolumeSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for StatVolumeSvc { type Response = super::StatVolumeResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::stat_volume(&inner, request).await }; + let fut = async move { + ::stat_volume(&inner, request).await + }; Box::pin(fut) } } @@ -3318,8 +4643,14 @@ pub mod node_service_server { let method = StatVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3328,12 +4659,23 @@ pub mod node_service_server { "/node_service.NodeService/DeletePaths" => { #[allow(non_camel_case_types)] struct DeletePathsSvc(pub Arc); - impl tonic::server::UnaryService for DeletePathsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeletePathsSvc { type Response = super::DeletePathsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_paths(&inner, request).await }; + let fut = async move { + ::delete_paths(&inner, request).await + }; Box::pin(fut) } } @@ -3346,8 +4688,14 @@ pub mod node_service_server { let method = DeletePathsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3356,12 +4704,23 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetadata" => { #[allow(non_camel_case_types)] struct UpdateMetadataSvc(pub Arc); - impl tonic::server::UnaryService for UpdateMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for UpdateMetadataSvc { type Response = super::UpdateMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::update_metadata(&inner, request).await }; + let fut = async move { + ::update_metadata(&inner, request).await + }; Box::pin(fut) } } @@ -3374,8 +4733,14 @@ pub mod node_service_server { let method = UpdateMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3384,12 +4749,23 @@ pub mod node_service_server { "/node_service.NodeService/WriteMetadata" => { #[allow(non_camel_case_types)] struct WriteMetadataSvc(pub Arc); - impl tonic::server::UnaryService for WriteMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for WriteMetadataSvc { type Response = super::WriteMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::write_metadata(&inner, request).await }; + let fut = async move { + ::write_metadata(&inner, request).await + }; Box::pin(fut) } } @@ -3402,8 +4778,14 @@ pub mod node_service_server { let method = WriteMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3412,12 +4794,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadVersion" => { #[allow(non_camel_case_types)] struct ReadVersionSvc(pub Arc); - impl tonic::server::UnaryService for ReadVersionSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadVersionSvc { type Response = super::ReadVersionResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_version(&inner, request).await }; + let fut = async move { + ::read_version(&inner, request).await + }; Box::pin(fut) } } @@ -3430,8 +4823,14 @@ pub mod node_service_server { let method = ReadVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3440,12 +4839,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadXL" => { #[allow(non_camel_case_types)] struct ReadXLSvc(pub Arc); - impl tonic::server::UnaryService for ReadXLSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadXLSvc { type Response = super::ReadXlResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_xl(&inner, request).await }; + let fut = async move { + ::read_xl(&inner, request).await + }; Box::pin(fut) } } @@ -3458,8 +4868,14 @@ pub mod node_service_server { let method = ReadXLSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3468,12 +4884,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersion" => { #[allow(non_camel_case_types)] struct DeleteVersionSvc(pub Arc); - impl tonic::server::UnaryService for DeleteVersionSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteVersionSvc { type Response = super::DeleteVersionResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_version(&inner, request).await }; + let fut = async move { + ::delete_version(&inner, request).await + }; Box::pin(fut) } } @@ -3486,8 +4913,14 @@ pub mod node_service_server { let method = DeleteVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3496,12 +4929,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersions" => { #[allow(non_camel_case_types)] struct DeleteVersionsSvc(pub Arc); - impl tonic::server::UnaryService for DeleteVersionsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteVersionsSvc { type Response = super::DeleteVersionsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_versions(&inner, request).await }; + let fut = async move { + ::delete_versions(&inner, request).await + }; Box::pin(fut) } } @@ -3514,8 +4958,14 @@ pub mod node_service_server { let method = DeleteVersionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3524,12 +4974,23 @@ pub mod node_service_server { "/node_service.NodeService/ReadMultiple" => { #[allow(non_camel_case_types)] struct ReadMultipleSvc(pub Arc); - impl tonic::server::UnaryService for ReadMultipleSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReadMultipleSvc { type Response = super::ReadMultipleResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::read_multiple(&inner, request).await }; + let fut = async move { + ::read_multiple(&inner, request).await + }; Box::pin(fut) } } @@ -3542,8 +5003,14 @@ pub mod node_service_server { let method = ReadMultipleSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3552,12 +5019,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVolume" => { #[allow(non_camel_case_types)] struct DeleteVolumeSvc(pub Arc); - impl tonic::server::UnaryService for DeleteVolumeSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteVolumeSvc { type Response = super::DeleteVolumeResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_volume(&inner, request).await }; + let fut = async move { + ::delete_volume(&inner, request).await + }; Box::pin(fut) } } @@ -3570,8 +5048,14 @@ pub mod node_service_server { let method = DeleteVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3580,12 +5064,23 @@ pub mod node_service_server { "/node_service.NodeService/DiskInfo" => { #[allow(non_camel_case_types)] struct DiskInfoSvc(pub Arc); - impl tonic::server::UnaryService for DiskInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DiskInfoSvc { type Response = super::DiskInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::disk_info(&inner, request).await }; + let fut = async move { + ::disk_info(&inner, request).await + }; Box::pin(fut) } } @@ -3598,8 +5093,14 @@ pub mod node_service_server { let method = DiskInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3608,13 +5109,26 @@ pub mod node_service_server { "/node_service.NodeService/NsScanner" => { #[allow(non_camel_case_types)] struct NsScannerSvc(pub Arc); - impl tonic::server::StreamingService for NsScannerSvc { + impl< + T: NodeService, + > tonic::server::StreamingService + for NsScannerSvc { type Response = super::NsScannerResponse; type ResponseStream = T::NsScannerStream; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request>) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + tonic::Streaming, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::ns_scanner(&inner, request).await }; + let fut = async move { + ::ns_scanner(&inner, request).await + }; Box::pin(fut) } } @@ -3627,8 +5141,14 @@ pub mod node_service_server { let method = NsScannerSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -3637,12 +5157,23 @@ pub mod node_service_server { "/node_service.NodeService/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl tonic::server::UnaryService for LockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::lock(&inner, request).await }; + let fut = async move { + ::lock(&inner, request).await + }; Box::pin(fut) } } @@ -3655,8 +5186,14 @@ pub mod node_service_server { let method = LockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3665,12 +5202,23 @@ pub mod node_service_server { "/node_service.NodeService/UnLock" => { #[allow(non_camel_case_types)] struct UnLockSvc(pub Arc); - impl tonic::server::UnaryService for UnLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for UnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::un_lock(&inner, request).await }; + let fut = async move { + ::un_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3683,8 +5231,14 @@ pub mod node_service_server { let method = UnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3693,12 +5247,23 @@ pub mod node_service_server { "/node_service.NodeService/RLock" => { #[allow(non_camel_case_types)] struct RLockSvc(pub Arc); - impl tonic::server::UnaryService for RLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::r_lock(&inner, request).await }; + let fut = async move { + ::r_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3711,8 +5276,14 @@ pub mod node_service_server { let method = RLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3721,12 +5292,23 @@ pub mod node_service_server { "/node_service.NodeService/RUnLock" => { #[allow(non_camel_case_types)] struct RUnLockSvc(pub Arc); - impl tonic::server::UnaryService for RUnLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::r_un_lock(&inner, request).await }; + let fut = async move { + ::r_un_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3739,8 +5321,14 @@ pub mod node_service_server { let method = RUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3749,12 +5337,23 @@ pub mod node_service_server { "/node_service.NodeService/ForceUnLock" => { #[allow(non_camel_case_types)] struct ForceUnLockSvc(pub Arc); - impl tonic::server::UnaryService for ForceUnLockSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ForceUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::force_un_lock(&inner, request).await }; + let fut = async move { + ::force_un_lock(&inner, request).await + }; Box::pin(fut) } } @@ -3767,8 +5366,14 @@ pub mod node_service_server { let method = ForceUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3777,12 +5382,23 @@ pub mod node_service_server { "/node_service.NodeService/Refresh" => { #[allow(non_camel_case_types)] struct RefreshSvc(pub Arc); - impl tonic::server::UnaryService for RefreshSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for RefreshSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::refresh(&inner, request).await }; + let fut = async move { + ::refresh(&inner, request).await + }; Box::pin(fut) } } @@ -3795,8 +5411,14 @@ pub mod node_service_server { let method = RefreshSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3805,12 +5427,24 @@ pub mod node_service_server { "/node_service.NodeService/LocalStorageInfo" => { #[allow(non_camel_case_types)] struct LocalStorageInfoSvc(pub Arc); - impl tonic::server::UnaryService for LocalStorageInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LocalStorageInfoSvc { type Response = super::LocalStorageInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::local_storage_info(&inner, request).await }; + let fut = async move { + ::local_storage_info(&inner, request) + .await + }; Box::pin(fut) } } @@ -3823,8 +5457,14 @@ pub mod node_service_server { let method = LocalStorageInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3833,12 +5473,23 @@ pub mod node_service_server { "/node_service.NodeService/ServerInfo" => { #[allow(non_camel_case_types)] struct ServerInfoSvc(pub Arc); - impl tonic::server::UnaryService for ServerInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ServerInfoSvc { type Response = super::ServerInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::server_info(&inner, request).await }; + let fut = async move { + ::server_info(&inner, request).await + }; Box::pin(fut) } } @@ -3851,8 +5502,14 @@ pub mod node_service_server { let method = ServerInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3861,12 +5518,23 @@ pub mod node_service_server { "/node_service.NodeService/GetCpus" => { #[allow(non_camel_case_types)] struct GetCpusSvc(pub Arc); - impl tonic::server::UnaryService for GetCpusSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetCpusSvc { type Response = super::GetCpusResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_cpus(&inner, request).await }; + let fut = async move { + ::get_cpus(&inner, request).await + }; Box::pin(fut) } } @@ -3879,8 +5547,14 @@ pub mod node_service_server { let method = GetCpusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3889,12 +5563,23 @@ pub mod node_service_server { "/node_service.NodeService/GetNetInfo" => { #[allow(non_camel_case_types)] struct GetNetInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetNetInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetNetInfoSvc { type Response = super::GetNetInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_net_info(&inner, request).await }; + let fut = async move { + ::get_net_info(&inner, request).await + }; Box::pin(fut) } } @@ -3907,8 +5592,14 @@ pub mod node_service_server { let method = GetNetInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3917,12 +5608,23 @@ pub mod node_service_server { "/node_service.NodeService/GetPartitions" => { #[allow(non_camel_case_types)] struct GetPartitionsSvc(pub Arc); - impl tonic::server::UnaryService for GetPartitionsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetPartitionsSvc { type Response = super::GetPartitionsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_partitions(&inner, request).await }; + let fut = async move { + ::get_partitions(&inner, request).await + }; Box::pin(fut) } } @@ -3935,8 +5637,14 @@ pub mod node_service_server { let method = GetPartitionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3945,12 +5653,23 @@ pub mod node_service_server { "/node_service.NodeService/GetOsInfo" => { #[allow(non_camel_case_types)] struct GetOsInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetOsInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetOsInfoSvc { type Response = super::GetOsInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_os_info(&inner, request).await }; + let fut = async move { + ::get_os_info(&inner, request).await + }; Box::pin(fut) } } @@ -3963,8 +5682,14 @@ pub mod node_service_server { let method = GetOsInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3973,12 +5698,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSELinuxInfo" => { #[allow(non_camel_case_types)] struct GetSELinuxInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetSELinuxInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSELinuxInfoSvc { type Response = super::GetSeLinuxInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_se_linux_info(&inner, request).await }; + let fut = async move { + ::get_se_linux_info(&inner, request).await + }; Box::pin(fut) } } @@ -3991,8 +5727,14 @@ pub mod node_service_server { let method = GetSELinuxInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4001,12 +5743,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSysConfig" => { #[allow(non_camel_case_types)] struct GetSysConfigSvc(pub Arc); - impl tonic::server::UnaryService for GetSysConfigSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSysConfigSvc { type Response = super::GetSysConfigResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_sys_config(&inner, request).await }; + let fut = async move { + ::get_sys_config(&inner, request).await + }; Box::pin(fut) } } @@ -4019,8 +5772,14 @@ pub mod node_service_server { let method = GetSysConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4029,12 +5788,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSysErrors" => { #[allow(non_camel_case_types)] struct GetSysErrorsSvc(pub Arc); - impl tonic::server::UnaryService for GetSysErrorsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSysErrorsSvc { type Response = super::GetSysErrorsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_sys_errors(&inner, request).await }; + let fut = async move { + ::get_sys_errors(&inner, request).await + }; Box::pin(fut) } } @@ -4047,8 +5817,14 @@ pub mod node_service_server { let method = GetSysErrorsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4057,12 +5833,23 @@ pub mod node_service_server { "/node_service.NodeService/GetMemInfo" => { #[allow(non_camel_case_types)] struct GetMemInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetMemInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetMemInfoSvc { type Response = super::GetMemInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_mem_info(&inner, request).await }; + let fut = async move { + ::get_mem_info(&inner, request).await + }; Box::pin(fut) } } @@ -4075,8 +5862,14 @@ pub mod node_service_server { let method = GetMemInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4085,12 +5878,23 @@ pub mod node_service_server { "/node_service.NodeService/GetMetrics" => { #[allow(non_camel_case_types)] struct GetMetricsSvc(pub Arc); - impl tonic::server::UnaryService for GetMetricsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetMetricsSvc { type Response = super::GetMetricsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_metrics(&inner, request).await }; + let fut = async move { + ::get_metrics(&inner, request).await + }; Box::pin(fut) } } @@ -4103,8 +5907,14 @@ pub mod node_service_server { let method = GetMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4113,12 +5923,23 @@ pub mod node_service_server { "/node_service.NodeService/GetProcInfo" => { #[allow(non_camel_case_types)] struct GetProcInfoSvc(pub Arc); - impl tonic::server::UnaryService for GetProcInfoSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetProcInfoSvc { type Response = super::GetProcInfoResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_proc_info(&inner, request).await }; + let fut = async move { + ::get_proc_info(&inner, request).await + }; Box::pin(fut) } } @@ -4131,8 +5952,14 @@ pub mod node_service_server { let method = GetProcInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4141,12 +5968,23 @@ pub mod node_service_server { "/node_service.NodeService/StartProfiling" => { #[allow(non_camel_case_types)] struct StartProfilingSvc(pub Arc); - impl tonic::server::UnaryService for StartProfilingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for StartProfilingSvc { type Response = super::StartProfilingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::start_profiling(&inner, request).await }; + let fut = async move { + ::start_profiling(&inner, request).await + }; Box::pin(fut) } } @@ -4159,8 +5997,14 @@ pub mod node_service_server { let method = StartProfilingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4169,12 +6013,24 @@ pub mod node_service_server { "/node_service.NodeService/DownloadProfileData" => { #[allow(non_camel_case_types)] struct DownloadProfileDataSvc(pub Arc); - impl tonic::server::UnaryService for DownloadProfileDataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DownloadProfileDataSvc { type Response = super::DownloadProfileDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::download_profile_data(&inner, request).await }; + let fut = async move { + ::download_profile_data(&inner, request) + .await + }; Box::pin(fut) } } @@ -4187,8 +6043,14 @@ pub mod node_service_server { let method = DownloadProfileDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4197,12 +6059,23 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketStats" => { #[allow(non_camel_case_types)] struct GetBucketStatsSvc(pub Arc); - impl tonic::server::UnaryService for GetBucketStatsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetBucketStatsSvc { type Response = super::GetBucketStatsDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_bucket_stats(&inner, request).await }; + let fut = async move { + ::get_bucket_stats(&inner, request).await + }; Box::pin(fut) } } @@ -4215,8 +6088,14 @@ pub mod node_service_server { let method = GetBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4225,12 +6104,23 @@ pub mod node_service_server { "/node_service.NodeService/GetSRMetrics" => { #[allow(non_camel_case_types)] struct GetSRMetricsSvc(pub Arc); - impl tonic::server::UnaryService for GetSRMetricsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetSRMetricsSvc { type Response = super::GetSrMetricsDataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_sr_metrics(&inner, request).await }; + let fut = async move { + ::get_sr_metrics(&inner, request).await + }; Box::pin(fut) } } @@ -4243,8 +6133,14 @@ pub mod node_service_server { let method = GetSRMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4253,12 +6149,24 @@ pub mod node_service_server { "/node_service.NodeService/GetAllBucketStats" => { #[allow(non_camel_case_types)] struct GetAllBucketStatsSvc(pub Arc); - impl tonic::server::UnaryService for GetAllBucketStatsSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetAllBucketStatsSvc { type Response = super::GetAllBucketStatsResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_all_bucket_stats(&inner, request).await }; + let fut = async move { + ::get_all_bucket_stats(&inner, request) + .await + }; Box::pin(fut) } } @@ -4271,8 +6179,14 @@ pub mod node_service_server { let method = GetAllBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4281,12 +6195,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadBucketMetadata" => { #[allow(non_camel_case_types)] struct LoadBucketMetadataSvc(pub Arc); - impl tonic::server::UnaryService for LoadBucketMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadBucketMetadataSvc { type Response = super::LoadBucketMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_bucket_metadata(&inner, request).await }; + let fut = async move { + ::load_bucket_metadata(&inner, request) + .await + }; Box::pin(fut) } } @@ -4299,8 +6225,14 @@ pub mod node_service_server { let method = LoadBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4309,12 +6241,24 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucketMetadata" => { #[allow(non_camel_case_types)] struct DeleteBucketMetadataSvc(pub Arc); - impl tonic::server::UnaryService for DeleteBucketMetadataSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteBucketMetadataSvc { type Response = super::DeleteBucketMetadataResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_bucket_metadata(&inner, request).await }; + let fut = async move { + ::delete_bucket_metadata(&inner, request) + .await + }; Box::pin(fut) } } @@ -4327,8 +6271,14 @@ pub mod node_service_server { let method = DeleteBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4337,12 +6287,23 @@ pub mod node_service_server { "/node_service.NodeService/DeletePolicy" => { #[allow(non_camel_case_types)] struct DeletePolicySvc(pub Arc); - impl tonic::server::UnaryService for DeletePolicySvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeletePolicySvc { type Response = super::DeletePolicyResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_policy(&inner, request).await }; + let fut = async move { + ::delete_policy(&inner, request).await + }; Box::pin(fut) } } @@ -4355,8 +6316,14 @@ pub mod node_service_server { let method = DeletePolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4365,12 +6332,23 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicy" => { #[allow(non_camel_case_types)] struct LoadPolicySvc(pub Arc); - impl tonic::server::UnaryService for LoadPolicySvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadPolicySvc { type Response = super::LoadPolicyResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_policy(&inner, request).await }; + let fut = async move { + ::load_policy(&inner, request).await + }; Box::pin(fut) } } @@ -4383,8 +6361,14 @@ pub mod node_service_server { let method = LoadPolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4393,12 +6377,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicyMapping" => { #[allow(non_camel_case_types)] struct LoadPolicyMappingSvc(pub Arc); - impl tonic::server::UnaryService for LoadPolicyMappingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadPolicyMappingSvc { type Response = super::LoadPolicyMappingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_policy_mapping(&inner, request).await }; + let fut = async move { + ::load_policy_mapping(&inner, request) + .await + }; Box::pin(fut) } } @@ -4411,8 +6407,14 @@ pub mod node_service_server { let method = LoadPolicyMappingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4421,12 +6423,23 @@ pub mod node_service_server { "/node_service.NodeService/DeleteUser" => { #[allow(non_camel_case_types)] struct DeleteUserSvc(pub Arc); - impl tonic::server::UnaryService for DeleteUserSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteUserSvc { type Response = super::DeleteUserResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_user(&inner, request).await }; + let fut = async move { + ::delete_user(&inner, request).await + }; Box::pin(fut) } } @@ -4439,8 +6452,14 @@ pub mod node_service_server { let method = DeleteUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4449,12 +6468,24 @@ pub mod node_service_server { "/node_service.NodeService/DeleteServiceAccount" => { #[allow(non_camel_case_types)] struct DeleteServiceAccountSvc(pub Arc); - impl tonic::server::UnaryService for DeleteServiceAccountSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for DeleteServiceAccountSvc { type Response = super::DeleteServiceAccountResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::delete_service_account(&inner, request).await }; + let fut = async move { + ::delete_service_account(&inner, request) + .await + }; Box::pin(fut) } } @@ -4467,8 +6498,14 @@ pub mod node_service_server { let method = DeleteServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4477,12 +6514,23 @@ pub mod node_service_server { "/node_service.NodeService/LoadUser" => { #[allow(non_camel_case_types)] struct LoadUserSvc(pub Arc); - impl tonic::server::UnaryService for LoadUserSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadUserSvc { type Response = super::LoadUserResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_user(&inner, request).await }; + let fut = async move { + ::load_user(&inner, request).await + }; Box::pin(fut) } } @@ -4495,8 +6543,14 @@ pub mod node_service_server { let method = LoadUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4505,12 +6559,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadServiceAccount" => { #[allow(non_camel_case_types)] struct LoadServiceAccountSvc(pub Arc); - impl tonic::server::UnaryService for LoadServiceAccountSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadServiceAccountSvc { type Response = super::LoadServiceAccountResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_service_account(&inner, request).await }; + let fut = async move { + ::load_service_account(&inner, request) + .await + }; Box::pin(fut) } } @@ -4523,8 +6589,14 @@ pub mod node_service_server { let method = LoadServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4533,12 +6605,23 @@ pub mod node_service_server { "/node_service.NodeService/LoadGroup" => { #[allow(non_camel_case_types)] struct LoadGroupSvc(pub Arc); - impl tonic::server::UnaryService for LoadGroupSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadGroupSvc { type Response = super::LoadGroupResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_group(&inner, request).await }; + let fut = async move { + ::load_group(&inner, request).await + }; Box::pin(fut) } } @@ -4551,8 +6634,14 @@ pub mod node_service_server { let method = LoadGroupSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4561,14 +6650,30 @@ pub mod node_service_server { "/node_service.NodeService/ReloadSiteReplicationConfig" => { #[allow(non_camel_case_types)] struct ReloadSiteReplicationConfigSvc(pub Arc); - impl tonic::server::UnaryService - for ReloadSiteReplicationConfigSvc - { + impl< + T: NodeService, + > tonic::server::UnaryService< + super::ReloadSiteReplicationConfigRequest, + > for ReloadSiteReplicationConfigSvc { type Response = super::ReloadSiteReplicationConfigResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::ReloadSiteReplicationConfigRequest, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::reload_site_replication_config(&inner, request).await }; + let fut = async move { + ::reload_site_replication_config( + &inner, + request, + ) + .await + }; Box::pin(fut) } } @@ -4581,8 +6686,14 @@ pub mod node_service_server { let method = ReloadSiteReplicationConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4591,12 +6702,23 @@ pub mod node_service_server { "/node_service.NodeService/SignalService" => { #[allow(non_camel_case_types)] struct SignalServiceSvc(pub Arc); - impl tonic::server::UnaryService for SignalServiceSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for SignalServiceSvc { type Response = super::SignalServiceResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::signal_service(&inner, request).await }; + let fut = async move { + ::signal_service(&inner, request).await + }; Box::pin(fut) } } @@ -4609,8 +6731,14 @@ pub mod node_service_server { let method = SignalServiceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4619,12 +6747,24 @@ pub mod node_service_server { "/node_service.NodeService/BackgroundHealStatus" => { #[allow(non_camel_case_types)] struct BackgroundHealStatusSvc(pub Arc); - impl tonic::server::UnaryService for BackgroundHealStatusSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for BackgroundHealStatusSvc { type Response = super::BackgroundHealStatusResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::background_heal_status(&inner, request).await }; + let fut = async move { + ::background_heal_status(&inner, request) + .await + }; Box::pin(fut) } } @@ -4637,8 +6777,14 @@ pub mod node_service_server { let method = BackgroundHealStatusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4647,12 +6793,24 @@ pub mod node_service_server { "/node_service.NodeService/GetMetacacheListing" => { #[allow(non_camel_case_types)] struct GetMetacacheListingSvc(pub Arc); - impl tonic::server::UnaryService for GetMetacacheListingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for GetMetacacheListingSvc { type Response = super::GetMetacacheListingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::get_metacache_listing(&inner, request).await }; + let fut = async move { + ::get_metacache_listing(&inner, request) + .await + }; Box::pin(fut) } } @@ -4665,8 +6823,14 @@ pub mod node_service_server { let method = GetMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4675,12 +6839,27 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetacacheListing" => { #[allow(non_camel_case_types)] struct UpdateMetacacheListingSvc(pub Arc); - impl tonic::server::UnaryService for UpdateMetacacheListingSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for UpdateMetacacheListingSvc { type Response = super::UpdateMetacacheListingResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::update_metacache_listing(&inner, request).await }; + let fut = async move { + ::update_metacache_listing( + &inner, + request, + ) + .await + }; Box::pin(fut) } } @@ -4693,8 +6872,14 @@ pub mod node_service_server { let method = UpdateMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4703,12 +6888,23 @@ pub mod node_service_server { "/node_service.NodeService/ReloadPoolMeta" => { #[allow(non_camel_case_types)] struct ReloadPoolMetaSvc(pub Arc); - impl tonic::server::UnaryService for ReloadPoolMetaSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for ReloadPoolMetaSvc { type Response = super::ReloadPoolMetaResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::reload_pool_meta(&inner, request).await }; + let fut = async move { + ::reload_pool_meta(&inner, request).await + }; Box::pin(fut) } } @@ -4721,8 +6917,14 @@ pub mod node_service_server { let method = ReloadPoolMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4731,12 +6933,23 @@ pub mod node_service_server { "/node_service.NodeService/StopRebalance" => { #[allow(non_camel_case_types)] struct StopRebalanceSvc(pub Arc); - impl tonic::server::UnaryService for StopRebalanceSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for StopRebalanceSvc { type Response = super::StopRebalanceResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::stop_rebalance(&inner, request).await }; + let fut = async move { + ::stop_rebalance(&inner, request).await + }; Box::pin(fut) } } @@ -4749,8 +6962,14 @@ pub mod node_service_server { let method = StopRebalanceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4759,12 +6978,24 @@ pub mod node_service_server { "/node_service.NodeService/LoadRebalanceMeta" => { #[allow(non_camel_case_types)] struct LoadRebalanceMetaSvc(pub Arc); - impl tonic::server::UnaryService for LoadRebalanceMetaSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadRebalanceMetaSvc { type Response = super::LoadRebalanceMetaResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_rebalance_meta(&inner, request).await }; + let fut = async move { + ::load_rebalance_meta(&inner, request) + .await + }; Box::pin(fut) } } @@ -4777,8 +7008,14 @@ pub mod node_service_server { let method = LoadRebalanceMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4787,12 +7024,29 @@ pub mod node_service_server { "/node_service.NodeService/LoadTransitionTierConfig" => { #[allow(non_camel_case_types)] struct LoadTransitionTierConfigSvc(pub Arc); - impl tonic::server::UnaryService for LoadTransitionTierConfigSvc { + impl< + T: NodeService, + > tonic::server::UnaryService + for LoadTransitionTierConfigSvc { type Response = super::LoadTransitionTierConfigResponse; - type Future = BoxFuture, tonic::Status>; - fn call(&mut self, request: tonic::Request) -> Self::Future { + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request< + super::LoadTransitionTierConfigRequest, + >, + ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::load_transition_tier_config(&inner, request).await }; + let fut = async move { + ::load_transition_tier_config( + &inner, + request, + ) + .await + }; Box::pin(fut) } } @@ -4805,20 +7059,36 @@ pub mod node_service_server { let method = LoadTransitionTierConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config(accept_compression_encodings, send_compression_encodings) - .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert(tonic::Status::GRPC_STATUS, (tonic::Code::Unimplemented as i32).into()); - headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index fea12acba..493971d00 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -47,7 +47,7 @@ serde.workspace = true serde_json.workspace = true tracing.workspace = true time = { workspace = true, features = ["parsing", "formatting", "serde"] } -tokio-util = { version = "0.7.13", features = ["io", "compat"] } +tokio-util.workspace = true tokio = { workspace = true, features = [ "rt-multi-thread", "macros", diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 928a154ae..228127329 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -45,8 +45,6 @@ use ecstore::xhttp; use futures::pin_mut; use futures::{Stream, StreamExt}; use http::HeaderMap; -use iam::policy::action::Action; -use iam::policy::action::S3Action; use lazy_static::lazy_static; use log::warn; use policy::auth; diff --git a/s3select/api/Cargo.toml b/s3select/api/Cargo.toml index 0f147396c..1936e846a 100644 --- a/s3select/api/Cargo.toml +++ b/s3select/api/Cargo.toml @@ -16,5 +16,7 @@ object_store = "0.11.2" s3s.workspace = true snafu = { workspace = true, features = ["backtrace"] } tokio.workspace = true +tokio-util.workspace = true tracing.workspace = true +transform-stream.workspace = true url.workspace = true \ No newline at end of file diff --git a/s3select/api/src/object_store.rs b/s3select/api/src/object_store.rs index bb9273cdf..7772936ce 100644 --- a/s3select/api/src/object_store.rs +++ b/s3select/api/src/object_store.rs @@ -1,13 +1,14 @@ use async_trait::async_trait; use bytes::Bytes; use chrono::Utc; +use ecstore::io::READ_BUFFER_SIZE; use ecstore::new_object_layer_fn; use ecstore::store::ECStore; use ecstore::store_api::ObjectIO; use ecstore::store_api::ObjectOptions; use ecstore::StorageAPI; -use futures::stream; -use futures::StreamExt; +use futures::pin_mut; +use futures::{Stream, StreamExt}; use futures_core::stream::BoxStream; use http::HeaderMap; use object_store::path::Path; @@ -28,7 +29,9 @@ use s3s::s3_error; use s3s::S3Result; use std::ops::Range; use std::sync::Arc; +use tokio_util::io::ReaderStream; use tracing::info; +use transform_stream::AsyncTryStream; #[derive(Debug)] pub struct EcObjectStore { @@ -76,16 +79,16 @@ impl ObjectStore for EcObjectStore { source: "can not get object info".into(), })?; - let stream = stream::unfold(reader.stream, |mut blob| async move { - match blob.next().await { - Some(Ok(chunk)) => { - let bytes = chunk; - Some((Ok(bytes), blob)) - } - _ => None, - } - }) - .boxed(); + // let stream = stream::unfold(reader.stream, |mut blob| async move { + // match blob.next().await { + // Some(Ok(chunk)) => { + // let bytes = chunk; + // Some((Ok(bytes), blob)) + // } + // _ => None, + // } + // }) + // .boxed(); let meta = ObjectMeta { location: location.clone(), last_modified: Utc::now(), @@ -96,7 +99,9 @@ impl ObjectStore for EcObjectStore { let attributes = Attributes::default(); Ok(GetResult { - payload: object_store::GetResultPayload::Stream(stream), + payload: object_store::GetResultPayload::Stream( + bytes_stream(ReaderStream::with_capacity(reader.stream, READ_BUFFER_SIZE), reader.object_info.size).boxed(), + ), meta, range: 0..reader.object_info.size, attributes, @@ -148,3 +153,25 @@ impl ObjectStore for EcObjectStore { unimplemented!() } } + +pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static +where + S: Stream> + Send + 'static, +{ + AsyncTryStream::::new(|mut y| async move { + pin_mut!(stream); + let mut remaining: usize = content_length; + while let Some(result) = stream.next().await { + let mut bytes = result.map_err(|e| o_Error::Generic { + store: "", + source: Box::new(e), + })?; + if bytes.len() > remaining { + bytes.truncate(remaining); + } + remaining -= bytes.len(); + y.yield_ok(bytes).await; + } + Ok(()) + }) +} From 0598183f4fc8c6c5eba7cb88809b573a6967c582 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Mon, 31 Mar 2025 06:34:56 +0000 Subject: [PATCH 034/103] rename func Signed-off-by: junxiang Mu <1948535941@qq.com> --- rustfs/src/storage/ecfs.rs | 4 ++-- s3select/query/src/instance.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 228127329..1fc410cb9 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -53,7 +53,7 @@ use policy::policy::action::S3Action; use policy::policy::BucketPolicy; use policy::policy::BucketPolicyArgs; use policy::policy::Validator; -use query::instance::make_cnosdbms; +use query::instance::make_rustfsms; use s3s::dto::*; use s3s::s3_error; use s3s::S3Error; @@ -1878,7 +1878,7 @@ impl S3 for FS { let input = req.input; info!("{:?}", input); - let db = make_cnosdbms(input.clone(), false).await.map_err(|e| { + let db = make_rustfsms(input.clone(), false).await.map_err(|e| { error!("make db failed, {}", e.to_string()); s3_error!(InternalError) })?; diff --git a/s3select/query/src/instance.rs b/s3select/query/src/instance.rs index a0b645ced..03cc7b037 100644 --- a/s3select/query/src/instance.rs +++ b/s3select/query/src/instance.rs @@ -63,7 +63,7 @@ where } } -pub async fn make_cnosdbms(input: SelectObjectContentInput, is_test: bool) -> QueryResult { +pub async fn make_rustfsms(input: SelectObjectContentInput, is_test: bool) -> QueryResult { // init Function Manager, we can define some UDF if need let func_manager = SimpleFunctionMetadataManager::default(); // TODO session config need load global system config @@ -105,7 +105,7 @@ mod tests { SelectObjectContentRequest, }; - use crate::instance::make_cnosdbms; + use crate::instance::make_rustfsms; #[tokio::test] #[ignore] @@ -133,7 +133,7 @@ mod tests { scan_range: None, }, }; - let db = make_cnosdbms(input.clone(), true).await.unwrap(); + let db = make_rustfsms(input.clone(), true).await.unwrap(); let query = Query::new(Context { input }, sql.to_string()); let result = db.execute(&query).await.unwrap(); From 96cc708b5b2c0af7bfabfc5b413c9863704631ed Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 31 Mar 2025 16:32:22 +0800 Subject: [PATCH 035/103] upgrade reqwest version from 0.12.12 to 0.12.15 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 665a4d7ce..29f07cb48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ protobuf = "3.7" protos = { path = "./common/protos" } rand = "0.8.5" rdkafka = { version = "0.37", features = ["tokio"] } -reqwest = { version = "0.12.12", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream", "json", "blocking"] } +reqwest = { version = "0.12.15", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream", "json", "blocking"] } rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } rmp = "0.8.14" rmp-serde = "1.3.0" From f2692b78dd36a2803ead3e713f3f6429ed96c97d Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 31 Mar 2025 18:32:22 +0800 Subject: [PATCH 036/103] TryInto cover --- Cargo.toml | 2 +- ecstore/src/heal/data_scanner.rs | 24 +++++++++--------------- ecstore/src/heal/data_usage_cache.rs | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 29f07cb48..342c1ea5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,7 +100,7 @@ serde_json = "1.0.138" sha2 = "0.10.8" tempfile = "3.16.0" thiserror = "2.0.12" -time = { version = "0.3.37", features = [ +time = { version = "0.3.41", features = [ "std", "parsing", "formatting", diff --git a/ecstore/src/heal/data_scanner.rs b/ecstore/src/heal/data_scanner.rs index 52ded12a2..6701f7ba8 100644 --- a/ecstore/src/heal/data_scanner.rs +++ b/ecstore/src/heal/data_scanner.rs @@ -352,7 +352,7 @@ impl CurrentScannerCycle { let str_len = rmp::decode::read_str_len(&mut cur)?; - // !!! Vec::with_capacity(str_len) 失败,vec!正常 + // !!!Vec::with_capacity(str_len) 失败,vec! 正常 let mut field_buff = vec![0u8; str_len as usize]; cur.read_exact(&mut field_buff)?; @@ -435,7 +435,7 @@ impl ScannerItem { pub async fn apply_versions_actions(&self, fivs: &[FileInfo]) -> Result> { let obj_infos = self.apply_newer_noncurrent_version_limit(fivs).await?; - if obj_infos.len() >= SCANNER_EXCESS_OBJECT_VERSIONS.load(Ordering::SeqCst).try_into().unwrap() { + if obj_infos.len() >= >::try_into(SCANNER_EXCESS_OBJECT_VERSIONS.load(Ordering::SeqCst)).unwrap() { // todo } @@ -445,10 +445,7 @@ impl ScannerItem { } if cumulative_size - >= SCANNER_EXCESS_OBJECT_VERSIONS_TOTAL_SIZE - .load(Ordering::SeqCst) - .try_into() - .unwrap() + >= >::try_into(SCANNER_EXCESS_OBJECT_VERSIONS_TOTAL_SIZE.load(Ordering::SeqCst)).unwrap() { //todo } @@ -684,16 +681,13 @@ impl FolderScanner { } let should_compact = self.new_cache.info.name != folder.name - && existing_folders.len() + new_folders.len() >= DATA_SCANNER_COMPACT_AT_FOLDERS.try_into().unwrap() - || existing_folders.len() + new_folders.len() >= DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS.try_into().unwrap(); + && existing_folders.len() + new_folders.len() + >= >::try_into(DATA_SCANNER_COMPACT_AT_FOLDERS).unwrap() + || existing_folders.len() + new_folders.len() + >= >::try_into(DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS).unwrap(); let total_folders = existing_folders.len() + new_folders.len(); - if total_folders - > SCANNER_EXCESS_FOLDERS - .load(std::sync::atomic::Ordering::SeqCst) - .try_into() - .unwrap() - { + if total_folders > >::try_into(SCANNER_EXCESS_FOLDERS.load(Ordering::SeqCst)).unwrap() { let _prefix_name = format!("{}/", folder.name.trim_end_matches('/')); // todo: notification } @@ -957,7 +951,7 @@ impl FolderScanner { if !into.compacted && self.new_cache.info.name != folder.name { let mut flat = self.new_cache.size_recursive(&this_hash.key()).unwrap_or_default(); flat.compacted = true; - let compact = if flat.objects < DATA_SCANNER_COMPACT_LEAST_OBJECT.try_into().unwrap() { + let compact = if flat.objects < >::try_into(DATA_SCANNER_COMPACT_LEAST_OBJECT).unwrap() { true } else { // Compact if we only have objects as children... diff --git a/ecstore/src/heal/data_usage_cache.rs b/ecstore/src/heal/data_usage_cache.rs index 7bc33df81..9111d2a7f 100644 --- a/ecstore/src/heal/data_usage_cache.rs +++ b/ecstore/src/heal/data_usage_cache.rs @@ -588,7 +588,7 @@ impl DataUsageCache { Some(e) => e, None => return, }; - if top_e.children.len() > DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS.try_into().unwrap() { + if top_e.children.len() > >::try_into(DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS).unwrap() { self.reduce_children_of(&hash_path(&self.info.name), limit, true); } if self.cache.len() <= limit { From 9bdc96de8c9c510d82323d4a31073922f92fb99e Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Tue, 1 Apr 2025 03:52:12 +0000 Subject: [PATCH 037/103] support func Signed-off-by: junxiang Mu <1948535941@qq.com> --- s3select/api/src/query/function.rs | 11 ++-- s3select/query/src/dispatcher/manager.rs | 2 +- .../query/src/function/simple_func_manager.rs | 60 ++++++++++++++--- s3select/query/src/instance.rs | 64 ++++++++++++++----- s3select/query/src/metadata/mod.rs | 6 +- 5 files changed, 110 insertions(+), 33 deletions(-) diff --git a/s3select/api/src/query/function.rs b/s3select/api/src/query/function.rs index af207fc15..3a8c67619 100644 --- a/s3select/api/src/query/function.rs +++ b/s3select/api/src/query/function.rs @@ -1,4 +1,3 @@ -use std::collections::HashSet; use std::sync::Arc; use datafusion::logical_expr::{AggregateUDF, ScalarUDF, WindowUDF}; @@ -7,11 +6,11 @@ use crate::QueryResult; pub type FuncMetaManagerRef = Arc; pub trait FunctionMetadataManager { - fn register_udf(&mut self, udf: ScalarUDF) -> QueryResult<()>; + fn register_udf(&mut self, udf: Arc) -> QueryResult<()>; - fn register_udaf(&mut self, udaf: AggregateUDF) -> QueryResult<()>; + fn register_udaf(&mut self, udaf: Arc) -> QueryResult<()>; - fn register_udwf(&mut self, udwf: WindowUDF) -> QueryResult<()>; + fn register_udwf(&mut self, udwf: Arc) -> QueryResult<()>; fn udf(&self, name: &str) -> QueryResult>; @@ -19,5 +18,7 @@ pub trait FunctionMetadataManager { fn udwf(&self, name: &str) -> QueryResult>; - fn udfs(&self) -> HashSet; + fn udfs(&self) -> Vec; + fn udafs(&self) -> Vec; + fn udwfs(&self) -> Vec; } diff --git a/s3select/query/src/dispatcher/manager.rs b/s3select/query/src/dispatcher/manager.rs index 4abc4cec2..e85e7a543 100644 --- a/s3select/query/src/dispatcher/manager.rs +++ b/s3select/query/src/dispatcher/manager.rs @@ -139,7 +139,7 @@ impl SimpleQueryDispatcher { let path = format!("s3://{}/{}", self.input.bucket, self.input.key); let table_path = ListingTableUrl::parse(path)?; let listing_options = if self.input.request.input_serialization.csv.is_some() { - let file_format = CsvFormat::default().with_options(CsvOptions::default().with_has_header(false)); + let file_format = CsvFormat::default().with_options(CsvOptions::default().with_has_header(true)); ListingOptions::new(Arc::new(file_format)).with_file_extension(".csv") } else if self.input.request.input_serialization.parquet.is_some() { let file_format = ParquetFormat::new(); diff --git a/s3select/query/src/function/simple_func_manager.rs b/s3select/query/src/function/simple_func_manager.rs index 129efacff..bb3d3852d 100644 --- a/s3select/query/src/function/simple_func_manager.rs +++ b/s3select/query/src/function/simple_func_manager.rs @@ -1,13 +1,15 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::sync::Arc; use api::query::function::FunctionMetadataManager; use api::{QueryError, QueryResult}; +use datafusion::execution::SessionStateDefaults; use datafusion::logical_expr::{AggregateUDF, ScalarUDF, WindowUDF}; +use tracing::debug; pub type SimpleFunctionMetadataManagerRef = Arc; -#[derive(Debug, Default)] +#[derive(Debug)] pub struct SimpleFunctionMetadataManager { /// Scalar functions that are registered with the context pub scalar_functions: HashMap>, @@ -17,19 +19,53 @@ pub struct SimpleFunctionMetadataManager { pub window_functions: HashMap>, } +impl Default for SimpleFunctionMetadataManager { + fn default() -> Self { + let mut func_meta_manager = Self { + scalar_functions: Default::default(), + aggregate_functions: Default::default(), + window_functions: Default::default(), + }; + SessionStateDefaults::default_scalar_functions().into_iter().for_each(|udf| { + let existing_udf = func_meta_manager.register_udf(udf.clone()); + if let Ok(()) = existing_udf { + debug!("Overwrote an existing UDF: {}", udf.name()); + } + }); + + SessionStateDefaults::default_aggregate_functions() + .into_iter() + .for_each(|udaf| { + let existing_udaf = func_meta_manager.register_udaf(udaf.clone()); + if let Ok(()) = existing_udaf { + debug!("Overwrote an existing UDAF: {}", udaf.name()); + } + }); + + SessionStateDefaults::default_window_functions().into_iter().for_each(|udwf| { + let existing_udwf = func_meta_manager.register_udwf(udwf.clone()); + if let Ok(()) = existing_udwf { + debug!("Overwrote an existing UDWF: {}", udwf.name()); + } + }); + + func_meta_manager + } +} + impl FunctionMetadataManager for SimpleFunctionMetadataManager { - fn register_udf(&mut self, f: ScalarUDF) -> QueryResult<()> { - self.scalar_functions.insert(f.inner().name().to_uppercase(), Arc::new(f)); + fn register_udf(&mut self, f: Arc) -> QueryResult<()> { + self.scalar_functions.insert(f.inner().name().to_uppercase(), f); Ok(()) } - fn register_udaf(&mut self, f: AggregateUDF) -> QueryResult<()> { - self.aggregate_functions.insert(f.inner().name().to_uppercase(), Arc::new(f)); + fn register_udaf(&mut self, f: Arc) -> QueryResult<()> { + self.aggregate_functions.insert(f.inner().name().to_uppercase(), f); Ok(()) } - fn register_udwf(&mut self, f: WindowUDF) -> QueryResult<()> { - self.window_functions.insert(f.inner().name().to_uppercase(), Arc::new(f)); + fn register_udwf(&mut self, f: Arc) -> QueryResult<()> { + self.window_functions.insert(f.inner().name().to_uppercase(), f); Ok(()) } @@ -57,7 +93,13 @@ impl FunctionMetadataManager for SimpleFunctionMetadataManager { .ok_or_else(|| QueryError::FunctionNotExists { name: name.to_string() }) } - fn udfs(&self) -> HashSet { + fn udfs(&self) -> Vec { self.scalar_functions.keys().cloned().collect() } + fn udafs(&self) -> Vec { + self.aggregate_functions.keys().cloned().collect() + } + fn udwfs(&self) -> Vec { + self.window_functions.keys().cloned().collect() + } } diff --git a/s3select/query/src/instance.rs b/s3select/query/src/instance.rs index 03cc7b037..3ad8941a8 100644 --- a/s3select/query/src/instance.rs +++ b/s3select/query/src/instance.rs @@ -141,24 +141,58 @@ mod tests { let results = result.result().chunk_result().await.unwrap().to_vec(); let expected = [ - "+----------------+----------+----------+------------+----------+", - "| column_1 | column_2 | column_3 | column_4 | column_5 |", - "+----------------+----------+----------+------------+----------+", - "| id | name | age | department | salary |", - "| 1 | Alice | 25 | HR | 5000 |", - "| 2 | Bob | 30 | IT | 6000 |", - "| 3 | Charlie | 35 | Finance | 7000 |", - "| 4 | Diana | 22 | Marketing | 4500 |", - "| 5 | Eve | 28 | IT | 5500 |", - "| 6 | Frank | 40 | Finance | 8000 |", - "| 7 | Grace | 26 | HR | 5200 |", - "| 8 | Henry | 32 | IT | 6200 |", - "| 9 | Ivy | 24 | Marketing | 4800 |", - "| 10 | Jack | 38 | Finance | 7500 |", - "+----------------+----------+----------+------------+----------+", + "+----------------+---------+-----+------------+--------+", + "| id | name | age | department | salary |", + "+----------------+---------+-----+------------+--------+", + "| 1 | Alice | 25 | HR | 5000 |", + "| 2 | Bob | 30 | IT | 6000 |", + "| 3 | Charlie | 35 | Finance | 7000 |", + "| 4 | Diana | 22 | Marketing | 4500 |", + "| 5 | Eve | 28 | IT | 5500 |", + "| 6 | Frank | 40 | Finance | 8000 |", + "| 7 | Grace | 26 | HR | 5200 |", + "| 8 | Henry | 32 | IT | 6200 |", + "| 9 | Ivy | 24 | Marketing | 4800 |", + "| 10 | Jack | 38 | Finance | 7500 |", + "+----------------+---------+-----+------------+--------+", ]; assert_batches_eq!(expected, &results); pretty::print_batches(&results).unwrap(); } + + #[tokio::test] + #[ignore] + async fn test_func_sql() { + let sql = "select count(s.id) from S3Object as s"; + let input = SelectObjectContentInput { + bucket: "dandan".to_string(), + expected_bucket_owner: None, + key: "test.csv".to_string(), + sse_customer_algorithm: None, + sse_customer_key: None, + sse_customer_key_md5: None, + request: SelectObjectContentRequest { + expression: sql.to_string(), + expression_type: ExpressionType::from_static("SQL"), + input_serialization: InputSerialization { + csv: Some(CSVInput::default()), + ..Default::default() + }, + output_serialization: OutputSerialization { + csv: Some(CSVOutput::default()), + ..Default::default() + }, + request_progress: None, + scan_range: None, + }, + }; + let db = make_rustfsms(input.clone(), true).await.unwrap(); + let query = Query::new(Context { input }, sql.to_string()); + + let result = db.execute(&query).await.unwrap(); + + let results = result.result().chunk_result().await.unwrap().to_vec(); + pretty::print_batches(&results).unwrap(); + } } diff --git a/s3select/query/src/metadata/mod.rs b/s3select/query/src/metadata/mod.rs index 78c79e368..04a71d4e7 100644 --- a/s3select/query/src/metadata/mod.rs +++ b/s3select/query/src/metadata/mod.rs @@ -113,14 +113,14 @@ impl ContextProvider for MetadataProvider { } fn udf_names(&self) -> Vec { - todo!() + self.func_manager.udfs() } fn udaf_names(&self) -> Vec { - todo!() + self.func_manager.udafs() } fn udwf_names(&self) -> Vec { - todo!() + self.func_manager.udwfs() } } From 19943025744b245c6aa59dc3616bec78123a7842 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 1 Apr 2025 22:06:47 +0800 Subject: [PATCH 038/103] improve tls for console --- .gitignore | 5 +- Cargo.lock | 224 +++++++++++++++++++++++++++++++++++++-- Cargo.toml | 6 +- rustfs/Cargo.toml | 4 +- rustfs/src/config/mod.rs | 12 +++ rustfs/src/console.rs | 109 +++++++++++++++++-- rustfs/src/main.rs | 22 ++-- 7 files changed, 352 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 83b9ef43c..e9172ab10 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ .devcontainer rustfs/static/* vendor -cli/rustfs-gui/embedded-rustfs/rustfs \ No newline at end of file +cli/rustfs-gui/embedded-rustfs/rustfs +.log +config/obs.toml +config/certs/* \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 8dbf614de..fea149c5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -679,6 +679,29 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "aws-lc-rs" +version = "1.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dabb68eb3a7aa08b46fddfd59a3d55c978243557a90ab804769f7e20e67d2b01" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77926887776171ced7d662120a75998e444d3750c951abfe07f90da130514b1f" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "axum" version = "0.7.9" @@ -734,6 +757,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum-server" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ad46c3ec4e12f4a4b6835e173ba21c25e484c9d02b49770bf006ce5367c036" +dependencies = [ + "arc-swap", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "pin-project-lite", + "rustls 0.21.12", + "rustls-pemfile", + "tokio", + "tokio-rustls 0.24.1", + "tower 0.4.13", + "tower-service", +] + [[package]] name = "backon" version = "1.4.0" @@ -795,6 +841,29 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.9.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex", + "syn 2.0.98", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -1002,6 +1071,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfb" version = "0.7.3" @@ -1133,6 +1211,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading 0.8.6", +] + [[package]] name = "clap" version = "4.5.31" @@ -1173,6 +1262,15 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + [[package]] name = "cocoa" version = "0.25.0" @@ -3116,6 +3214,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futf" version = "0.1.5" @@ -3853,10 +3957,12 @@ dependencies = [ "http", "hyper", "hyper-util", - "rustls", + "log", + "rustls 0.23.23", + "rustls-native-certs", "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.26.2", "tower-service", "webpki-roots", ] @@ -4172,6 +4278,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -4331,6 +4446,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "lexical-core" version = "1.0.5" @@ -5281,6 +5402,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + [[package]] name = "option-ext" version = "0.2.0" @@ -6034,7 +6161,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.1.1", - "rustls", + "rustls 0.23.23", "socket2", "thiserror 2.0.11", "tokio", @@ -6052,7 +6179,7 @@ dependencies = [ "rand 0.8.5", "ring", "rustc-hash 2.1.1", - "rustls", + "rustls 0.23.23", "rustls-pki-types", "slab", "thiserror 2.0.11", @@ -6354,7 +6481,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls", + "rustls 0.23.23", "rustls-pemfile", "rustls-pki-types", "serde", @@ -6363,7 +6490,7 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", - "tokio-rustls", + "tokio-rustls 0.26.2", "tokio-util", "tower 0.5.2", "tower-service", @@ -6529,6 +6656,7 @@ dependencies = [ "async-trait", "atoi", "axum", + "axum-server", "bytes", "chrono", "clap", @@ -6545,6 +6673,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "hyper-util", "iam", "jsonwebtoken", @@ -6623,21 +6752,46 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki 0.101.7", + "sct", +] + [[package]] name = "rustls" version = "0.23.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" dependencies = [ + "aws-lc-rs", "log", "once_cell", "ring", "rustls-pki-types", - "rustls-webpki", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework 3.2.0", +] + [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -6656,12 +6810,23 @@ dependencies = [ "web-time", ] +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustls-webpki" version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -6746,6 +6911,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -6758,6 +6932,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" version = "2.11.1" @@ -7722,13 +7906,23 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.12", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ - "rustls", + "rustls 0.23.23", "tokio", ] @@ -7838,7 +8032,7 @@ dependencies = [ "rustls-pemfile", "socket2", "tokio", - "tokio-rustls", + "tokio-rustls 0.26.2", "tokio-stream", "tower 0.4.13", "tower-layer", @@ -8594,6 +8788,18 @@ dependencies = [ "windows-core 0.58.0", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index adae86503..ed7abe714 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,9 +47,10 @@ flatbuffers = "24.12.23" futures = "0.3.31" futures-util = "0.3.31" common = { path = "./common/common" } -policy = {path = "./policy"} +policy = { path = "./policy" } hex = "0.4.3" hyper = "1.6.0" +hyper-rustls = { version = "0.27.5", features = ["http2"] } hyper-util = { version = "0.1.10", features = [ "tokio", "server-auto", @@ -72,7 +73,7 @@ prost-types = "0.13.4" protobuf = "3.7" protos = { path = "./common/protos" } rand = "0.8.5" -reqwest = { version = "0.12.12", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream","blocking"] } +reqwest = { version = "0.12.12", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream", "blocking"] } rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } rmp = "0.8.14" rmp-serde = "1.3.0" @@ -114,6 +115,7 @@ uuid = { version = "1.15.1", features = [ ] } log = "0.4.25" axum = "0.7.9" +axum-server = { version = "0.6", features = ["tls-rustls"] } md-5 = "0.10.6" workers = { path = "./common/workers" } test-case = "3.3.1" diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 493971d00..4c506863c 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -24,12 +24,13 @@ csv = "1.3.1" datafusion = { workspace = true } common.workspace = true ecstore.workspace = true -policy.workspace =true +policy.workspace = true flatbuffers.workspace = true futures.workspace = true futures-util.workspace = true h2 = "0.4.7" hyper.workspace = true +hyper-rustls.workspace = true hyper-util.workspace = true http.workspace = true http-body.workspace = true @@ -65,6 +66,7 @@ transform-stream.workspace = true uuid = "1.15.1" url.workspace = true axum.workspace = true +axum-server = { workspace = true } matchit = "0.8.6" shadow-rs.workspace = true const-str = { version = "0.6.1", features = ["std", "proc"] } diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index cd8f238fd..b6c3d3701 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -7,6 +7,14 @@ shadow_rs::shadow!(build); pub const DEFAULT_ACCESS_KEY: &str = "rustfsadmin"; pub const DEFAULT_SECRET_KEY: &str = "rustfsadmin"; +/// Default TLS key for rustfs +/// This is the default key for TLS. +pub const RUSTFS_TLS_KEY: &str = "rustfs_tls_key.pem"; + +/// Default TLS cert for rustfs +/// This is the default cert for TLS. +pub const RUSTFS_TLS_CERT: &str = "rustfs_tls_cert.pem"; + #[allow(clippy::const_is_empty)] const SHORT_VERSION: &str = { if !build::TAG.is_empty() { @@ -62,4 +70,8 @@ pub struct Opt { #[arg(long, default_value_t = format!("127.0.0.1:{}", 9002), env = "RUSTFS_CONSOLE_ADDRESS")] pub console_address: String, + + /// tls path for rustfs api and console. + #[arg(long, env = "RUSTFS_TLS_PATH")] + pub tls_path: Option, } diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index 8ccf0fb88..602997b64 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -6,19 +6,24 @@ use axum::{ routing::get, Router, }; - +use axum_server::tls_rustls::RustlsConfig; use mime_guess::from_path; use rust_embed::RustEmbed; use serde::Serialize; use shadow_rs::shadow; use std::net::{Ipv4Addr, SocketAddr, ToSocketAddrs}; use std::sync::OnceLock; -use tracing::info; +use std::time::Duration; +use tokio::signal; +use tracing::{debug, error, info}; shadow!(build); const RUSTFS_ADMIN_PREFIX: &str = "/rustfs/admin/v3"; +const RUSTFS_CONSOLE_TLS_KEY: &str = "rustfs_console_tls_key.pem"; +const RUSTFS_CONSOLE_TLS_CERT: &str = "rustfs_console_tls_cert.pem"; + #[derive(RustEmbed)] #[folder = "$CARGO_MANIFEST_DIR/static"] struct StaticFiles; @@ -189,18 +194,104 @@ async fn config_handler(Host(host): Host) -> impl IntoResponse { .unwrap() } -pub async fn start_static_file_server(addrs: &str, local_ip: Ipv4Addr, access_key: &str, secret_key: &str) { - // 创建路由 +pub async fn start_static_file_server( + addrs: &str, + local_ip: Ipv4Addr, + access_key: &str, + secret_key: &str, + tls_path: Option, +) { + // Create a route let app = Router::new() .route("/config.json", get(config_handler)) .nest_service("/", get(static_handler)); - - let listener = tokio::net::TcpListener::bind(addrs).await.unwrap(); - let local_addr = listener.local_addr().unwrap(); - + let local_addr: SocketAddr = addrs.parse().expect("Failed to parse socket address"); info!("WebUI: http://{}:{} http://127.0.0.1:{}", local_ip, local_addr.port(), local_addr.port()); info!(" RootUser: {}", access_key); info!(" RootPass: {}", secret_key); - axum::serve(listener, app).await.unwrap(); + let tls_path = tls_path.unwrap_or_default(); + let key_path = format!("{}/{}", tls_path, RUSTFS_CONSOLE_TLS_KEY); + let cert_path = format!("{}/{}", tls_path, RUSTFS_CONSOLE_TLS_CERT); + // Check and start the HTTPS/HTTP server + match start_server(addrs, local_addr, &key_path, &cert_path, app.clone()).await { + Ok(_) => info!("Server shutdown gracefully"), + Err(e) => error!("Server error: {}", e), + } +} +async fn start_server(addrs: &str, local_addr: SocketAddr, key_path: &str, cert_path: &str, app: Router) -> std::io::Result<()> { + let has_tls_certs = tokio::try_join!(tokio::fs::metadata(key_path), tokio::fs::metadata(cert_path)).is_ok(); + + if has_tls_certs { + debug!("Found TLS certificates, starting with HTTPS"); + match tokio::try_join!(tokio::fs::read(key_path), tokio::fs::read(cert_path)) { + Ok((key_data, cert_data)) => { + match RustlsConfig::from_pem(cert_data, key_data).await { + Ok(config) => { + let handle = axum_server::Handle::new(); + // create a signal off listening task + let handle_clone = handle.clone(); + tokio::spawn(async move { + shutdown_signal().await; + handle_clone.graceful_shutdown(Some(Duration::from_secs(10))); + }); + debug!("Starting HTTPS server..."); + axum_server::bind_rustls(local_addr, config) + .handle(handle.clone()) + .serve(app.into_make_service()) + .await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; + + Ok(()) + } + Err(e) => { + error!("Failed to create TLS config: {}", e); + start_http_server(addrs, app).await + } + } + } + Err(e) => { + error!("Failed to read TLS certificates: {}", e); + start_http_server(addrs, app).await + } + } + } else { + debug!("TLS certificates not found at {} and {}", key_path, cert_path); + start_http_server(addrs, app).await + } +} + +async fn start_http_server(addrs: &str, app: Router) -> std::io::Result<()> { + debug!("Starting HTTP server..."); + let listener = tokio::net::TcpListener::bind(addrs).await.unwrap(); + axum::serve(listener, app) + .with_graceful_shutdown(shutdown_signal()) + .await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)) +} + +async fn shutdown_signal() { + let ctrl_c = async { + signal::ctrl_c().await.expect("failed to install Ctrl+C handler"); + }; + + #[cfg(unix)] + let terminate = async { + signal::unix::signal(signal::unix::SignalKind::terminate()) + .expect("failed to install signal handler") + .recv() + .await; + }; + + #[cfg(not(unix))] + let terminate = std::future::pending::<()>(); + + tokio::select! { + _ = ctrl_c => { + info!("shutdown_signal ctrl_c") + }, + _ = terminate => { + info!("shutdown_signal terminate") + }, + } } diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 35187ba9f..cd4f5c627 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -87,7 +87,7 @@ fn main() -> Result<()> { //解析获得到的参数 let opt = config::Opt::parse(); - //设置trace + //设置 trace setup_tracing(); //运行参数 @@ -110,18 +110,17 @@ async fn run(opt: config::Opt) -> Result<()> { debug!("server_address {}", &server_address); - //设置AK和SK - + //设置 AK 和 SK iam::init_global_action_cred(Some(opt.access_key.clone()), Some(opt.secret_key.clone())).unwrap(); set_global_rustfs_port(server_port); - //监听地址,端口从参数中获取 + //监听地址,端口从参数中获取 let listener = TcpListener::bind(server_address.clone()).await?; //获取监听地址 let local_addr: SocketAddr = listener.local_addr()?; let local_ip = utils::get_local_ip().ok_or(local_addr.ip()).unwrap(); - // 用于rpc + // 用于 rpc let (endpoint_pools, setup_type) = EndpointServerPools::from_volumes(server_address.clone().as_str(), opt.volumes.clone()) .map_err(|err| Error::from_string(err.to_string()))?; @@ -172,7 +171,7 @@ async fn run(opt: config::Opt) -> Result<()> { .map_err(|err| Error::from_string(err.to_string()))?; // Setup S3 service - // 本项目使用s3s库来实现s3服务 + // 本项目使用 s3s 库来实现 s3 服务 let service = { let store = storage::ecfs::FS::new(); // let mut b = S3ServiceBuilder::new(storage::ecfs::FS::new(server_address.clone(), endpoint_pools).await?); @@ -180,7 +179,7 @@ async fn run(opt: config::Opt) -> Result<()> { let access_key = opt.access_key.clone(); let secret_key = opt.secret_key.clone(); - //显示info信息 + //显示 info 信息 debug!("authentication is enabled {}, {}", &access_key, &secret_key); b.set_auth(IAMAuth::new(access_key, secret_key)); @@ -294,8 +293,15 @@ async fn run(opt: config::Opt) -> Result<()> { let access_key = opt.access_key.clone(); let secret_key = opt.secret_key.clone(); let console_address = opt.console_address.clone(); + let tls_path = opt.tls_path.clone(); + + if console_address.is_empty() { + error!("console_address is empty"); + return Err(Error::from_string("console_address is empty".to_string())); + } + tokio::spawn(async move { - console::start_static_file_server(&console_address, local_ip, &access_key, &secret_key).await; + console::start_static_file_server(&console_address, local_ip, &access_key, &secret_key, tls_path).await; }); } From 28edca1b63dc1c4aeb3d947884c6f161c6b2924e Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 1 Apr 2025 23:09:47 +0800 Subject: [PATCH 039/103] add rustls --- Cargo.lock | 4 ++++ Cargo.toml | 4 ++++ rustfs/Cargo.toml | 4 ++++ rustfs/src/config/mod.rs | 4 ++-- rustfs/src/main.rs | 31 ++++++++++++++++++++++++++----- rustfs/src/utils.rs | 27 +++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fea149c5e..147bd87dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6696,6 +6696,9 @@ dependencies = [ "query", "rmp-serde", "rust-embed", + "rustls 0.23.23", + "rustls-pemfile", + "rustls-pki-types", "s3s", "serde", "serde_json", @@ -6703,6 +6706,7 @@ dependencies = [ "shadow-rs", "time", "tokio", + "tokio-rustls 0.26.2", "tokio-stream", "tokio-util", "tonic", diff --git a/Cargo.toml b/Cargo.toml index ed7abe714..8e71d2a49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,6 +78,9 @@ rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", rmp = "0.8.14" rmp-serde = "1.3.0" rust-embed = "8.6.0" +rustls = { version = "0.23" } +rustls-pki-types = "1.11.0" +rustls-pemfile = "2.2.0" s3s = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779", default-features = true, features = [ "tower", ] } @@ -99,6 +102,7 @@ tokio = { version = "1.43.0", features = ["fs", "rt-multi-thread"] } tonic = { version = "0.12.3", features = ["gzip"] } tonic-build = "0.12.3" tonic-reflection = "0.12" +tokio-rustls = { version = "0.26", default-features = false } tokio-stream = "0.1.17" tokio-util = { version = "0.7.13", features = ["io", "compat"] } tower = { version = "0.5.2", features = ["timeout"] } diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 4c506863c..da0f2ddf8 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -43,6 +43,9 @@ prost-types.workspace = true protos.workspace = true protobuf.workspace = true rmp-serde.workspace = true +rustls.workspace = true +rustls-pemfile.workspace = true +rustls-pki-types.workspace = true s3s.workspace = true serde.workspace = true serde_json.workspace = true @@ -55,6 +58,7 @@ tokio = { workspace = true, features = [ "net", "signal", ] } +tokio-rustls.workspace = true lazy_static.workspace = true tokio-stream.workspace = true tonic = { version = "0.12.3", features = ["gzip"] } diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index b6c3d3701..ada5307ef 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -9,11 +9,11 @@ pub const DEFAULT_SECRET_KEY: &str = "rustfsadmin"; /// Default TLS key for rustfs /// This is the default key for TLS. -pub const RUSTFS_TLS_KEY: &str = "rustfs_tls_key.pem"; +pub(crate) const RUSTFS_TLS_KEY: &str = "rustfs_tls_key.pem"; /// Default TLS cert for rustfs /// This is the default cert for TLS. -pub const RUSTFS_TLS_CERT: &str = "rustfs_tls_cert.pem"; +pub(crate) const RUSTFS_TLS_CERT: &str = "rustfs_tls_cert.pem"; #[allow(clippy::const_is_empty)] const SHORT_VERSION: &str = { diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index cd4f5c627..a34b182d7 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -9,13 +9,14 @@ mod utils; use crate::auth::IAMAuth; use crate::console::{init_console_cfg, CONSOLE_CONFIG}; +use crate::utils::error; use chrono::Datelike; use clap::Parser; use common::{ error::{Error, Result}, globals::set_global_addr, }; -use config::{DEFAULT_ACCESS_KEY, DEFAULT_SECRET_KEY}; +use config::{DEFAULT_ACCESS_KEY, DEFAULT_SECRET_KEY, RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; use ecstore::heal::background_heal_ops::init_auto_heal; use ecstore::utils::net::{self, get_available_port}; use ecstore::{ @@ -26,6 +27,7 @@ use ecstore::{ update_erasure_type, }; use ecstore::{global::set_global_rustfs_port, notification_sys::new_global_notification_sys}; +use futures_util::TryFutureExt; use grpc::make_server; use hyper_util::{ rt::{TokioExecutor, TokioIo}, @@ -34,10 +36,13 @@ use hyper_util::{ }; use iam::init_iam_sys; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; +use rustls::ServerConfig; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; +use std::sync::Arc; use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; +use tokio_rustls::TlsAcceptor; use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; use tracing::{debug, error, info, warn}; @@ -211,6 +216,22 @@ async fn run(opt: config::Opt) -> Result<()> { }; let rpc_service = NodeServiceServer::with_interceptor(make_server(), check_auth); + let tls_path = opt.tls_path.clone().unwrap_or_default(); + let key_path = format!("{}/{}", tls_path, RUSTFS_TLS_KEY); + let cert_path = format!("{}/{}", tls_path, RUSTFS_TLS_CERT); + + let has_tls_certs = tokio::try_join!(tokio::fs::metadata(key_path.clone()), tokio::fs::metadata(cert_path.clone())).is_ok(); + + if has_tls_certs { + let certs = utils::load_certs(cert_path.as_str()).map_err(|e| error(e.to_string()))?; + let key = utils::load_private_key(key_path.as_str()).map_err(|e| error(e.to_string()))?; + let mut server_config = ServerConfig::builder() + .with_no_client_auth() + .with_single_cert(certs, key) + .map_err(|e| error(e.to_string()))?; + server_config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec(), b"http/1.0".to_vec()]; + let tls_acceptor = TlsAcceptor::from(Arc::new(server_config)); + }; tokio::spawn(async move { let hyper_service = service.into_shared(); @@ -250,10 +271,10 @@ async fn run(opt: config::Opt) -> Result<()> { tokio::select! { () = graceful.shutdown() => { - tracing::debug!("Gracefully shutdown!"); + debug!("Gracefully shutdown!"); }, () = tokio::time::sleep(std::time::Duration::from_secs(10)) => { - tracing::debug!("Waited 10 seconds for graceful shutdown, aborting..."); + debug!("Waited 10 seconds for graceful shutdown, aborting..."); } } }); @@ -267,7 +288,7 @@ async fn run(opt: config::Opt) -> Result<()> { })?; ECStore::init(store.clone()).await.map_err(|err| { - error!("ECStore init faild {:?}", &err); + error!("ECStore init failed {:?}", &err); Error::from_string(err.to_string()) })?; debug!("init store success!"); @@ -275,7 +296,7 @@ async fn run(opt: config::Opt) -> Result<()> { init_iam_sys(store.clone()).await.unwrap(); new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| { - error!("new_global_notification_sys faild {:?}", &err); + error!("new_global_notification_sys failed {:?}", &err); Error::from_string(err.to_string()) })?; diff --git a/rustfs/src/utils.rs b/rustfs/src/utils.rs index 1496bd3f6..b90d942b4 100644 --- a/rustfs/src/utils.rs +++ b/rustfs/src/utils.rs @@ -1,4 +1,7 @@ +use rustls_pemfile::{certs, private_key}; +use rustls_pki_types::{CertificateDer, PrivateKeyDer}; use std::net::IpAddr; +use std::{fs, io}; pub(crate) fn get_local_ip() -> Option { match local_ip_address::local_ip() { @@ -7,3 +10,27 @@ pub(crate) fn get_local_ip() -> Option { Ok(IpAddr::V6(_)) => todo!(), } } + +/// Load public certificate from file. +pub(crate) fn load_certs(filename: &str) -> io::Result>> { + // Open certificate file. + let cert_file = fs::File::open(filename).map_err(|e| error(format!("failed to open {}: {}", filename, e)))?; + let mut reader = io::BufReader::new(cert_file); + + // Load and return certificate. + certs(&mut reader).collect() +} + +/// Load private key from file. +pub(crate) fn load_private_key(filename: &str) -> io::Result> { + // Open keyfile. + let keyfile = fs::File::open(filename).map_err(|e| error(format!("failed to open {}: {}", filename, e)))?; + let mut reader = io::BufReader::new(keyfile); + + // Load and return a single private key. + private_key(&mut reader).map(|key| key.unwrap()) +} + +pub(crate) fn error(err: String) -> io::Error { + io::Error::new(io::ErrorKind::Other, err) +} From de0e9bee20537dcaae3f7cdc253e72aae03000e9 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 1 Apr 2025 23:27:48 +0800 Subject: [PATCH 040/103] Log records uniformly use `tracing` --- Cargo.lock | 1 - rustfs/Cargo.toml | 2 +- rustfs/src/storage/ecfs.rs | 42 +++++++++++++++++++------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 147bd87dd..b453c2bf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6680,7 +6680,6 @@ dependencies = [ "lazy_static", "local-ip-address", "lock", - "log", "madmin", "matchit 0.8.6", "mime", diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index da0f2ddf8..9ae6b5802 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -16,7 +16,7 @@ workspace = true [dependencies] madmin.workspace = true -log.workspace = true +#log.workspace = true async-trait.workspace = true bytes.workspace = true clap.workspace = true diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 1fc410cb9..3cee79f23 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -46,7 +46,6 @@ use futures::pin_mut; use futures::{Stream, StreamExt}; use http::HeaderMap; use lazy_static::lazy_static; -use log::warn; use policy::auth; use policy::policy::action::Action; use policy::policy::action::S3Action; @@ -70,6 +69,7 @@ use tokio_util::io::StreamReader; use tracing::debug; use tracing::error; use tracing::info; +use tracing::warn; use transform_stream::AsyncTryStream; use uuid::Uuid; @@ -230,7 +230,7 @@ impl S3 for FS { #[tracing::instrument(level = "debug", skip(self, req))] async fn delete_bucket(&self, req: S3Request) -> S3Result> { let input = req.input; - // TODO: DeleteBucketInput 没有force参数? + // TODO: DeleteBucketInput 没有 force 参数? let Some(store) = new_object_layer_fn() else { return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string())); }; @@ -586,8 +586,8 @@ impl S3 for FS { .await .is_ok() || authorize_request(&mut req, Action::S3Action(S3Action::GetBucketLocationAction)) - .await - .is_ok() + .await + .is_ok() }) }); } @@ -1256,7 +1256,7 @@ impl S3 for FS { conditions: &conditions, object: "", }) - .await; + .await; let write_olny = PolicySys::is_allowed(&BucketPolicyArgs { bucket: &bucket, @@ -1267,7 +1267,7 @@ impl S3 for FS { conditions: &conditions, object: "", }) - .await; + .await; let is_public = read_olny && write_olny; @@ -1680,11 +1680,11 @@ impl S3 for FS { // TODO: valid target list if let Some(NotificationConfiguration { - event_bridge_configuration, - lambda_function_configurations, - queue_configurations, - topic_configurations, - }) = has_notification_config + event_bridge_configuration, + lambda_function_configurations, + queue_configurations, + topic_configurations, + }) = has_notification_config { Ok(S3Response::new(GetBucketNotificationConfigurationOutput { event_bridge_configuration, @@ -1785,10 +1785,10 @@ impl S3 for FS { // !gs.is_empty() && gs.first().is_some_and(|g| { - g.to_owned() - .permission - .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) - }) + g.to_owned() + .permission + .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) + }) }) }); @@ -1855,10 +1855,10 @@ impl S3 for FS { // !gs.is_empty() && gs.first().is_some_and(|g| { - g.to_owned() - .permission - .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) - }) + g.to_owned() + .permission + .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) + }) }) }); @@ -1934,9 +1934,9 @@ impl S3 for FS { } #[allow(dead_code)] -pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static +pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static where - S: Stream> + Send + 'static, + S: Stream> + Send + 'static, E: Send + 'static, { AsyncTryStream::::new(|mut y| async move { From d017409f5bd98f2a34a52fa09f17239f30510ed2 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 00:48:08 +0800 Subject: [PATCH 041/103] add rustfs tls --- Cargo.lock | 30 ------------------------- Cargo.toml | 2 +- rustfs/Cargo.toml | 2 +- rustfs/src/main.rs | 56 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b453c2bf9..264247907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3957,9 +3957,7 @@ dependencies = [ "http", "hyper", "hyper-util", - "log", "rustls 0.23.23", - "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls 0.26.2", @@ -5402,12 +5400,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "openssl-probe" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" - [[package]] name = "option-ext" version = "0.2.0" @@ -6673,7 +6665,6 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-rustls", "hyper-util", "iam", "jsonwebtoken", @@ -6783,18 +6774,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework 3.2.0", -] - [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -6914,15 +6893,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "scoped-tls" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 8e71d2a49..2e97d0eb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ common = { path = "./common/common" } policy = { path = "./policy" } hex = "0.4.3" hyper = "1.6.0" -hyper-rustls = { version = "0.27.5", features = ["http2"] } +#hyper-rustls = { version = "0.27.5", features = ["http2"] } hyper-util = { version = "0.1.10", features = [ "tokio", "server-auto", diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 9ae6b5802..c1a5d071e 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -30,7 +30,7 @@ futures.workspace = true futures-util.workspace = true h2 = "0.4.7" hyper.workspace = true -hyper-rustls.workspace = true +#hyper-rustls.workspace = true hyper-util.workspace = true http.workspace = true http-body.workspace = true diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index a34b182d7..8edc9e72f 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -27,7 +27,6 @@ use ecstore::{ update_erasure_type, }; use ecstore::{global::set_global_rustfs_port, notification_sys::new_global_notification_sys}; -use futures_util::TryFutureExt; use grpc::make_server; use hyper_util::{ rt::{TokioExecutor, TokioIo}, @@ -216,13 +215,14 @@ async fn run(opt: config::Opt) -> Result<()> { }; let rpc_service = NodeServiceServer::with_interceptor(make_server(), check_auth); + let tls_path = opt.tls_path.clone().unwrap_or_default(); let key_path = format!("{}/{}", tls_path, RUSTFS_TLS_KEY); let cert_path = format!("{}/{}", tls_path, RUSTFS_TLS_CERT); - let has_tls_certs = tokio::try_join!(tokio::fs::metadata(key_path.clone()), tokio::fs::metadata(cert_path.clone())).is_ok(); - - if has_tls_certs { + let tls_acceptor = if has_tls_certs { + debug!("Found TLS certificates, starting with HTTPS"); + let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); let certs = utils::load_certs(cert_path.as_str()).map_err(|e| error(e.to_string()))?; let key = utils::load_private_key(key_path.as_str()).map_err(|e| error(e.to_string()))?; let mut server_config = ServerConfig::builder() @@ -230,12 +230,14 @@ async fn run(opt: config::Opt) -> Result<()> { .with_single_cert(certs, key) .map_err(|e| error(e.to_string()))?; server_config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec(), b"http/1.0".to_vec()]; - let tls_acceptor = TlsAcceptor::from(Arc::new(server_config)); + Some(TlsAcceptor::from(Arc::new(server_config))) + } else { + debug!("TLS certificates not found, starting with HTTP"); + None }; tokio::spawn(async move { let hyper_service = service.into_shared(); - let hybrid_service = TowerToHyperService::new( tower::ServiceBuilder::new() .layer(CorsLayer::permissive()) @@ -245,8 +247,10 @@ async fn run(opt: config::Opt) -> Result<()> { let http_server = ConnBuilder::new(TokioExecutor::new()); let mut ctrl_c = std::pin::pin!(tokio::signal::ctrl_c()); let graceful = hyper_util::server::graceful::GracefulShutdown::new(); - + debug!("graceful initiated"); loop { + debug!("waiting for SIGINT or SIGTERM has_tls_certs: {}", has_tls_certs); + // Wait for a connection let (socket, _) = tokio::select! { res = listener.accept() => { match res { @@ -261,12 +265,38 @@ async fn run(opt: config::Opt) -> Result<()> { break; } }; - - let conn = http_server.serve_connection(TokioIo::new(socket), hybrid_service.clone()); - let conn = graceful.watch(conn.into_owned()); - tokio::spawn(async move { - let _ = conn.await; - }); + if has_tls_certs { + debug!("TLS certificates found, starting with SIGINT"); + let tls_socket = match tls_acceptor.as_ref().ok_or_else(|| error("TLS not configured".to_string())).unwrap().accept(socket).await { + Ok(tls_socket) => tls_socket, + Err(err) => { + error!("TLS handshake failed {}", err); + continue; + } + }; + let conn = http_server.serve_connection(TokioIo::new(tls_socket), hybrid_service.clone()); + let conn = graceful.watch(conn.into_owned()); + tokio::task::spawn_blocking(move || { + tokio::runtime::Runtime::new() + .expect("Failed to create runtime") + .block_on(async move { + if let Err(err) = conn.await { + error!("Https Connection error: {}", err); + } + }); + }); + debug!("TLS handshake success"); + } else { + debug!("Http handshake start"); + let conn = http_server.serve_connection(TokioIo::new(socket), hybrid_service.clone()); + let conn = graceful.watch(conn.into_owned()); + tokio::spawn(async move { + if let Err(err) = conn.await { + error!("Http Connection error: {}", err); + } + }); + debug!("Http handshake success"); + } } tokio::select! { From 15efeb572fde6f6bac775846b6d29328970169e6 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 00:51:59 +0800 Subject: [PATCH 042/103] improve crate and remove log crate --- Cargo.lock | 3 --- Cargo.toml | 3 +-- cli/rustfs-gui/Cargo.toml | 1 - iam/Cargo.toml | 1 - iam/src/cache.rs | 12 ++++++------ iam/src/lib.rs | 2 +- iam/src/manager.rs | 2 +- policy/Cargo.toml | 1 - rustfs/Cargo.toml | 6 ++---- 9 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 264247907..1db4030ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4012,7 +4012,6 @@ dependencies = [ "itertools 0.14.0", "jsonwebtoken", "lazy_static", - "log", "madmin", "policy", "rand 0.8.5", @@ -5845,7 +5844,6 @@ dependencies = [ "itertools 0.14.0", "jsonwebtoken", "lazy_static", - "log", "madmin", "rand 0.8.5", "regex", @@ -6719,7 +6717,6 @@ dependencies = [ "chrono", "dioxus", "dirs 6.0.0", - "futures-util", "hex", "keyring", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 2e97d0eb0..20f6a009a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,7 @@ tokio-rustls = { version = "0.26", default-features = false } tokio-stream = "0.1.17" tokio-util = { version = "0.7.13", features = ["io", "compat"] } tower = { version = "0.5.2", features = ["timeout"] } +tower-http = { version = "0.6.2", features = ["cors"] } tracing = "0.1.41" tracing-error = "0.2.1" tracing-subscriber = { version = "0.3.19", features = ["env-filter", "time"] } @@ -117,13 +118,11 @@ uuid = { version = "1.15.1", features = [ "fast-rng", "macro-diagnostics", ] } -log = "0.4.25" axum = "0.7.9" axum-server = { version = "0.6", features = ["tls-rustls"] } md-5 = "0.10.6" workers = { path = "./common/workers" } test-case = "3.3.1" -zip = "2.2.3" snafu = "0.8.5" diff --git a/cli/rustfs-gui/Cargo.toml b/cli/rustfs-gui/Cargo.toml index c9af2fc37..faca71ee5 100644 --- a/cli/rustfs-gui/Cargo.toml +++ b/cli/rustfs-gui/Cargo.toml @@ -10,7 +10,6 @@ version.workspace = true chrono = { workspace = true } dioxus = { workspace = true, features = ["router"] } dirs = { workspace = true } -futures-util = { workspace = true } hex = { workspace = true } keyring = { workspace = true } lazy_static = { workspace = true } diff --git a/iam/Cargo.toml b/iam/Cargo.toml index 5afc93c54..fce678b66 100644 --- a/iam/Cargo.toml +++ b/iam/Cargo.toml @@ -11,7 +11,6 @@ workspace = true [dependencies] tokio.workspace = true -log.workspace = true time = { workspace = true, features = ["serde-human-readable"] } serde = { workspace = true, features = ["derive", "rc"] } ecstore = { path = "../ecstore" } diff --git a/iam/src/cache.rs b/iam/src/cache.rs index f16921162..b5dd20c3b 100644 --- a/iam/src/cache.rs +++ b/iam/src/cache.rs @@ -6,12 +6,12 @@ use std::{ }; use arc_swap::{ArcSwap, AsRaw, Guard}; -use log::warn; use policy::{ auth::UserIdentity, policy::{Args, PolicyDoc}, }; use time::OffsetDateTime; +use tracing::warn; use crate::store::{GroupInfo, MappedPolicy}; @@ -63,7 +63,7 @@ impl Cache { let mut new = CacheEntity::clone(&cur); op(&mut new); - // 使用cas原子替换内容 + // 使用 cas 原子替换内容 let prev = target.compare_and_swap(&*cur, Arc::new(new)); let swapped = Self::ptr_eq(&*cur, &*prev); if swapped { @@ -112,8 +112,8 @@ impl CacheInner { // todo!() // } - // /// 如果是临时用户,返回Ok(Some(partent_name))) - // /// 如果不是临时用户,返回Ok(None) + // /// 如果是临时用户,返回 Ok(Some(partent_name))) + // /// 如果不是临时用户,返回 Ok(None) // fn is_temp_user(&self, user_name: &str) -> crate::Result> { // let user = self // .get_user(user_name) @@ -126,8 +126,8 @@ impl CacheInner { // } // } - // /// 如果是临时用户,返回Ok(Some(partent_name))) - // /// 如果不是临时用户,返回Ok(None) + // /// 如果是临时用户,返回 Ok(Some(partent_name))) + // /// 如果不是临时用户,返回 Ok(None) // fn is_service_account(&self, user_name: &str) -> crate::Result> { // let user = self // .get_user(user_name) diff --git a/iam/src/lib.rs b/iam/src/lib.rs index 88392bb98..d88da7555 100644 --- a/iam/src/lib.rs +++ b/iam/src/lib.rs @@ -1,12 +1,12 @@ use common::error::{Error, Result}; use ecstore::store::ECStore; use error::Error as IamError; -use log::debug; use manager::IamCache; use policy::auth::Credentials; use std::sync::{Arc, OnceLock}; use store::object::ObjectStore; use sys::IamSys; +use tracing::debug; pub mod cache; pub mod error; diff --git a/iam/src/manager.rs b/iam/src/manager.rs index f4fc076c2..73994e220 100644 --- a/iam/src/manager.rs +++ b/iam/src/manager.rs @@ -11,7 +11,6 @@ use crate::{ use common::error::{Error, Result}; use ecstore::config::error::is_err_config_not_found; use ecstore::utils::{crypto::base64_encode, path::path_join_buf}; -use log::{debug, warn}; use madmin::{AccountStatus, AddOrUpdateUserReq, GroupDesc}; use policy::{ arn::ARN, @@ -40,6 +39,7 @@ use tokio::{ }, }; use tracing::error; +use tracing::{debug, warn}; const IAM_FORMAT_FILE: &str = "format.json"; const IAM_FORMAT_VERSION_1: i32 = 1; diff --git a/policy/Cargo.toml b/policy/Cargo.toml index da2c4636c..56e33d725 100644 --- a/policy/Cargo.toml +++ b/policy/Cargo.toml @@ -11,7 +11,6 @@ workspace = true [dependencies] tokio.workspace = true -log.workspace = true time = { workspace = true, features = ["serde-human-readable"] } serde = { workspace = true, features = ["derive", "rc"] } serde_json.workspace = true diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index c1a5d071e..805406219 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -16,7 +16,6 @@ workspace = true [dependencies] madmin.workspace = true -#log.workspace = true async-trait.workspace = true bytes.workspace = true clap.workspace = true @@ -30,7 +29,6 @@ futures.workspace = true futures-util.workspace = true h2 = "0.4.7" hyper.workspace = true -#hyper-rustls.workspace = true hyper-util.workspace = true http.workspace = true http-body.workspace = true @@ -61,7 +59,7 @@ tokio = { workspace = true, features = [ tokio-rustls.workspace = true lazy_static.workspace = true tokio-stream.workspace = true -tonic = { version = "0.12.3", features = ["gzip"] } +tonic.workspace = true tonic-reflection.workspace = true tower.workspace = true tracing-error.workspace = true @@ -81,7 +79,7 @@ query = { path = "../s3select/query" } api = { path = "../s3select/api" } iam = { path = "../iam" } jsonwebtoken = "9.3.0" -tower-http = { version = "0.6.2", features = ["cors"] } +tower-http.workspace = true mime_guess = "2.0.5" rust-embed = { workspace = true, features = ["interpolate-folder-path"] } local-ip-address = { workspace = true } From b365aab902cbcab0dc2a717ee813b51feeef089a Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 01:12:43 +0800 Subject: [PATCH 043/103] Update rustfs/src/utils.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rustfs/src/utils.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rustfs/src/utils.rs b/rustfs/src/utils.rs index b90d942b4..8f72e5f7a 100644 --- a/rustfs/src/utils.rs +++ b/rustfs/src/utils.rs @@ -28,7 +28,10 @@ pub(crate) fn load_private_key(filename: &str) -> io::Result Ok(key), + None => Err(error(format!("no private key found in {}", filename))), + } } pub(crate) fn error(err: String) -> io::Error { From f47a417319b0a580e4af4ca9e07badcbfedaaab7 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 01:12:54 +0800 Subject: [PATCH 044/103] Update rustfs/src/utils.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rustfs/src/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rustfs/src/utils.rs b/rustfs/src/utils.rs index 8f72e5f7a..b0ccb228c 100644 --- a/rustfs/src/utils.rs +++ b/rustfs/src/utils.rs @@ -18,7 +18,8 @@ pub(crate) fn load_certs(filename: &str) -> io::Result, _>>()?; + Ok(certs) } /// Load private key from file. From 2a90b3bb70338666708c210ad4cafd7cfde5e346 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 01:18:44 +0800 Subject: [PATCH 045/103] improve code --- rustfs/src/utils.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rustfs/src/utils.rs b/rustfs/src/utils.rs index b0ccb228c..2d12f64d2 100644 --- a/rustfs/src/utils.rs +++ b/rustfs/src/utils.rs @@ -29,10 +29,7 @@ pub(crate) fn load_private_key(filename: &str) -> io::Result Ok(key), - None => Err(error(format!("no private key found in {}", filename))), - } + private_key(&mut reader)?.ok_or_else(|| error(format!("no private key found in {}", filename))) } pub(crate) fn error(err: String) -> io::Error { From 8d4c3dfa0e01cd14fe78ebc22cd7a8912f56effd Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 08:37:06 +0800 Subject: [PATCH 046/103] add example certs readme.md --- config/certs/README.md | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 config/certs/README.md diff --git a/config/certs/README.md b/config/certs/README.md new file mode 100644 index 000000000..ce3dbe759 --- /dev/null +++ b/config/certs/README.md @@ -0,0 +1,44 @@ +## Certs + +### Generate a self-signed certificate + +```bash +openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes +``` + +### Generate a self-signed certificate with a specific subject + +```bash +openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \ + -subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=mydomain.com" +``` + +### Generate a self-signed certificate with a specific subject and SAN + +```bash +openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \ + -subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=mydomain.com" \ + -addext "subjectAltName=DNS:mydomain.com,DNS:www.mydomain.com" +``` + +### Generate a self-signed certificate with a specific subject and SAN (multiple SANs) + +```bash +openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \ + -subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=mydomain.com" \ + -addext "subjectAltName=DNS:mydomain.com,DNS:www.mydomain.com,DNS:api.mydomain.com" +``` + +### TLS File + +```text + + rustfs_tls_cert.pem api cert.pem + + rustfs_tls_key.pem api key.pem + + rustfs_console_tls_cert.pem console cert.pem + + rustfs_console_tls_key.pem console key.pem + +``` \ No newline at end of file From c57ee8e4712ecee28595cd93ac2ddb4f2bbf1a1e Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 16:08:51 +0800 Subject: [PATCH 047/103] modify default value --- config/obs.example.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/obs.example.toml b/config/obs.example.toml index 4b107e15e..0ba434ada 100644 --- a/config/obs.example.toml +++ b/config/obs.example.toml @@ -1,7 +1,7 @@ [observability] -endpoint = "" # Default is "http://localhost:4317" if not specified -use_stdout = false -sample_ratio = 0.5 +endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified +use_stdout = false # Output with stdout, true output, false no output +sample_ratio = 2.0 meter_interval = 30 service_name = "rustfs" service_version = "0.1.0" From 0b552b1697f5aace5387fc182acc5ba9eb1d18e1 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 17:18:03 +0800 Subject: [PATCH 048/103] run.sh add RUSTFS_OBS_CONFIG = "./config/obs.example.toml" --- Cargo.toml | 2 +- rustfs/Cargo.toml | 2 +- scripts/run.sh | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0945e52b7..76edbe035 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ backon = "1.3.0" bytes = "1.9.0" bytesize = "1.3.0" chrono = { version = "0.4.40", features = ["serde"] } -clap = { version = "4.5.31", features = ["derive", "env"] } +clap = { version = "4.5.35", features = ["derive", "env"] } config = "0.15.9" datafusion = "46.0.0" derive_builder = "0.20.2" diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index acb7be72f..db348d89a 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -98,7 +98,7 @@ futures-util.workspace = true # uuid = { version = "1.8.0", features = ["v4", "fast-rng", "serde"] } ecstore = { path = "../ecstore" } s3s.workspace = true -clap = { version = "4.5.31", features = ["derive", "env"] } +clap = { workspace = true } tracing-subscriber = { version = "0.3.19", features = ["env-filter", "time"] } hyper-util = { version = "0.1.10", features = [ "tokio", diff --git a/scripts/run.sh b/scripts/run.sh index 2b00ade0f..cc964beea 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -26,6 +26,9 @@ export RUSTFS_CONSOLE_ENABLE=true export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" # export RUSTFS_SERVER_DOMAINS="localhost:9000" +# 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 +export RUSTFS_OBS_CONFIG="./config/obs.example.toml" + if [ -n "$1" ]; then export RUSTFS_VOLUMES="$1" fi From 3a0ea8992f3b7886126cf4c43aa09808f8d59c8f Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 18:23:20 +0800 Subject: [PATCH 049/103] improve code for observability --- packages/obs/examples/config.toml | 10 ++++++---- packages/obs/src/telemetry.rs | 2 +- scripts/run.bat | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml index 135dd39ac..0db8e820f 100644 --- a/packages/obs/examples/config.toml +++ b/packages/obs/examples/config.toml @@ -1,11 +1,12 @@ [observability] -endpoint = "http://localhost:4317" -use_stdout = true +endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified +use_stdout = false # Output with stdout, true output, false no output sample_ratio = 1 meter_interval = 30 service_name = "rustfs_obs" service_version = "0.1.0" -deployment_environment = "develop" +environments = "develop" +logger_levela = "debug" [sinks] [sinks.kafka] @@ -17,7 +18,8 @@ batch_timeout_ms = 1000 # Default is 1000ms if not specified [sinks.webhook] enabled = false -url = "http://localhost:8080/webhook" +endpoint = "http://localhost:8080/webhook" +auth_token = "" batch_size = 100 # Default is 3 if not specified batch_timeout_ms = 1000 # Default is 100ms if not specified diff --git a/packages/obs/src/telemetry.rs b/packages/obs/src/telemetry.rs index f73d9b879..415e427fc 100644 --- a/packages/obs/src/telemetry.rs +++ b/packages/obs/src/telemetry.rs @@ -258,7 +258,7 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { } _ => { let mut filter = EnvFilter::new(logger_level); - for directive in ["hyper", "opentelemetry", "tonic", "h2", "reqwest"] { + for directive in ["hyper", "tonic", "h2", "reqwest"] { filter = filter.add_directive(format!("{}=off", directive).parse().unwrap()); } filter diff --git a/scripts/run.bat b/scripts/run.bat index e0ec7dc5f..0dd48a448 100644 --- a/scripts/run.bat +++ b/scripts/run.bat @@ -24,6 +24,8 @@ set RUSTFS_ADDRESS=0.0.0.0:9000 set RUSTFS_CONSOLE_ENABLE=true set RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 rem set RUSTFS_SERVER_DOMAINS=localhost:9000 +rem 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 +set RUSTFS_OBS_CONFIG=.\config\obs.example.toml" if not "%~1"=="" ( set RUSTFS_VOLUMES=%~1 From 56dd13981c1567bd12cc0921b3e38be553428a2b Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 22:27:49 +0800 Subject: [PATCH 050/103] Create a docker-compose-obs.yaml file related to observability --- .docker/observability/conifg/obs.toml | 33 ++++++ Dockerfile.obs | 19 ++++ data/README.md | 0 docker-compose-obs.yaml | 148 ++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 .docker/observability/conifg/obs.toml create mode 100644 Dockerfile.obs create mode 100644 data/README.md create mode 100644 docker-compose-obs.yaml diff --git a/.docker/observability/conifg/obs.toml b/.docker/observability/conifg/obs.toml new file mode 100644 index 000000000..2454934f6 --- /dev/null +++ b/.docker/observability/conifg/obs.toml @@ -0,0 +1,33 @@ +[observability] +endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified +use_stdout = true +sample_ratio = 2.0 +meter_interval = 30 +service_name = "rustfs" +service_version = "0.1.0" +environments = "develop" +logger_levela = "info" + +[sinks] +[sinks.kafka] # Kafka sink is disabled by default +enabled = false +bootstrap_servers = "localhost:9092" +topic = "logs" +batch_size = 100 # Default is 100 if not specified +batch_timeout_ms = 1000 # Default is 1000ms if not specified + +[sinks.webhook] +enabled = false +endpoint = "http://localhost:8080/webhook" +auth_token = "" +batch_size = 100 # Default is 3 if not specified +batch_timeout_ms = 1000 # Default is 100ms if not specified + +[sinks.file] +enabled = true +path = "/Users/qun/Documents/rust/rustfs/s3-rustfs/logs/app.log" +batch_size = 10 +batch_timeout_ms = 1000 # Default is 8192 bytes if not specified + +[logger] +queue_capacity = 10 \ No newline at end of file diff --git a/Dockerfile.obs b/Dockerfile.obs new file mode 100644 index 000000000..5a6148ab0 --- /dev/null +++ b/Dockerfile.obs @@ -0,0 +1,19 @@ +FROM alpine:latest + +# RUN apk add --no-cache +# 如果 rustfs 有依赖,可以在这里添加,例如: +# RUN apk add --no-cache openssl + +WORKDIR /app + +# 创建与 RUSTFS_VOLUMES 一致的目录 +RUN mkdir -p /root/data/target/volume/test1 /root/data/target/volume/test2 /root/data/target/volume/test3 /root/data/target/volume/test4 + +COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs + +RUN chmod +x /app/rustfs + +EXPOSE 9000 +EXPOSE 9002 + +CMD ["/app/rustfs"] \ No newline at end of file diff --git a/data/README.md b/data/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/docker-compose-obs.yaml b/docker-compose-obs.yaml new file mode 100644 index 000000000..4630106e3 --- /dev/null +++ b/docker-compose-obs.yaml @@ -0,0 +1,148 @@ +services: + otel-collector: + image: otel/opentelemetry-collector-contrib:0.120.0 + environment: + - TZ=Asia/Shanghai + volumes: + - ./.docker/observability/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml + ports: + - 1888:1888 + - 8888:8888 + - 8889:8889 + - 13133:13133 + - 4317:4317 + - 4318:4318 + - 55679:55679 + networks: + - rustfs-network + jaeger: + image: jaegertracing/jaeger:2.4.0 + environment: + - TZ=Asia/Shanghai + ports: + - "16686:16686" + - "14317:4317" + - "14318:4318" + networks: + - rustfs-network + prometheus: + image: prom/prometheus:v3.2.1 + environment: + - TZ=Asia/Shanghai + volumes: + - ./.docker/observability/prometheus.yml:/etc/prometheus/prometheus.yml + ports: + - "9090:9090" + networks: + - rustfs-network + loki: + image: grafana/loki:3.4.2 + environment: + - TZ=Asia/Shanghai + volumes: + - ./.docker/observability/loki-config.yaml:/etc/loki/local-config.yaml + ports: + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml + networks: + - rustfs-network + grafana: + image: grafana/grafana:11.6.0 + ports: + - "3000:3000" # Web UI + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + - TZ=Asia/Shanghai + networks: + - rustfs-network + + node1: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node1 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9001:9000" # 映射宿主机的 9001 端口到容器的 9000 端口 + - "9101:9002" + volumes: + - ./data:/root/data # 将当前路径挂载到容器内的 /root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + + node2: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node2 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9002:9000" # 映射宿主机的 9002 端口到容器的 9000 端口 + - "9102:9002" + volumes: + - ./data:/root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + + node3: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node3 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9003:9000" # 映射宿主机的 9003 端口到容器的 9000 端口 + - "9103:9002" + volumes: + - ./data:/root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + + node4: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node4 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9004:9000" # 映射宿主机的 9004 端口到容器的 9000 端口 + - "9104:9002" + volumes: + - ./data:/root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + +networks: + rustfs-network: + driver: bridge + name: "network_otel_config" + driver_opts: + com.docker.network.enable_ipv6: "true" From 5de28e6e7e0c51748c9332822c6194a69f557d81 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 23:56:12 +0800 Subject: [PATCH 051/103] fix typo --- .docker/observability/{conifg => config}/obs.toml | 2 +- Dockerfile.obs | 2 +- data/README.md | 1 + docker-compose-obs.yaml | 2 +- packages/obs/examples/config.toml | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) rename .docker/observability/{conifg => config}/obs.toml (97%) diff --git a/.docker/observability/conifg/obs.toml b/.docker/observability/config/obs.toml similarity index 97% rename from .docker/observability/conifg/obs.toml rename to .docker/observability/config/obs.toml index 2454934f6..5d0f0dad4 100644 --- a/.docker/observability/conifg/obs.toml +++ b/.docker/observability/config/obs.toml @@ -6,7 +6,7 @@ meter_interval = 30 service_name = "rustfs" service_version = "0.1.0" environments = "develop" -logger_levela = "info" +logger_level = "info" [sinks] [sinks.kafka] # Kafka sink is disabled by default diff --git a/Dockerfile.obs b/Dockerfile.obs index 5a6148ab0..a4de399c7 100644 --- a/Dockerfile.obs +++ b/Dockerfile.obs @@ -7,7 +7,7 @@ FROM alpine:latest WORKDIR /app # 创建与 RUSTFS_VOLUMES 一致的目录 -RUN mkdir -p /root/data/target/volume/test1 /root/data/target/volume/test2 /root/data/target/volume/test3 /root/data/target/volume/test4 +# RUN mkdir -p /root/data/target/volume/test1 /root/data/target/volume/test2 /root/data/target/volume/test3 /root/data/target/volume/test4 COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs diff --git a/data/README.md b/data/README.md index e69de29bb..2e3d4df77 100644 --- a/data/README.md +++ b/data/README.md @@ -0,0 +1 @@ +## Observability Docker Compose \ No newline at end of file diff --git a/docker-compose-obs.yaml b/docker-compose-obs.yaml index 4630106e3..19390da0f 100644 --- a/docker-compose-obs.yaml +++ b/docker-compose-obs.yaml @@ -143,6 +143,6 @@ services: networks: rustfs-network: driver: bridge - name: "network_otel_config" + name: "network_rustfs_config" driver_opts: com.docker.network.enable_ipv6: "true" diff --git a/packages/obs/examples/config.toml b/packages/obs/examples/config.toml index 0db8e820f..929867f03 100644 --- a/packages/obs/examples/config.toml +++ b/packages/obs/examples/config.toml @@ -6,7 +6,7 @@ meter_interval = 30 service_name = "rustfs_obs" service_version = "0.1.0" environments = "develop" -logger_levela = "debug" +logger_level = "debug" [sinks] [sinks.kafka] From 4136dd53937a348ec384ccb522a82efb2a53b5b0 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 3 Apr 2025 01:59:28 +0800 Subject: [PATCH 052/103] improve code for dockerfile --- .docker/observability/config/obs.toml | 6 +++--- Dockerfile.obs | 4 +--- docker-compose-obs.yaml | 8 ++++---- ecstore/src/store.rs | 18 +++++++++--------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.docker/observability/config/obs.toml b/.docker/observability/config/obs.toml index 5d0f0dad4..ecb340061 100644 --- a/.docker/observability/config/obs.toml +++ b/.docker/observability/config/obs.toml @@ -1,11 +1,11 @@ [observability] endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified -use_stdout = true +use_stdout = false # Output with stdout, true output, false no output sample_ratio = 2.0 meter_interval = 30 service_name = "rustfs" service_version = "0.1.0" -environments = "develop" +environments = "production" logger_level = "info" [sinks] @@ -25,7 +25,7 @@ batch_timeout_ms = 1000 # Default is 100ms if not specified [sinks.file] enabled = true -path = "/Users/qun/Documents/rust/rustfs/s3-rustfs/logs/app.log" +path = "/root/data/logs/app.log" batch_size = 10 batch_timeout_ms = 1000 # Default is 8192 bytes if not specified diff --git a/Dockerfile.obs b/Dockerfile.obs index a4de399c7..fdcfcc3fe 100644 --- a/Dockerfile.obs +++ b/Dockerfile.obs @@ -3,12 +3,10 @@ FROM alpine:latest # RUN apk add --no-cache # 如果 rustfs 有依赖,可以在这里添加,例如: # RUN apk add --no-cache openssl +# RUN apk add --no-cache bash # 安装 Bash WORKDIR /app -# 创建与 RUSTFS_VOLUMES 一致的目录 -# RUN mkdir -p /root/data/target/volume/test1 /root/data/target/volume/test2 /root/data/target/volume/test3 /root/data/target/volume/test4 - COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs RUN chmod +x /app/rustfs diff --git a/docker-compose-obs.yaml b/docker-compose-obs.yaml index 19390da0f..9a01db4cb 100644 --- a/docker-compose-obs.yaml +++ b/docker-compose-obs.yaml @@ -62,7 +62,7 @@ services: dockerfile: Dockerfile.obs container_name: node1 environment: - - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_VOLUMES=/root/data/target/volume/test{1...4} - RUSTFS_ADDRESS=0.0.0.0:9000 - RUSTFS_CONSOLE_ENABLE=true - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 @@ -83,7 +83,7 @@ services: dockerfile: Dockerfile.obs container_name: node2 environment: - - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_VOLUMES=/root/data/target/volume/test{1...4} - RUSTFS_ADDRESS=0.0.0.0:9000 - RUSTFS_CONSOLE_ENABLE=true - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 @@ -104,7 +104,7 @@ services: dockerfile: Dockerfile.obs container_name: node3 environment: - - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_VOLUMES=/root/data/target/volume/test{1...4} - RUSTFS_ADDRESS=0.0.0.0:9000 - RUSTFS_CONSOLE_ENABLE=true - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 @@ -125,7 +125,7 @@ services: dockerfile: Dockerfile.obs container_name: node4 environment: - - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_VOLUMES=/root/data/target/volume/test{1...4} - RUSTFS_ADDRESS=0.0.0.0:9000 - RUSTFS_CONSOLE_ENABLE=true - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 diff --git a/ecstore/src/store.rs b/ecstore/src/store.rs index 84c6da013..1f57b704c 100644 --- a/ecstore/src/store.rs +++ b/ecstore/src/store.rs @@ -608,7 +608,7 @@ impl ECStore { let mut ress = Vec::new(); - // join_all结果跟输入顺序一致 + // join_all 结果跟输入顺序一致 for (i, res) in results.into_iter().enumerate() { let index = i; @@ -1010,7 +1010,7 @@ pub async fn all_local_disk() -> Vec { .collect() } -// init_local_disks 初始化本地磁盘,server启动前必须初始化成功 +// init_local_disks 初始化本地磁盘,server 启动前必须初始化成功 pub async fn init_local_disks(endpoint_pools: EndpointServerPools) -> Result<()> { let opt = &DiskOption { cleanup: true, @@ -1279,7 +1279,7 @@ impl StorageAPI for ECStore { // TODO: replication opts.srdelete_op - // 删除meta + // 删除 meta self.delete_all(RUSTFS_META_BUCKET, format!("{}/{}", BUCKET_META_PREFIX, bucket).as_str()) .await?; Ok(()) @@ -1483,7 +1483,7 @@ impl StorageAPI for ECStore { // results.push(jh.await.unwrap()); // } - // 记录pool Index 对应的objects pool_idx -> objects idx + // 记录 pool Index 对应的 objects pool_idx -> objects idx let mut pool_obj_idx_map = HashMap::new(); let mut orig_index_map = HashMap::new(); @@ -1533,9 +1533,9 @@ impl StorageAPI for ECStore { if !pool_obj_idx_map.is_empty() { for (i, sets) in self.pools.iter().enumerate() { - // 取pool idx 对应的 objects index + // 取 pool idx 对应的 objects index if let Some(objs) = pool_obj_idx_map.get(&i) { - // 取对应obj,理论上不会none + // 取对应 obj,理论上不会 none // let objs: Vec = obj_idxs.iter().filter_map(|&idx| objects.get(idx).cloned()).collect(); if objs.is_empty() { @@ -1544,10 +1544,10 @@ impl StorageAPI for ECStore { let (pdel_objs, perrs) = sets.delete_objects(bucket, objs.clone(), opts.clone()).await?; - // 同时存入不可能为none + // 同时存入不可能为 none let org_indexes = orig_index_map.get(&i).unwrap(); - // perrs的顺序理论上跟obj_idxs顺序一致 + // perrs 的顺序理论上跟 obj_idxs 顺序一致 for (i, err) in perrs.into_iter().enumerate() { let obj_idx = org_indexes[i]; @@ -1580,7 +1580,7 @@ impl StorageAPI for ECStore { let object = utils::path::encode_dir_object(object); let object = object.as_str(); - // 查询在哪个pool + // 查询在哪个 pool let (mut pinfo, errs) = self .get_pool_info_existing_with_opts(bucket, object, &opts) .await From 5204cb67d81c9fee587ae988c8417a1e442979db Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 7 Apr 2025 16:55:14 +0800 Subject: [PATCH 053/103] Change build target to `x86_64-unknown-linux-musl` and update system dependencies - Change build target from `x86_64-unknown-linux-gnu` to `x86_64-unknown-linux-musl` - Default install `x86_64-unknown-linux-musl` toolchain in setup action - Add `musl-tools` and `build-essential` to system dependencies --- .github/actions/setup/action.yml | 3 +++ .github/workflows/build.yml | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 4c7afb30e..13eb3b8fe 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -21,6 +21,8 @@ runs: run: | sudo apt update sudo apt install -y \ + musl-tools \ + build-essential \ lld \ libdbus-1-dev \ libwayland-dev \ @@ -38,6 +40,7 @@ runs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ inputs.rust-version }} + targets: x86_64-unknown-linux-musl components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 886a5bc0b..32fed0f6f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: push: branches: - main - tags: ["v*", "*"] + tags: [ "v*", "*" ] jobs: build-rustfs: @@ -16,17 +16,17 @@ jobs: strategy: matrix: variant: - - { profile: dev, target: x86_64-unknown-linux-gnu, glibc: "default" } + - { profile: dev, target: x86_64-unknown-linux-musl, glibc: "default" } - { - profile: release, - target: x86_64-unknown-linux-gnu, - glibc: "default", - } + profile: release, + target: x86_64-unknown-linux-musl, + glibc: "default", + } - { - profile: release, - target: x86_64-unknown-linux-gnu, - glibc: "2.31", - } + profile: release, + target: x86_64-unknown-linux-musl, + glibc: "2.31", + } steps: - uses: actions/checkout@v4 @@ -190,7 +190,7 @@ jobs: merge: runs-on: ubuntu-latest - needs: [build-rustfs, build-rustfs-gui] + needs: [ build-rustfs, build-rustfs-gui ] steps: - uses: actions/upload-artifact/merge@v4 with: From 8de029bd7a49238e75f5fac96741894aedd7daf6 Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 7 Apr 2025 17:13:19 +0800 Subject: [PATCH 054/103] update --- .github/actions/setup/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 13eb3b8fe..da6d0b98b 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -20,6 +20,8 @@ runs: shell: bash run: | sudo apt update + apt list --upgradable + sudo apt upgrade -y sudo apt install -y \ musl-tools \ build-essential \ From 212ec9ca6900765cec99acc773bdbe1d4bcc76b9 Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 7 Apr 2025 17:24:13 +0800 Subject: [PATCH 055/103] improve --- .github/actions/setup/action.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index da6d0b98b..a2d3d0588 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -20,16 +20,7 @@ runs: shell: bash run: | sudo apt update - apt list --upgradable - sudo apt upgrade -y - sudo apt install -y \ - musl-tools \ - build-essential \ - lld \ - libdbus-1-dev \ - libwayland-dev \ - libwebkit2gtk-4.1-dev \ - libxdo-dev + sudo apt install -y musl-tools build-essential lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev - uses: arduino/setup-protoc@v3 with: From 96625b42ff523dcae7b4fddd623fc223d5f2920a Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 7 Apr 2025 17:47:43 +0800 Subject: [PATCH 056/103] improve code for build --- .github/actions/setup/action.yml | 1 - .github/workflows/build.yml | 13 +++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index a2d3d0588..c7b62a004 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -33,7 +33,6 @@ runs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ inputs.rust-version }} - targets: x86_64-unknown-linux-musl components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 32fed0f6f..30717df32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,16 +17,9 @@ jobs: matrix: variant: - { profile: dev, target: x86_64-unknown-linux-musl, glibc: "default" } - - { - profile: release, - target: x86_64-unknown-linux-musl, - glibc: "default", - } - - { - profile: release, - target: x86_64-unknown-linux-musl, - glibc: "2.31", - } + - { profile: release, target: x86_64-unknown-linux-musl, glibc: "default" } + - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" } + - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "2.31" } steps: - uses: actions/checkout@v4 From 99b473e229025dc6c60ebf19d45430e849cfb84f Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 7 Apr 2025 17:57:45 +0800 Subject: [PATCH 057/103] install target `x86_64-unknown-linux-musl` --- scripts/build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/build.py b/scripts/build.py index 5d6857a5e..106a25fed 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -34,6 +34,9 @@ def main(args: CliArgs): use_zigbuild = True use_old_glibc = True + if args.target and args.target == "x86_64-unknown-linux-musl": + shell("rustup target add " + args.target) + cmd = ["cargo", "build"] if use_zigbuild: cmd = ["cargo", " zigbuild"] From 0ed8a8dd191b3f40675a9e9a74e9c211f34e61c5 Mon Sep 17 00:00:00 2001 From: Damonxue Date: Tue, 8 Apr 2025 17:32:12 +0800 Subject: [PATCH 058/103] feat: update file access error handling and improve script downloads fix: correct file size retrieval in bitrot verification chore: remove deprecated run.bat and add run.ps1 script --- ecstore/src/disk/local.rs | 11 ++++--- ecstore/src/utils/os/windows.rs | 3 +- rustfs/src/logging/mod.rs | 1 + rustfs/src/storage/ecfs.rs | 38 ++++++++++++------------ rustfs/static/readme.md | 1 - scripts/run.bat | 34 ---------------------- scripts/run.ps1 | 51 +++++++++++++++++++++++++++++++++ scripts/run.sh | 2 +- 8 files changed, 79 insertions(+), 62 deletions(-) delete mode 100644 rustfs/static/readme.md delete mode 100644 scripts/run.bat create mode 100644 scripts/run.ps1 diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 76b5f3ac3..8c0517ca3 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -51,6 +51,7 @@ use path_absolutize::Absolutize; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::io::SeekFrom; +#[cfg(unix)] use std::os::unix::fs::MetadataExt; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; @@ -383,7 +384,7 @@ impl LocalDisk { kind => { if kind.to_string() != "directory not empty" { warn!("delete_file remove_dir {:?} err {}", &delete_path, kind.to_string()); - return Err(Error::from(err)); + return Err(Error::new(DiskError::FileAccessDenied)); } } } @@ -395,7 +396,7 @@ impl LocalDisk { ErrorKind::NotFound => (), _ => { warn!("delete_file remove_file {:?} err {:?}", &delete_path, &err); - return Err(Error::from(err)); + return Err(Error::new(DiskError::FileAccessDenied)); } } } @@ -743,12 +744,10 @@ impl LocalDisk { .await .map_err(os_err_to_file_err)?; - // let mut data = Vec::new(); - // let n = file.read_to_end(&mut data).await?; - let meta = file.metadata().await?; + let file_size = meta.len() as usize; - bitrot_verify(Box::new(file), meta.size() as usize, part_size, algo, sum.to_vec(), shard_size).await + bitrot_verify(Box::new(file), file_size, part_size, algo, sum.to_vec(), shard_size).await } async fn scan_dir( diff --git a/ecstore/src/utils/os/windows.rs b/ecstore/src/utils/os/windows.rs index 432e90e66..a99d7001c 100644 --- a/ecstore/src/utils/os/windows.rs +++ b/ecstore/src/utils/os/windows.rs @@ -1,7 +1,8 @@ #![allow(unsafe_code)] // TODO: audit unsafe code use super::IOStats; -use crate::{disk::Info, error::Result}; +use crate::disk::Info; +use common::error::Result; use std::io::{Error, ErrorKind}; use std::mem; use std::os::windows::ffi::OsStrExt; diff --git a/rustfs/src/logging/mod.rs b/rustfs/src/logging/mod.rs index e69de29bb..8b1378917 100644 --- a/rustfs/src/logging/mod.rs +++ b/rustfs/src/logging/mod.rs @@ -0,0 +1 @@ + diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 3cee79f23..f517220a3 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -586,8 +586,8 @@ impl S3 for FS { .await .is_ok() || authorize_request(&mut req, Action::S3Action(S3Action::GetBucketLocationAction)) - .await - .is_ok() + .await + .is_ok() }) }); } @@ -1256,7 +1256,7 @@ impl S3 for FS { conditions: &conditions, object: "", }) - .await; + .await; let write_olny = PolicySys::is_allowed(&BucketPolicyArgs { bucket: &bucket, @@ -1267,7 +1267,7 @@ impl S3 for FS { conditions: &conditions, object: "", }) - .await; + .await; let is_public = read_olny && write_olny; @@ -1680,11 +1680,11 @@ impl S3 for FS { // TODO: valid target list if let Some(NotificationConfiguration { - event_bridge_configuration, - lambda_function_configurations, - queue_configurations, - topic_configurations, - }) = has_notification_config + event_bridge_configuration, + lambda_function_configurations, + queue_configurations, + topic_configurations, + }) = has_notification_config { Ok(S3Response::new(GetBucketNotificationConfigurationOutput { event_bridge_configuration, @@ -1785,10 +1785,10 @@ impl S3 for FS { // !gs.is_empty() && gs.first().is_some_and(|g| { - g.to_owned() - .permission - .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) - }) + g.to_owned() + .permission + .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) + }) }) }); @@ -1855,10 +1855,10 @@ impl S3 for FS { // !gs.is_empty() && gs.first().is_some_and(|g| { - g.to_owned() - .permission - .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) - }) + g.to_owned() + .permission + .is_some_and(|p| p.as_str() == Permission::FULL_CONTROL) + }) }) }); @@ -1934,9 +1934,9 @@ impl S3 for FS { } #[allow(dead_code)] -pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static +pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static where - S: Stream> + Send + 'static, + S: Stream> + Send + 'static, E: Send + 'static, { AsyncTryStream::::new(|mut y| async move { diff --git a/rustfs/static/readme.md b/rustfs/static/readme.md deleted file mode 100644 index 325303e1a..000000000 --- a/rustfs/static/readme.md +++ /dev/null @@ -1 +0,0 @@ -console static path, do not delete \ No newline at end of file diff --git a/scripts/run.bat b/scripts/run.bat deleted file mode 100644 index 0dd48a448..000000000 --- a/scripts/run.bat +++ /dev/null @@ -1,34 +0,0 @@ -@echo off -rem filepath: run.bat - -if not defined SKIP_BUILD ( - cargo build -p rustfs --bins -) - -set current_dir=%cd% - -if not exist .\target\volume\test mkdir .\target\volume\test - -if not defined RUST_LOG ( - set RUST_BACKTRACE=1 - set RUST_LOG=rustfs=debug,ecstore=debug,s3s=debug,iam=debug -) - -rem set RUSTFS_ERASURE_SET_DRIVE_COUNT=5 - -rem set RUSTFS_STORAGE_CLASS_INLINE_BLOCK=512 KB - -rem set RUSTFS_VOLUMES=.\target\volume\test{0...4} -set RUSTFS_VOLUMES=.\target\volume\test -set RUSTFS_ADDRESS=0.0.0.0:9000 -set RUSTFS_CONSOLE_ENABLE=true -set RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 -rem set RUSTFS_SERVER_DOMAINS=localhost:9000 -rem 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 -set RUSTFS_OBS_CONFIG=.\config\obs.example.toml" - -if not "%~1"=="" ( - set RUSTFS_VOLUMES=%~1 -) - -cargo run --bin rustfs \ No newline at end of file diff --git a/scripts/run.ps1 b/scripts/run.ps1 new file mode 100644 index 000000000..a6ab92fb5 --- /dev/null +++ b/scripts/run.ps1 @@ -0,0 +1,51 @@ +# Check if static files need to be downloaded +if (-not (Test-Path .\rustfs\static\index.html)) { + Write-Host "Downloading rustfs-console-latest.zip" + + Invoke-WebRequest -Uri "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -OutFile 'tempfile.zip' + Expand-Archive -Path 'tempfile.zip' -DestinationPath '.\rustfs\static' -Force + Remove-Item tempfile.zip +} + +# Check if build should be skipped +if (-not $env:SKIP_BUILD) { + cargo build -p rustfs --bins +} + +$current_dir = Get-Location + +# Create multiple test directories +$testDirs = @("test0", "test1", "test2", "test3", "test4") +foreach ($dir in $testDirs) { + $path = Join-Path -Path ".\target\volume" -ChildPath $dir + if (-not (Test-Path $path)) { + New-Item -ItemType Directory -Path $path -Force | Out-Null + } +} + +# Set environment variables +if (-not $env:RUST_LOG) { + $env:RUST_BACKTRACE = 1 + $env:RUST_LOG = "rustfs=debug,ecstore=debug,s3s=debug,iam=debug" +} + +# The following environment variables are commented out, uncomment them if needed +# $env:RUSTFS_ERASURE_SET_DRIVE_COUNT = 5 +# $env:RUSTFS_STORAGE_CLASS_INLINE_BLOCK = "512 KB" + +$env:RUSTFS_VOLUMES = ".\target\volume\test{0...4}" +# $env:RUSTFS_VOLUMES = ".\target\volume\test" +$env:RUSTFS_ADDRESS = "127.0.0.1:9000" +$env:RUSTFS_CONSOLE_ENABLE = "true" +$env:RUSTFS_CONSOLE_ADDRESS = "127.0.0.1:9002" +# $env:RUSTFS_SERVER_DOMAINS = "localhost:9000" +# Change to the actual configuration file path, obs.example.toml is for reference only +$env:RUSTFS_OBS_CONFIG = ".\config\obs.example.toml" + +# Check command line arguments +if ($args.Count -gt 0) { + $env:RUSTFS_VOLUMES = $args[0] +} + +# Run the program +cargo run --bin rustfs \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh index cc964beea..4defb1f18 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -39,7 +39,7 @@ fi if [ ! -f ./rustfs/static/index.html ]; then echo "Downloading rustfs-console-latest.zip" # download rustfs-console-latest.zip do not show log - curl -s -L "https://dl.rustfs.com/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip + curl -s -L "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip fi cargo run --bin rustfs \ No newline at end of file From 00a83c56d5e6cb56348fc74f2e6e91f9cb4f796e Mon Sep 17 00:00:00 2001 From: DamonXue Date: Tue, 8 Apr 2025 17:42:02 +0800 Subject: [PATCH 059/103] Update ecstore/src/disk/local.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- ecstore/src/disk/local.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 8c0517ca3..290a80432 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -396,7 +396,10 @@ impl LocalDisk { ErrorKind::NotFound => (), _ => { warn!("delete_file remove_file {:?} err {:?}", &delete_path, &err); - return Err(Error::new(DiskError::FileAccessDenied)); + return Err(Error::new(FileAccessDeniedWithContext { + path: delete_path.clone(), + source: err, + })); } } } From 69e27bfeceb78c5e505b146881a88b92464779ed Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 8 Apr 2025 19:35:21 +0800 Subject: [PATCH 060/103] fix sts download --- rustfs/src/admin/handlers/service_account.rs | 26 ++++++++++++------ rustfs/src/admin/handlers/sts.rs | 5 ++-- rustfs/src/admin/handlers/user.rs | 8 ++++-- rustfs/src/auth.rs | 29 +++++++++++++++----- rustfs/src/storage/access.rs | 26 ++++++++++-------- 5 files changed, 61 insertions(+), 33 deletions(-) diff --git a/rustfs/src/admin/handlers/service_account.rs b/rustfs/src/admin/handlers/service_account.rs index 7d26e9bad..942bf4e59 100644 --- a/rustfs/src/admin/handlers/service_account.rs +++ b/rustfs/src/admin/handlers/service_account.rs @@ -1,4 +1,5 @@ use crate::admin::utils::has_space_be; +use crate::auth::get_session_token; use crate::{admin::router::Operation, auth::check_key_valid}; use http::HeaderMap; use hyper::StatusCode; @@ -29,7 +30,8 @@ impl Operation for AddServiceAccount { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = check_key_valid(&req.headers, &req_cred.access_key).await?; + let (cred, _owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &req_cred.access_key).await?; let mut input = req.input; let body = match input.store_all_unlimited().await { @@ -357,10 +359,13 @@ impl Operation for ListServiceAccount { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = check_key_valid(&req.headers, &input_cred.access_key).await.map_err(|e| { - debug!("check key failed: {e:?}"); - s3_error!(InternalError, "check key failed") - })?; + let (cred, _owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key) + .await + .map_err(|e| { + debug!("check key failed: {e:?}"); + s3_error!(InternalError, "check key failed") + })?; let target_account = if let Some(user) = query.user { if user != input_cred.access_key { @@ -415,10 +420,13 @@ impl Operation for DeleteServiceAccount { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (_cred, _owner) = check_key_valid(&req.headers, &input_cred.access_key).await.map_err(|e| { - debug!("check key failed: {e:?}"); - s3_error!(InternalError, "check key failed") - })?; + let (_cred, _owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key) + .await + .map_err(|e| { + debug!("check key failed: {e:?}"); + s3_error!(InternalError, "check key failed") + })?; let query = { if let Some(query) = req.uri.query() { diff --git a/rustfs/src/admin/handlers/sts.rs b/rustfs/src/admin/handlers/sts.rs index 14efd2222..025866cde 100644 --- a/rustfs/src/admin/handlers/sts.rs +++ b/rustfs/src/admin/handlers/sts.rs @@ -42,12 +42,13 @@ impl Operation for AssumeRoleHandle { let Some(user) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) }; - let session_token = get_session_token(&req.headers); + let session_token = get_session_token(&req.uri, &req.headers); if session_token.is_some() { return Err(s3_error!(InvalidRequest, "AccessDenied1")); } - let (cred, _owner) = check_key_valid(&req.headers, &user.access_key).await?; + let (cred, _owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &user.access_key).await?; // // TODO: 判断权限, 不允许sts访问 if cred.is_temp() || cred.is_service_account() { diff --git a/rustfs/src/admin/handlers/user.rs b/rustfs/src/admin/handlers/user.rs index ae55f97f7..06e2b9872 100644 --- a/rustfs/src/admin/handlers/user.rs +++ b/rustfs/src/admin/handlers/user.rs @@ -11,7 +11,7 @@ use tracing::warn; use crate::{ admin::{router::Operation, utils::has_space_be}, - auth::check_key_valid, + auth::{check_key_valid, get_session_token}, }; #[derive(Debug, Deserialize, Default)] @@ -39,7 +39,8 @@ impl Operation for AddUser { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = check_key_valid(&req.headers, &input_cred.access_key).await?; + let (cred, _owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; let ak = query.access_key.as_deref().unwrap_or_default(); @@ -246,7 +247,8 @@ impl Operation for RemoveUser { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = check_key_valid(&req.headers, &input_cred.access_key).await?; + let (cred, _owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; let sys_cred = get_global_action_cred() .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?; diff --git a/rustfs/src/auth.rs b/rustfs/src/auth.rs index 3d0425535..c3b8ed5f9 100644 --- a/rustfs/src/auth.rs +++ b/rustfs/src/auth.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use http::HeaderMap; +use http::Uri; use iam::error::Error as IamError; use iam::get_global_action_cred; use iam::sys::SESSION_POLICY_NAME; @@ -48,7 +49,7 @@ impl S3Auth for IAMAuth { } // check_key_valid checks the key is valid or not. return the user's credentials and if the user is the owner. -pub async fn check_key_valid(header: &HeaderMap, access_key: &str) -> S3Result<(auth::Credentials, bool)> { +pub async fn check_key_valid(session_token: &str, access_key: &str) -> S3Result<(auth::Credentials, bool)> { let Some(mut cred) = get_global_action_cred() else { return Err(S3Error::with_message( S3ErrorCode::InternalError, @@ -88,7 +89,7 @@ pub async fn check_key_valid(header: &HeaderMap, access_key: &str) -> S3Result<( cred = u.credentials; } - let claims = check_claims_from_token(header, &cred) + let claims = check_claims_from_token(session_token, &cred) .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("check claims failed {}", e)))?; cred.claims = if !claims.is_empty() { Some(claims) } else { None }; @@ -105,9 +106,7 @@ pub async fn check_key_valid(header: &HeaderMap, access_key: &str) -> S3Result<( Ok((cred, owner)) } -pub fn check_claims_from_token(header: &HeaderMap, cred: &auth::Credentials) -> S3Result> { - let token = get_session_token(header).unwrap_or_default(); - +pub fn check_claims_from_token(token: &str, cred: &auth::Credentials) -> S3Result> { if !token.is_empty() && cred.access_key.is_empty() { return Err(s3_error!(InvalidRequest, "no access key")); } @@ -149,8 +148,10 @@ pub fn check_claims_from_token(header: &HeaderMap, cred: &auth::Credentials) -> Ok(HashMap::new()) } -pub fn get_session_token(hds: &HeaderMap) -> Option<&str> { - hds.get("x-amz-security-token").map(|v| v.to_str().unwrap_or_default()) +pub fn get_session_token<'a>(uri: &'a Uri, hds: &'a HeaderMap) -> Option<&'a str> { + hds.get("x-amz-security-token") + .map(|v| v.to_str().unwrap_or_default()) + .or_else(|| get_query_param(uri.query().unwrap_or_default(), "x-amz-security-token")) } pub fn get_condition_values(header: &HeaderMap, cred: &auth::Credentials) -> HashMap> { @@ -295,3 +296,17 @@ pub fn get_condition_values(header: &HeaderMap, cred: &auth::Credentials) -> Has args } + +pub fn get_query_param<'a>(url: &'a str, param_name: &str) -> Option<&'a str> { + let query_start = url.find('?')?; + let query = &url[query_start + 1..]; + for pair in query.split('&') { + let mut parts = pair.splitn(2, '='); + if let (Some(key), Some(value)) = (parts.next(), parts.next()) { + if key.to_lowercase() == param_name { + return Some(value); + } + } + } + None +} diff --git a/rustfs/src/storage/access.rs b/rustfs/src/storage/access.rs index 0e1562cad..fc6bb0b62 100644 --- a/rustfs/src/storage/access.rs +++ b/rustfs/src/storage/access.rs @@ -1,5 +1,5 @@ use super::ecfs::FS; -use crate::auth::{check_key_valid, get_condition_values}; +use crate::auth::{check_key_valid, get_condition_values, get_session_token}; use ecstore::bucket::policy_sys::PolicySys; use iam::error::Error as IamError; use policy::auth; @@ -8,6 +8,7 @@ use policy::policy::{Args, BucketPolicyArgs}; use s3s::access::{S3Access, S3AccessContext}; use s3s::{dto::*, s3_error, S3Error, S3ErrorCode, S3Request, S3Result}; use std::collections::HashMap; +use tracing::info; #[allow(dead_code)] #[derive(Default, Clone)] @@ -143,19 +144,20 @@ impl S3Access for FS { // /// + [`cx.extensions_mut()`](S3AccessContext::extensions_mut) async fn check(&self, cx: &mut S3AccessContext<'_>) -> S3Result<()> { // 上层验证了 ak/sk - // info!( - // "s3 check uri: {:?}, method: {:?} path: {:?}, s3_op: {:?}, cred: {:?}, headers:{:?}", - // cx.uri(), - // cx.method(), - // cx.s3_path(), - // cx.s3_op().name(), - // cx.credentials(), - // cx.headers(), - // // cx.extensions_mut(), - // ); + info!( + "s3 check uri: {:?}, method: {:?} path: {:?}, s3_op: {:?}, cred: {:?}, headers:{:?}", + cx.uri(), + cx.method(), + cx.s3_path(), + cx.s3_op().name(), + cx.credentials(), + cx.headers(), + // cx.extensions_mut(), + ); let (cred, is_owner) = if let Some(input_cred) = cx.credentials() { - let (cred, is_owner) = check_key_valid(cx.headers(), &input_cred.access_key).await?; + let (cred, is_owner) = + check_key_valid(get_session_token(cx.uri(), cx.headers()).unwrap_or_default(), &input_cred.access_key).await?; (Some(cred), is_owner) } else { (None, false) From 3dbdd3888968c1c9d09563bab8c82b035a87a297 Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 8 Apr 2025 22:10:47 +0800 Subject: [PATCH 061/103] rm log --- ecstore/src/heal/data_usage_cache.rs | 2 +- ecstore/src/store_list_objects.rs | 4 ++-- iam/src/manager.rs | 2 +- iam/src/store/object.rs | 2 +- rustfs/src/storage/access.rs | 21 ++++++++++----------- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ecstore/src/heal/data_usage_cache.rs b/ecstore/src/heal/data_usage_cache.rs index 9111d2a7f..cca9d79f3 100644 --- a/ecstore/src/heal/data_usage_cache.rs +++ b/ecstore/src/heal/data_usage_cache.rs @@ -380,7 +380,7 @@ impl DataUsageCache { let mut retries = 0; while retries < 5 { let path = Path::new(BUCKET_META_PREFIX).join(name); - warn!("Loading data usage cache from backend: {}", path.display()); + // warn!("Loading data usage cache from backend: {}", path.display()); match store .get_object_reader( RUSTFS_META_BUCKET, diff --git a/ecstore/src/store_list_objects.rs b/ecstore/src/store_list_objects.rs index 4ebd42e4f..08c671e77 100644 --- a/ecstore/src/store_list_objects.rs +++ b/ecstore/src/store_list_objects.rs @@ -25,7 +25,7 @@ use std::io::ErrorKind; use std::sync::Arc; use tokio::sync::broadcast::{self, Receiver as B_Receiver}; use tokio::sync::mpsc::{self, Receiver, Sender}; -use tracing::{error, warn}; +use tracing::error; use uuid::Uuid; const MAX_OBJECT_LIST: i32 = 1000; @@ -248,7 +248,7 @@ impl ECStore { ..Default::default() }; - warn!("list_objects_generic opts {:?}", &opts); + // warn!("list_objects_generic opts {:?}", &opts); // use get if !opts.prefix.is_empty() && opts.limit == 1 && opts.marker.is_none() { diff --git a/iam/src/manager.rs b/iam/src/manager.rs index 73994e220..19589d36b 100644 --- a/iam/src/manager.rs +++ b/iam/src/manager.rs @@ -135,7 +135,7 @@ where } async fn load(self: Arc) -> Result<()> { - debug!("load iam to cache"); + // debug!("load iam to cache"); self.api.load_all(&self.cache).await?; self.last_timestamp .store(OffsetDateTime::now_utc().unix_timestamp(), Ordering::Relaxed); diff --git a/iam/src/store/object.rs b/iam/src/store/object.rs index 20ab01289..7642fe2ea 100644 --- a/iam/src/store/object.rs +++ b/iam/src/store/object.rs @@ -133,7 +133,7 @@ impl ObjectStore { } async fn list_iam_config_items(&self, prefix: &str, ctx_rx: B_Receiver, sender: Sender) { - debug!("list iam config items, prefix: {}", &prefix); + // debug!("list iam config items, prefix: {}", &prefix); // todo, 实现walk,使用walk diff --git a/rustfs/src/storage/access.rs b/rustfs/src/storage/access.rs index fc6bb0b62..a3a3b0da3 100644 --- a/rustfs/src/storage/access.rs +++ b/rustfs/src/storage/access.rs @@ -8,7 +8,6 @@ use policy::policy::{Args, BucketPolicyArgs}; use s3s::access::{S3Access, S3AccessContext}; use s3s::{dto::*, s3_error, S3Error, S3ErrorCode, S3Request, S3Result}; use std::collections::HashMap; -use tracing::info; #[allow(dead_code)] #[derive(Default, Clone)] @@ -144,16 +143,16 @@ impl S3Access for FS { // /// + [`cx.extensions_mut()`](S3AccessContext::extensions_mut) async fn check(&self, cx: &mut S3AccessContext<'_>) -> S3Result<()> { // 上层验证了 ak/sk - info!( - "s3 check uri: {:?}, method: {:?} path: {:?}, s3_op: {:?}, cred: {:?}, headers:{:?}", - cx.uri(), - cx.method(), - cx.s3_path(), - cx.s3_op().name(), - cx.credentials(), - cx.headers(), - // cx.extensions_mut(), - ); + // info!( + // "s3 check uri: {:?}, method: {:?} path: {:?}, s3_op: {:?}, cred: {:?}, headers:{:?}", + // cx.uri(), + // cx.method(), + // cx.s3_path(), + // cx.s3_op().name(), + // cx.credentials(), + // cx.headers(), + // // cx.extensions_mut(), + // ); let (cred, is_owner) = if let Some(input_cred) = cx.credentials() { let (cred, is_owner) = From 885944802af2f9cc9d1dc6bacbca9c0526f339a7 Mon Sep 17 00:00:00 2001 From: weisd Date: Mon, 7 Apr 2025 17:13:43 +0800 Subject: [PATCH 062/103] license api --- Cargo.lock | 124 ++++++++++++++++++++++++++++++++++- Cargo.toml | 2 +- appauth/Cargo.toml | 19 ++++++ appauth/src/lib.rs | 1 + appauth/src/token.rs | 110 +++++++++++++++++++++++++++++++ rustfs/Cargo.toml | 1 + rustfs/src/config/mod.rs | 17 +++++ rustfs/src/console.rs | 24 +++++++ rustfs/src/license.rs | 29 ++++++++ rustfs/src/main.rs | 4 ++ rustfs/src/storage/access.rs | 6 ++ 11 files changed, 335 insertions(+), 2 deletions(-) create mode 100644 appauth/Cargo.toml create mode 100644 appauth/src/lib.rs create mode 100644 appauth/src/token.rs create mode 100644 rustfs/src/license.rs diff --git a/Cargo.lock b/Cargo.lock index a10f342d6..d2c5ee8e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,6 +200,19 @@ dependencies = [ "url", ] +[[package]] +name = "appauth" +version = "0.0.1" +dependencies = [ + "base64-simd", + "common", + "hex-simd", + "rand 0.8.5", + "rsa", + "serde", + "serde_json", +] + [[package]] name = "arc-swap" version = "1.7.1" @@ -1418,6 +1431,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "const-oid" version = "0.10.0" @@ -2314,6 +2333,17 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid 0.9.6", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.4.1" @@ -2375,6 +2405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid 0.9.6", "crypto-common 0.1.6", "subtle", ] @@ -2386,7 +2417,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c478574b20020306f98d61c8ca3322d762e1ff08117422ac6106438605ea516" dependencies = [ "block-buffer 0.11.0-rc.4", - "const-oid", + "const-oid 0.10.0", "crypto-common 0.2.0-rc.2", "subtle", ] @@ -4510,6 +4541,9 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "lazycell" @@ -5149,6 +5183,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-complex" version = "0.4.6" @@ -5849,6 +5900,15 @@ dependencies = [ "serde", ] +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -6083,6 +6143,27 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.32" @@ -6919,6 +7000,26 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "rsa" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +dependencies = [ + "const-oid 0.9.6", + "digest 0.10.7", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rust-embed" version = "8.6.0" @@ -6997,6 +7098,7 @@ name = "rustfs" version = "0.1.0" dependencies = [ "api", + "appauth", "async-trait", "atoi", "axum", @@ -7638,6 +7740,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -7798,6 +7910,16 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "sqlparser" version = "0.54.0" diff --git a/Cargo.toml b/Cargo.toml index 76edbe035..01c6f98bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ members = [ "cli/rustfs-gui", # Graphical user interface client "packages/obs", # Observability utilities "s3select/api", - "s3select/query", + "s3select/query", "appauth", ] resolver = "2" diff --git a/appauth/Cargo.toml b/appauth/Cargo.toml new file mode 100644 index 000000000..b638313e1 --- /dev/null +++ b/appauth/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "appauth" +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +version.workspace = true + +[dependencies] +base64-simd = "0.8.0" +common.workspace = true +hex-simd = "0.8.0" +rand.workspace = true +rsa = "0.9.8" +serde.workspace = true +serde_json.workspace = true + +[lints] +workspace = true diff --git a/appauth/src/lib.rs b/appauth/src/lib.rs new file mode 100644 index 000000000..79c66ba63 --- /dev/null +++ b/appauth/src/lib.rs @@ -0,0 +1 @@ +pub mod token; diff --git a/appauth/src/token.rs b/appauth/src/token.rs new file mode 100644 index 000000000..6be037dd5 --- /dev/null +++ b/appauth/src/token.rs @@ -0,0 +1,110 @@ +use common::error::Result; +use rsa::Pkcs1v15Encrypt; +use rsa::{ + pkcs8::{DecodePrivateKey, DecodePublicKey}, + RsaPrivateKey, RsaPublicKey, +}; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug)] +pub struct Token { + pub name: String, // 应用ID + pub expired: u64, // 到期时间 (UNIX时间戳) +} + +// 公钥生成Token +// [token] Token对象 +// [key] 公钥字符串 +// 返回base64处理的加密字符串 +pub fn gencode(token: &Token, key: &str) -> Result { + let data = serde_json::to_vec(token)?; + let public_key = RsaPublicKey::from_public_key_pem(key)?; + let encrypted_data = public_key.encrypt(&mut rand::thread_rng(), Pkcs1v15Encrypt, &data)?; + Ok(base64_simd::URL_SAFE_NO_PAD.encode_to_string(&encrypted_data)) +} + +// 私钥解析Token +// [token] base64处理的加密字符串 +// [key] 私钥字符串 +// 返回Token对象 +pub fn parse(token: &str, key: &str) -> Result { + let encrypted_data = base64_simd::URL_SAFE_NO_PAD.decode_to_vec(token.as_bytes())?; + let private_key = RsaPrivateKey::from_pkcs8_pem(key)?; + let decrypted_data = private_key.decrypt(Pkcs1v15Encrypt, &encrypted_data)?; + let res: Token = serde_json::from_slice(&decrypted_data)?; + Ok(res) +} + +pub fn parse_license(license: &str) -> Result { + parse(license, TEST_PRIVATE_KEY) + // match parse(license, TEST_PRIVATE_KEY) { + // Ok(token) => { + // if token.expired > SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() { + // Ok(token) + // } else { + // Err("Token expired".into()) + // } + // } + // Err(e) => Err(e), + // } +} + +static TEST_PRIVATE_KEY:&str ="-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCj86SrJIuxSxR6\nBJ/dlJEUIj6NeBRnhLQlCDdovuz61+7kJXVcxaR66w4m8W7SLEUP+IlPtnn6vmiG\n7XMhGNHIr7r1JsEVVLhZmL3tKI66DEZl786ZhG81BWqUlmcooIPS8UEPZNqJXLuz\nVGhxNyVGbj/tV7QC2pSISnKaixc+nrhxvo7w56p5qrm9tik0PjTgfZsUePkoBsSN\npoRkAauS14MAzK6HGB75CzG3dZqXUNWSWVocoWtQbZUwFGXyzU01ammsHQDvc2xu\nK1RQpd1qYH5bOWZ0N0aPFwT0r59HztFXg9sbjsnuhO1A7OiUOkc6iGVuJ0wm/9nA\nwZIBqzgjAgMBAAECggEAPMpeSEbotPhNw2BrllE76ec4omPfzPJbiU+em+wPGoNu\nRJHPDnMKJbl6Kd5jZPKdOOrCnxfd6qcnQsBQa/kz7+GYxMV12l7ra+1Cnujm4v0i\nLTHZvPpp8ZLsjeOmpF3AAzsJEJgon74OqtOlVjVIUPEYKvzV9ijt4gsYq0zfdYv0\nhrTMzyrGM4/UvKLsFIBROAfCeWfA7sXLGH8JhrRAyDrtCPzGtyyAmzoHKHtHafcB\nuyPFw/IP8otAgpDk5iiQPNkH0WwzAQIm12oHuNUa66NwUK4WEjXTnDg8KeWLHHNv\nIfN8vdbZchMUpMIvvkr7is315d8f2cHCB5gEO+GWAQKBgQDR/0xNll+FYaiUKCPZ\nvkOCAd3l5mRhsqnjPQ/6Ul1lAyYWpoJSFMrGGn/WKTa/FVFJRTGbBjwP+Mx10bfb\ngUg2GILDTISUh54fp4zngvTi9w4MWGKXrb7I1jPkM3vbJfC/v2fraQ/r7qHPpO2L\nf6ZbGxasIlSvr37KeGoelwcAQQKBgQDH3hmOTS2Hl6D4EXdq5meHKrfeoicGN7m8\noQK7u8iwn1R9zK5nh6IXxBhKYNXNwdCQtBZVRvFjjZ56SZJb7lKqa1BcTsgJfZCy\nnI3Uu4UykrECAH8AVCVqBXUDJmeA2yE+gDAtYEjvhSDHpUfWxoGHr0B/Oqk2Lxc/\npRy1qV5fYwKBgBWSL/hYVf+RhIuTg/s9/BlCr9SJ0g3nGGRrRVTlWQqjRCpXeFOO\nJzYqSq9pFGKUggEQxoOyJEFPwVDo9gXqRcyov+Xn2kaXl7qQr3yoixc1YZALFDWY\nd1ySBEqQr0xXnV9U/gvEgwotPRnjSzNlLWV2ZuHPtPtG/7M0o1H5GZMBAoGAKr3N\nW0gX53o+my4pCnxRQW+aOIsWq1a5aqRIEFudFGBOUkS2Oz+fI1P1GdrRfhnnfzpz\n2DK+plp/vIkFOpGhrf4bBlJ2psjqa7fdANRFLMaAAfyXLDvScHTQTCcnVUAHQPVq\n2BlSH56pnugyj7SNuLV6pnql+wdhAmRN2m9o1h8CgYAbX2juSr4ioXwnYjOUdrIY\n4+ERvHcXdjoJmmPcAm4y5NbSqLXyU0FQmplNMt2A5LlniWVJ9KNdjAQUt60FZw/+\nr76LdxXaHNZghyx0BOs7mtq5unSQXamZ8KixasfhE9uz3ij1jXjG6hafWkS8/68I\nuWbaZqgvy7a9oPHYlKH7Jg==\n-----END PRIVATE KEY-----\n"; + +#[cfg(test)] +mod tests { + use super::*; + use rsa::{ + pkcs8::{EncodePrivateKey, EncodePublicKey, LineEnding}, + RsaPrivateKey, + }; + use std::time::{SystemTime, UNIX_EPOCH}; + #[test] + fn test_gencode_and_parse() { + let mut rng = rand::thread_rng(); + let bits = 2048; + let private_key = RsaPrivateKey::new(&mut rng, bits).expect("Failed to generate private key"); + let public_key = RsaPublicKey::from(&private_key); + + let private_key_pem = private_key.to_pkcs8_pem(LineEnding::LF).unwrap(); + let public_key_pem = public_key.to_public_key_pem(LineEnding::LF).unwrap(); + + let token = Token { + name: "test_app".to_string(), + expired: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() + 3600, // 1 hour from now + }; + + let encoded = gencode(&token, &public_key_pem).expect("Failed to encode token"); + + let decoded = parse(&encoded, &private_key_pem).expect("Failed to decode token"); + + assert_eq!(token.name, decoded.name); + assert_eq!(token.expired, decoded.expired); + } + + #[test] + fn test_parse_invalid_token() { + let private_key_pem = RsaPrivateKey::new(&mut rand::thread_rng(), 2048) + .expect("Failed to generate private key") + .to_pkcs8_pem(LineEnding::LF) + .unwrap(); + + let invalid_token = "invalid_base64_token"; + let result = parse(invalid_token, &private_key_pem); + + assert!(result.is_err()); + } + + #[test] + fn test_gencode_with_invalid_key() { + let token = Token { + name: "test_app".to_string(), + expired: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() + 3600, // 1 hour from now + }; + + let invalid_key = "invalid_public_key"; + let result = gencode(&token, invalid_key); + + assert!(result.is_err()); + } +} diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index db348d89a..153db6bce 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -87,6 +87,7 @@ rust-embed = { workspace = true, features = ["interpolate-folder-path"] } local-ip-address = { workspace = true } chrono = { workspace = true } rustfs-obs = { workspace = true } +appauth = { version = "0.0.1", path = "../appauth" } [build-dependencies] prost-build.workspace = true diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index f955ccc78..673cffc80 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -2,6 +2,7 @@ use clap::Parser; use const_str::concat; use ecstore::global::DEFAULT_PORT; use std::string::ToString; +use std::sync::OnceLock; shadow_rs::shadow!(build); @@ -100,4 +101,20 @@ pub struct Opt { /// tls path for rustfs api and console. #[arg(long, env = "RUSTFS_TLS_PATH")] pub tls_path: Option, + + #[arg(long, env = "RUSTFS_LICENSE")] + pub license: Option, +} + +lazy_static::lazy_static! { + pub static ref OPT: OnceLock = OnceLock::new(); +} + +pub fn init_config() { + let opt = Opt::parse(); + OPT.set(opt).expect("Failed to set global config"); +} + +pub fn get_config() -> &'static Opt { + OPT.get().expect("Global config not initialized") } diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index 602997b64..5ed9dc37e 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -1,3 +1,4 @@ +use crate::config; use axum::{ body::Body, extract::Host, @@ -158,6 +159,28 @@ pub(crate) fn init_console_cfg(local_ip: Ipv4Addr, port: u16) { // host.parse::().is_ok() || host.parse::().is_ok() // } +async fn license_handler() -> impl IntoResponse { + let license = config::get_config() + .license + .as_ref() + .map(|license| { + if license.is_empty() { + return None; + } + match appauth::token::parse_license(license) { + Ok(token) => Some(token), + Err(_) => None, + } + }) + .unwrap_or_default(); + + Response::builder() + .header("content-type", "application/json") + .status(StatusCode::OK) + .body(Body::from(serde_json::to_string(&license).unwrap_or_default())) + .unwrap() +} + #[allow(clippy::const_is_empty)] async fn config_handler(Host(host): Host) -> impl IntoResponse { let host_with_port = if host.contains(':') { host } else { format!("{}:80", host) }; @@ -203,6 +226,7 @@ pub async fn start_static_file_server( ) { // Create a route let app = Router::new() + .route("/license", get(license_handler)) .route("/config.json", get(config_handler)) .nest_service("/", get(static_handler)); let local_addr: SocketAddr = addrs.parse().expect("Failed to parse socket address"); diff --git a/rustfs/src/license.rs b/rustfs/src/license.rs new file mode 100644 index 000000000..752c10457 --- /dev/null +++ b/rustfs/src/license.rs @@ -0,0 +1,29 @@ +use crate::config; +use common::error::{Error, Result}; +use std::time::SystemTime; +use std::time::UNIX_EPOCH; +use tracing::error; +use tracing::info; + +pub fn license_check() -> Result<()> { + let inval_license = config::get_config().license.as_ref().map(|license| { + if license.is_empty() { + error!("License is empty"); + return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); + } + let token = appauth::token::parse_license(license)?; + if token.expired < SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() { + error!("License expired"); + return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); + } + + info!("License is valid ! expired at {}", token.expired); + Ok(()) + }); + + if inval_license.is_none() || inval_license.is_some_and(|v| v.is_err()) { + return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); + } + + Ok(()) +} diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 318594cbf..572665d2b 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -3,6 +3,7 @@ mod auth; mod config; mod console; mod grpc; +pub mod license; mod logging; mod service; mod storage; @@ -11,6 +12,7 @@ mod utils; use crate::auth::IAMAuth; use crate::console::{init_console_cfg, CONSOLE_CONFIG}; use crate::utils::error; +// Ensure the correct path for parse_license is imported use chrono::Datelike; use clap::Parser; use common::{ @@ -92,6 +94,8 @@ fn print_server_info() { #[tokio::main] async fn main() -> Result<()> { + config::init_config(); + // Parse the obtained parameters let opt = config::Opt::parse(); diff --git a/rustfs/src/storage/access.rs b/rustfs/src/storage/access.rs index a3a3b0da3..e2cad0c07 100644 --- a/rustfs/src/storage/access.rs +++ b/rustfs/src/storage/access.rs @@ -1,5 +1,6 @@ use super::ecfs::FS; use crate::auth::{check_key_valid, get_condition_values, get_session_token}; +use crate::license::license_check; use ecstore::bucket::policy_sys::PolicySys; use iam::error::Error as IamError; use policy::auth; @@ -180,6 +181,8 @@ impl S3Access for FS { /// /// This method returns `Ok(())` by default. async fn create_bucket(&self, req: &mut S3Request) -> S3Result<()> { + license_check().map_err(|er| s3_error!(AccessDenied, "{:?}", er.to_string()))?; + let req_info = req.extensions.get_mut::().expect("ReqInfo not found"); req_info.bucket = Some(req.input.bucket.clone()); @@ -241,6 +244,7 @@ impl S3Access for FS { /// /// This method returns `Ok(())` by default. async fn create_multipart_upload(&self, _req: &mut S3Request) -> S3Result<()> { + license_check().map_err(|er| s3_error!(AccessDenied, "{:?}", er.to_string()))?; Ok(()) } @@ -995,6 +999,8 @@ impl S3Access for FS { /// /// This method returns `Ok(())` by default. async fn put_object(&self, req: &mut S3Request) -> S3Result<()> { + license_check().map_err(|er| s3_error!(AccessDenied, "{:?}", er.to_string()))?; + let req_info = req.extensions.get_mut::().expect("ReqInfo not found"); req_info.bucket = Some(req.input.bucket.clone()); req_info.object = Some(req.input.key.clone()); From d29bfcca9a7b594b44da9d576452915048ee61c0 Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 8 Apr 2025 17:46:46 +0800 Subject: [PATCH 063/103] cache license --- appauth/src/token.rs | 2 +- rustfs/src/config/mod.rs | 22 ++++++++---------- rustfs/src/console.rs | 16 ++----------- rustfs/src/license.rs | 49 ++++++++++++++++++++++++++++++++-------- rustfs/src/main.rs | 5 +++- 5 files changed, 57 insertions(+), 37 deletions(-) diff --git a/appauth/src/token.rs b/appauth/src/token.rs index 6be037dd5..f18ae57f7 100644 --- a/appauth/src/token.rs +++ b/appauth/src/token.rs @@ -6,7 +6,7 @@ use rsa::{ }; use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Default, Clone)] pub struct Token { pub name: String, // 应用ID pub expired: u64, // 到期时间 (UNIX时间戳) diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index 673cffc80..54dbc8d03 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -2,8 +2,6 @@ use clap::Parser; use const_str::concat; use ecstore::global::DEFAULT_PORT; use std::string::ToString; -use std::sync::OnceLock; - shadow_rs::shadow!(build); /// Default Access Key @@ -106,15 +104,15 @@ pub struct Opt { pub license: Option, } -lazy_static::lazy_static! { - pub static ref OPT: OnceLock = OnceLock::new(); -} +// lazy_static::lazy_static! { +// pub static ref OPT: OnceLock = OnceLock::new(); +// } -pub fn init_config() { - let opt = Opt::parse(); - OPT.set(opt).expect("Failed to set global config"); -} +// pub fn init_config() { +// let opt = Opt::parse(); +// OPT.set(opt).expect("Failed to set global config"); +// } -pub fn get_config() -> &'static Opt { - OPT.get().expect("Global config not initialized") -} +// pub fn get_config() -> &'static Opt { +// OPT.get().expect("Global config not initialized") +// } diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index 5ed9dc37e..bf50a4239 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -1,4 +1,4 @@ -use crate::config; +use crate::license::get_license; use axum::{ body::Body, extract::Host, @@ -160,19 +160,7 @@ pub(crate) fn init_console_cfg(local_ip: Ipv4Addr, port: u16) { // } async fn license_handler() -> impl IntoResponse { - let license = config::get_config() - .license - .as_ref() - .map(|license| { - if license.is_empty() { - return None; - } - match appauth::token::parse_license(license) { - Ok(token) => Some(token), - Err(_) => None, - } - }) - .unwrap_or_default(); + let license = get_license().unwrap_or_default(); Response::builder() .header("content-type", "application/json") diff --git a/rustfs/src/license.rs b/rustfs/src/license.rs index 752c10457..58daa1955 100644 --- a/rustfs/src/license.rs +++ b/rustfs/src/license.rs @@ -1,26 +1,57 @@ -use crate::config; +use appauth::token::Token; use common::error::{Error, Result}; +use std::sync::OnceLock; use std::time::SystemTime; use std::time::UNIX_EPOCH; use tracing::error; use tracing::info; +lazy_static::lazy_static! { + static ref LICENSE: OnceLock = OnceLock::new(); +} + +pub fn init_license(license: Option) { + if license.is_none() { + error!("License is None"); + return; + } + let license = license.unwrap(); + let token = appauth::token::parse_license(&license).unwrap_or_default(); + + LICENSE.set(token).unwrap_or_else(|_| { + error!("Failed to set license"); + }); +} + +pub fn get_license() -> Option { + LICENSE.get().cloned() +} + pub fn license_check() -> Result<()> { - let inval_license = config::get_config().license.as_ref().map(|license| { - if license.is_empty() { - error!("License is empty"); - return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); - } - let token = appauth::token::parse_license(license)?; - if token.expired < SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() { + let inval_license = LICENSE.get().map(|token| { + if token.expired < SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() { error!("License expired"); return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); } - info!("License is valid ! expired at {}", token.expired); Ok(()) }); + // let inval_license = config::get_config().license.as_ref().map(|license| { + // if license.is_empty() { + // error!("License is empty"); + // return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); + // } + // let token = appauth::token::parse_license(license)?; + // if token.expired < SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() { + // error!("License expired"); + // return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); + // } + + // info!("License is valid ! expired at {}", token.expired); + // Ok(()) + // }); + if inval_license.is_none() || inval_license.is_some_and(|v| v.is_err()) { return Err(Error::from_string("Incorrect license, please contact RustFS.".to_string())); } diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 572665d2b..4481525bb 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -37,6 +37,7 @@ use hyper_util::{ service::TowerToHyperService, }; use iam::init_iam_sys; +use license::init_license; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; use rustfs_obs::{init_obs, load_config, set_global_guard, InitLogStatus}; use rustls::ServerConfig; @@ -94,11 +95,13 @@ fn print_server_info() { #[tokio::main] async fn main() -> Result<()> { - config::init_config(); + // config::init_config(); // Parse the obtained parameters let opt = config::Opt::parse(); + init_license(opt.license.clone()); + // Load the configuration file let config = load_config(Some(opt.clone().obs_config)); From 5188d00a099c3d8be303db390c2ca0d2c7b9e610 Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 8 Apr 2025 22:27:39 +0800 Subject: [PATCH 064/103] merge license --- iam/src/lib.rs | 2 +- iam/src/manager.rs | 2 +- iam/src/store/object.rs | 2 +- rustfs/src/license.rs | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/iam/src/lib.rs b/iam/src/lib.rs index 5d3ca626c..a37c0d916 100644 --- a/iam/src/lib.rs +++ b/iam/src/lib.rs @@ -51,7 +51,7 @@ pub fn get_global_action_cred() -> Option { GLOBAL_ACTIVE_CRED.get().cloned() } -#[instrument] +#[instrument(skip(ecstore))] pub async fn init_iam_sys(ecstore: Arc) -> Result<()> { debug!("init iam system"); let s = IamCache::new(ObjectStore::new(ecstore)).await; diff --git a/iam/src/manager.rs b/iam/src/manager.rs index 19589d36b..2eb8a6f0e 100644 --- a/iam/src/manager.rs +++ b/iam/src/manager.rs @@ -39,7 +39,7 @@ use tokio::{ }, }; use tracing::error; -use tracing::{debug, warn}; +use tracing::warn; const IAM_FORMAT_FILE: &str = "format.json"; const IAM_FORMAT_VERSION_1: i32 = 1; diff --git a/iam/src/store/object.rs b/iam/src/store/object.rs index 7642fe2ea..cf365f562 100644 --- a/iam/src/store/object.rs +++ b/iam/src/store/object.rs @@ -24,7 +24,7 @@ use serde::{de::DeserializeOwned, Serialize}; use std::{collections::HashMap, sync::Arc}; use tokio::sync::broadcast::{self, Receiver as B_Receiver}; use tokio::sync::mpsc::{self, Sender}; -use tracing::{debug, info, warn}; +use tracing::{info, warn}; lazy_static! { pub static ref IAM_CONFIG_PREFIX: String = format!("{}/iam", RUSTFS_CONFIG_PREFIX); diff --git a/rustfs/src/license.rs b/rustfs/src/license.rs index 58daa1955..25d09c82c 100644 --- a/rustfs/src/license.rs +++ b/rustfs/src/license.rs @@ -27,7 +27,9 @@ pub fn get_license() -> Option { LICENSE.get().cloned() } +#[allow(unreachable_code)] pub fn license_check() -> Result<()> { + return Ok(()); let inval_license = LICENSE.get().map(|token| { if token.expired < SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() { error!("License expired"); From 2ae76618101bda7909da0c9d04db1349df2155e1 Mon Sep 17 00:00:00 2001 From: weisd Date: Tue, 8 Apr 2025 22:52:13 +0800 Subject: [PATCH 065/103] fix sts download --- rustfs/src/auth.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rustfs/src/auth.rs b/rustfs/src/auth.rs index c3b8ed5f9..6102960b7 100644 --- a/rustfs/src/auth.rs +++ b/rustfs/src/auth.rs @@ -297,9 +297,9 @@ pub fn get_condition_values(header: &HeaderMap, cred: &auth::Credentials) -> Has args } -pub fn get_query_param<'a>(url: &'a str, param_name: &str) -> Option<&'a str> { - let query_start = url.find('?')?; - let query = &url[query_start + 1..]; +pub fn get_query_param<'a>(query: &'a str, param_name: &str) -> Option<&'a str> { + let param_name = param_name.to_lowercase(); + for pair in query.split('&') { let mut parts = pair.splitn(2, '='); if let (Some(key), Some(value)) = (parts.next(), parts.next()) { From 9964457d09fde7b4f6fb4775f7cc4d5738bda5b6 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 8 Apr 2025 23:26:02 +0800 Subject: [PATCH 066/103] upgrade opentelemetry version from 0.29 to 0.29.1 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2c5ee8e4..1c80462af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5538,9 +5538,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "opentelemetry" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "768ee97dc5cd695a4dd4a69a0678fb42789666b5a89e8c0af48bb06c6e427120" +checksum = "9e87237e2775f74896f9ad219d26a2081751187eb7c9f5c58dde20a23b95d16c" dependencies = [ "futures-core", "futures-sink", diff --git a/Cargo.toml b/Cargo.toml index 01c6f98bb..6d64ea33a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,7 @@ local-ip-address = "0.6.3" mime = "0.3.17" netif = "0.1.6" once_cell = "1.21.1" -opentelemetry = { version = "0.29" } +opentelemetry = { version = "0.29.1" } opentelemetry-appender-tracing = { version = "0.29.1", features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { version = "0.29" } opentelemetry-stdout = { version = "0.29.0" } From f6b734ca69d0837c8e38ab46729305198b4151c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 15:33:56 +0000 Subject: [PATCH 067/103] Bump the dependencies group across 1 directory with 3 updates Bumps the dependencies group with 3 updates in the / directory: [rand](https://github.com/rust-random/rand), [tokio](https://github.com/tokio-rs/tokio) and [object_store](https://github.com/apache/arrow-rs). Updates `rand` from 0.8.5 to 0.9.0 - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.8.5...0.9.0) Updates `tokio` from 1.44.1 to 1.44.2 - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.44.1...tokio-1.44.2) Updates `object_store` from 0.11.2 to 0.12.0 - [Release notes](https://github.com/apache/arrow-rs/releases) - [Changelog](https://github.com/apache/arrow-rs/blob/main/CHANGELOG-old.md) - [Commits](https://github.com/apache/arrow-rs/compare/object_store_0.11.2...object_store_0.12.0) --- updated-dependencies: - dependency-name: rand dependency-version: 0.9.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: tokio dependency-version: 1.44.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: object_store dependency-version: 0.12.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies ... Signed-off-by: dependabot[bot] --- Cargo.lock | 52 +++++++++++++++++++++++++++++------------ Cargo.toml | 4 ++-- s3select/api/Cargo.toml | 2 +- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c80462af..b55093958 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,7 +190,7 @@ dependencies = [ "futures", "futures-core", "http", - "object_store", + "object_store 0.12.0", "s3s", "snafu", "tokio", @@ -207,7 +207,7 @@ dependencies = [ "base64-simd", "common", "hex-simd", - "rand 0.8.5", + "rand 0.9.0", "rsa", "serde", "serde_json", @@ -1677,7 +1677,7 @@ dependencies = [ "chacha20poly1305", "jsonwebtoken", "pbkdf2", - "rand 0.8.5", + "rand 0.9.0", "serde_json", "sha2 0.10.8", "test-case", @@ -1867,7 +1867,7 @@ dependencies = [ "futures", "itertools 0.14.0", "log", - "object_store", + "object_store 0.11.2", "parking_lot 0.12.3", "parquet", "rand 0.8.5", @@ -1919,7 +1919,7 @@ dependencies = [ "datafusion-physical-plan", "futures", "log", - "object_store", + "object_store 0.11.2", "tokio", ] @@ -1938,7 +1938,7 @@ dependencies = [ "indexmap 2.8.0", "libc", "log", - "object_store", + "object_store 0.11.2", "parquet", "paste", "recursive", @@ -1982,7 +1982,7 @@ dependencies = [ "glob", "itertools 0.14.0", "log", - "object_store", + "object_store 0.11.2", "rand 0.8.5", "tokio", "tokio-util", @@ -2009,7 +2009,7 @@ dependencies = [ "datafusion-expr", "futures", "log", - "object_store", + "object_store 0.11.2", "parking_lot 0.12.3", "rand 0.8.5", "tempfile", @@ -3045,7 +3045,7 @@ dependencies = [ "pin-project-lite", "policy", "protos", - "rand 0.8.5", + "rand 0.9.0", "reed-solomon-erasure", "regex", "reqwest", @@ -4100,7 +4100,7 @@ dependencies = [ "lazy_static", "madmin", "policy", - "rand 0.8.5", + "rand 0.9.0", "regex", "serde", "serde_json", @@ -4760,7 +4760,7 @@ dependencies = [ "common", "lazy_static", "protos", - "rand 0.8.5", + "rand 0.9.0", "serde", "serde_json", "tokio", @@ -5524,6 +5524,28 @@ dependencies = [ "walkdir", ] +[[package]] +name = "object_store" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9ce831b09395f933addbc56d894d889e4b226eba304d4e7adbab591e26daf1e" +dependencies = [ + "async-trait", + "bytes", + "chrono", + "futures", + "http", + "humantime", + "itertools 0.14.0", + "parking_lot 0.12.3", + "percent-encoding", + "thiserror 2.0.12", + "tokio", + "tracing", + "url", + "walkdir", +] + [[package]] name = "once_cell" version = "1.21.3" @@ -5813,7 +5835,7 @@ dependencies = [ "lz4_flex", "num", "num-bigint", - "object_store", + "object_store 0.11.2", "paste", "seq-macro", "simdutf8", @@ -6198,7 +6220,7 @@ dependencies = [ "jsonwebtoken", "lazy_static", "madmin", - "rand 0.8.5", + "rand 0.9.0", "regex", "serde", "serde_json", @@ -8362,9 +8384,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.44.1" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 6d64ea33a..8da54a2f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,7 +82,7 @@ prost-build = "0.13.4" prost-types = "0.13.4" protobuf = "3.7" protos = { path = "./common/protos" } -rand = "0.8.5" +rand = "0.9.0" rdkafka = { version = "0.37", features = ["tokio"] } reqwest = { version = "0.12.15", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream", "json", "blocking"] } rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } @@ -110,7 +110,7 @@ time = { version = "0.3.41", features = [ "macros", "serde", ] } -tokio = { version = "1.44.0", features = ["fs", "rt-multi-thread"] } +tokio = { version = "1.44.2", features = ["fs", "rt-multi-thread"] } tonic = { version = "0.12.3", features = ["gzip"] } tonic-build = "0.12.3" tonic-reflection = "0.12" diff --git a/s3select/api/Cargo.toml b/s3select/api/Cargo.toml index 1936e846a..e8c683665 100644 --- a/s3select/api/Cargo.toml +++ b/s3select/api/Cargo.toml @@ -12,7 +12,7 @@ ecstore.workspace = true futures = { workspace = true } futures-core = "0.3.31" http.workspace = true -object_store = "0.11.2" +object_store = "0.12.0" s3s.workspace = true snafu = { workspace = true, features = ["backtrace"] } tokio.workspace = true From b128cc9db46620ed4f2b3955578b6b99fea56d6b Mon Sep 17 00:00:00 2001 From: DamonXue Date: Wed, 9 Apr 2025 08:13:45 +0800 Subject: [PATCH 068/103] Update ecstore/src/disk/local.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- ecstore/src/disk/local.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 290a80432..13c0ea26d 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -384,7 +384,10 @@ impl LocalDisk { kind => { if kind.to_string() != "directory not empty" { warn!("delete_file remove_dir {:?} err {}", &delete_path, kind.to_string()); - return Err(Error::new(DiskError::FileAccessDenied)); + return Err(Error::new(FileAccessDeniedWithContext { + path: delete_path.clone(), + source: err, + })); } } } From b2f5e28b95b8514c1e5071672642e6f6c630f55d Mon Sep 17 00:00:00 2001 From: Damonxue Date: Wed, 9 Apr 2025 09:25:46 +0800 Subject: [PATCH 069/103] fix: remove duplicate download check for rustfs-console-latest.zip --- scripts/run.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index 4defb1f18..37e703f96 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,5 +1,12 @@ #!/bin/bash -e +# check ./rustfs/static/index.html not exists +if [ ! -f ./rustfs/static/index.html ]; then + echo "Downloading rustfs-console-latest.zip" + # download rustfs-console-latest.zip do not show log + curl -s -L "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip +fi + if [ -z "$SKIP_BUILD" ]; then cargo build -p rustfs --bins fi @@ -34,12 +41,4 @@ if [ -n "$1" ]; then fi - -# check ./rustfs/static/index.html not exists -if [ ! -f ./rustfs/static/index.html ]; then - echo "Downloading rustfs-console-latest.zip" - # download rustfs-console-latest.zip do not show log - curl -s -L "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip -fi - cargo run --bin rustfs \ No newline at end of file From 71d6d9ec484fff157a3466544dff9e419de010e5 Mon Sep 17 00:00:00 2001 From: Damonxue Date: Wed, 9 Apr 2025 10:25:41 +0800 Subject: [PATCH 070/103] feat: add FileAccessDeniedWithContext error type for better file access error handling --- ecstore/src/disk/error.rs | 14 ++++++++++++++ ecstore/src/disk/local.rs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ecstore/src/disk/error.rs b/ecstore/src/disk/error.rs index a0773b5e5..d7ea2854a 100644 --- a/ecstore/src/disk/error.rs +++ b/ecstore/src/disk/error.rs @@ -1,4 +1,5 @@ use std::io::{self, ErrorKind}; +use std::path::PathBuf; use tracing::error; @@ -345,6 +346,19 @@ pub fn os_err_to_file_err(e: io::Error) -> Error { } } +#[derive(Debug, thiserror::Error)] +pub struct FileAccessDeniedWithContext { + pub path: PathBuf, + #[source] + pub source: std::io::Error, +} + +impl std::fmt::Display for FileAccessDeniedWithContext { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "访问文件 '{}' 被拒绝: {}", self.path.display(), self.source) + } +} + pub fn is_unformatted_disk(err: &Error) -> bool { matches!(err.downcast_ref::(), Some(DiskError::UnformattedDisk)) } diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 13c0ea26d..5a69f7615 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -14,7 +14,7 @@ use crate::bucket::metadata_sys::{self}; use crate::cache_value::cache::{Cache, Opts, UpdateFn}; use crate::disk::error::{ convert_access_error, is_err_os_not_exist, is_sys_err_handle_invalid, is_sys_err_invalid_arg, is_sys_err_is_dir, - is_sys_err_not_dir, map_err_not_exists, os_err_to_file_err, + is_sys_err_not_dir, map_err_not_exists, os_err_to_file_err, FileAccessDeniedWithContext }; use crate::disk::os::{check_path_length, is_empty_dir}; use crate::disk::STORAGE_FORMAT_FILE; From ebf1a9d9c48679c3ef1d7049a8bddf5e8b64fb36 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Wed, 9 Apr 2025 02:39:46 +0000 Subject: [PATCH 071/103] update tonic axum Signed-off-by: junxiang Mu <1948535941@qq.com> --- Cargo.lock | 195 +++++++----------- Cargo.toml | 10 +- common/common/Cargo.toml | 2 +- common/protos/Cargo.toml | 2 +- common/protos/build.rs | 2 +- .../src/generated/proto_gen/node_service.rs | 14 +- e2e_test/Cargo.toml | 2 +- rustfs/Cargo.toml | 4 +- 8 files changed, 99 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b55093958..9fb4a60f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -614,28 +614,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "async-stream" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - [[package]] name = "async-task" version = "4.7.1" @@ -722,13 +700,13 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.9" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +checksum = "de45108900e1f9b9242f7f2e254aa3e2c029c921c258fe9e6b4217eeebd54288" dependencies = [ - "async-trait", "axum-core", "bytes", + "form_urlencoded", "futures-util", "http", "http-body", @@ -736,7 +714,7 @@ dependencies = [ "hyper", "hyper-util", "itoa 1.0.15", - "matchit 0.7.3", + "matchit", "memchr", "mime", "percent-encoding", @@ -756,13 +734,12 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.5" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" dependencies = [ - "async-trait", "bytes", - "futures-util", + "futures-core", "http", "http-body", "http-body-util", @@ -777,24 +754,23 @@ dependencies = [ [[package]] name = "axum-server" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad46c3ec4e12f4a4b6835e173ba21c25e484c9d02b49770bf006ce5367c036" +checksum = "495c05f60d6df0093e8fb6e74aa5846a0ad06abaf96d76166283720bf740f8ab" dependencies = [ "arc-swap", "bytes", - "futures-util", + "fs-err", "http", "http-body", - "http-body-util", "hyper", "hyper-util", "pin-project-lite", - "rustls 0.21.12", + "rustls", "rustls-pemfile", + "rustls-pki-types", "tokio", - "tokio-rustls 0.24.1", - "tower 0.4.13", + "tokio-rustls", "tower-service", ] @@ -1389,7 +1365,7 @@ dependencies = [ "lazy_static", "scopeguard", "tokio", - "tonic", + "tonic 0.13.0", "tracing-error", ] @@ -3007,7 +2983,7 @@ dependencies = [ "serde", "serde_json", "tokio", - "tonic", + "tonic 0.13.0", "tower 0.5.2", "url", ] @@ -3063,7 +3039,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "tonic", + "tonic 0.13.0", "tower 0.5.2", "tracing", "tracing-error", @@ -3285,6 +3261,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-err" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f89bda4c2a21204059a977ed3bfe746677dfd137b83c339e702b0ac91d482aa" +dependencies = [ + "autocfg", + "tokio", +] + [[package]] name = "fs_extra" version = "1.3.0" @@ -4042,10 +4028,10 @@ dependencies = [ "http", "hyper", "hyper-util", - "rustls 0.23.25", + "rustls", "rustls-pki-types", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls", "tower-service", "webpki-roots", ] @@ -4764,7 +4750,7 @@ dependencies = [ "serde", "serde_json", "tokio", - "tonic", + "tonic 0.13.0", "tracing", "tracing-error", "url", @@ -4918,15 +4904,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matchit" -version = "0.7.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" - -[[package]] -name = "matchit" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f926ade0c4e170215ae43342bf13b9310a437609c81f29f86c5df6657582ef9" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "md-5" @@ -5616,7 +5596,7 @@ dependencies = [ "reqwest", "thiserror 2.0.12", "tokio", - "tonic", + "tonic 0.12.3", "tracing", ] @@ -5643,7 +5623,7 @@ dependencies = [ "opentelemetry", "opentelemetry_sdk", "prost", - "tonic", + "tonic 0.12.3", ] [[package]] @@ -6495,7 +6475,7 @@ dependencies = [ "prost-build", "protobuf 3.7.2", "tokio", - "tonic", + "tonic 0.13.0", "tonic-build", "tower 0.5.2", ] @@ -6548,7 +6528,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash 2.1.1", - "rustls 0.23.25", + "rustls", "socket2", "thiserror 2.0.12", "tokio", @@ -6567,7 +6547,7 @@ dependencies = [ "rand 0.9.0", "ring", "rustc-hash 2.1.1", - "rustls 0.23.25", + "rustls", "rustls-pki-types", "slab", "thiserror 2.0.12", @@ -6905,7 +6885,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.25", + "rustls", "rustls-pemfile", "rustls-pki-types", "serde", @@ -6914,7 +6894,7 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls", "tokio-util", "tower 0.5.2", "tower-service", @@ -7147,7 +7127,7 @@ dependencies = [ "local-ip-address", "lock", "madmin", - "matchit 0.8.6", + "matchit", "mime", "mime_guess", "netif", @@ -7163,7 +7143,7 @@ dependencies = [ "rmp-serde", "rust-embed", "rustfs-obs", - "rustls 0.23.25", + "rustls", "rustls-pemfile", "rustls-pki-types", "s3s", @@ -7173,10 +7153,10 @@ dependencies = [ "shadow-rs", "time", "tokio", - "tokio-rustls 0.26.2", + "tokio-rustls", "tokio-stream", "tokio-util", - "tonic", + "tonic 0.13.0", "tonic-build", "tonic-reflection", "tower 0.5.2", @@ -7265,18 +7245,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "rustls" -version = "0.21.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" -dependencies = [ - "log", - "ring", - "rustls-webpki 0.101.7", - "sct", -] - [[package]] name = "rustls" version = "0.23.25" @@ -7288,7 +7256,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.1", + "rustls-webpki", "subtle", "zeroize", ] @@ -7311,16 +7279,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustls-webpki" version = "0.103.1" @@ -7418,16 +7376,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "security-framework" version = "2.11.1" @@ -8412,23 +8360,13 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.12", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ - "rustls 0.23.25", + "rustls", "tokio", ] @@ -8519,7 +8457,33 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ - "async-stream", + "async-trait", + "base64 0.22.1", + "bytes", + "flate2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85839f0b32fd242bb3209262371d07feda6d780d16ee9d2bc88581b89da1549b" +dependencies = [ "async-trait", "axum", "base64 0.22.1", @@ -8535,12 +8499,10 @@ dependencies = [ "percent-encoding", "pin-project", "prost", - "rustls-pemfile", "socket2", "tokio", - "tokio-rustls 0.26.2", "tokio-stream", - "tower 0.4.13", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -8548,9 +8510,9 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +checksum = "d85f0383fadd15609306383a90e85eaed44169f931a5d2be1b42c76ceff1825e" dependencies = [ "prettyplease", "proc-macro2", @@ -8562,15 +8524,15 @@ dependencies = [ [[package]] name = "tonic-reflection" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878d81f52e7fcfd80026b7fdb6a9b578b3c3653ba987f87f0dce4b64043cba27" +checksum = "88fa815be858816dad226a49439ee90b7bcf81ab55bee72fdb217f1e6778c3ca" dependencies = [ "prost", "prost-types", "tokio", "tokio-stream", - "tonic", + "tonic 0.13.0", ] [[package]] @@ -8601,9 +8563,12 @@ checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", + "indexmap 2.8.0", "pin-project-lite", + "slab", "sync_wrapper", "tokio", + "tokio-util", "tower-layer", "tower-service", "tracing", diff --git a/Cargo.toml b/Cargo.toml index 8da54a2f0..388537c29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,9 +111,9 @@ time = { version = "0.3.41", features = [ "serde", ] } tokio = { version = "1.44.2", features = ["fs", "rt-multi-thread"] } -tonic = { version = "0.12.3", features = ["gzip"] } -tonic-build = "0.12.3" -tonic-reflection = "0.12" +tonic = { version = "0.13.0", features = ["gzip"] } +tonic-build = "0.13.0" +tonic-reflection = "0.13.0" tokio-rustls = { version = "0.26", default-features = false } tokio-stream = "0.1.17" tokio-util = { version = "0.7.13", features = ["io", "compat"] } @@ -132,8 +132,8 @@ uuid = { version = "1.15.1", features = [ "fast-rng", "macro-diagnostics", ] } -axum = "0.7.9" -axum-server = { version = "0.6", features = ["tls-rustls"] } +axum = "0.8.3" +axum-server = { version = "0.7.2", features = ["tls-rustls"] } md-5 = "0.10.6" workers = { path = "./common/workers" } test-case = "3.3.1" diff --git a/common/common/Cargo.toml b/common/common/Cargo.toml index 78eba0acd..b2a34d3ac 100644 --- a/common/common/Cargo.toml +++ b/common/common/Cargo.toml @@ -11,5 +11,5 @@ async-trait.workspace = true lazy_static.workspace = true scopeguard = "1.2.0" tokio.workspace = true -tonic.workspace = true +tonic = { workspace = true } tracing-error.workspace = true diff --git a/common/protos/Cargo.toml b/common/protos/Cargo.toml index e9197762e..581fb2d02 100644 --- a/common/protos/Cargo.toml +++ b/common/protos/Cargo.toml @@ -13,7 +13,7 @@ flatbuffers = { workspace = true } prost = { workspace = true } protobuf = { workspace = true } tokio = { workspace = true } -tonic = { workspace = true, features = ["transport", "tls"] } +tonic = { workspace = true, features = ["transport"] } tower = { workspace = true } [build-dependencies] diff --git a/common/protos/build.rs b/common/protos/build.rs index 766011af1..fc55ec7a6 100644 --- a/common/protos/build.rs +++ b/common/protos/build.rs @@ -8,7 +8,7 @@ use std::{ type AnyError = Box; const ENV_OUT_DIR: &str = "OUT_DIR"; -const VERSION_PROTOBUF: Version = Version(27, 0, 0); // 27.0 +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. diff --git a/common/protos/src/generated/proto_gen/node_service.rs b/common/protos/src/generated/proto_gen/node_service.rs index 88f7b3ab0..b49c9391a 100644 --- a/common/protos/src/generated/proto_gen/node_service.rs +++ b/common/protos/src/generated/proto_gen/node_service.rs @@ -1085,7 +1085,7 @@ pub mod node_service_client { } impl NodeServiceClient where - T: tonic::client::GrpcService, + T: tonic::client::GrpcService, T::Error: Into, T::ResponseBody: Body + std::marker::Send + 'static, ::Error: Into + std::marker::Send, @@ -1106,13 +1106,13 @@ pub mod node_service_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, + http::Request, Response = http::Response< - >::ResponseBody, + >::ResponseBody, >, >, , + http::Request, >>::Error: Into + std::marker::Send + std::marker::Sync, { NodeServiceClient::new(InterceptedService::new(inner, interceptor)) @@ -3607,7 +3607,7 @@ pub mod node_service_server { B: Body + std::marker::Send + 'static, B::Error: Into + std::marker::Send + 'static, { - type Response = http::Response; + type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; fn poll_ready( @@ -7074,7 +7074,9 @@ pub mod node_service_server { } _ => { Box::pin(async move { - let mut response = http::Response::new(empty_body()); + let mut response = http::Response::new( + tonic::body::Body::default(), + ); let headers = response.headers_mut(); headers .insert( diff --git a/e2e_test/Cargo.toml b/e2e_test/Cargo.toml index a519f647e..8374bdcf7 100644 --- a/e2e_test/Cargo.toml +++ b/e2e_test/Cargo.toml @@ -22,7 +22,7 @@ protos.workspace = true rmp-serde.workspace = true serde.workspace = true serde_json.workspace = true -tonic = { version = "0.12.3", features = ["gzip"] } +tonic = { workspace = true } tokio = { workspace = true } tower.workspace = true url.workspace = true diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 153db6bce..09938aaad 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -60,7 +60,7 @@ tokio = { workspace = true, features = [ tokio-rustls.workspace = true lazy_static.workspace = true tokio-stream.workspace = true -tonic.workspace = true +tonic = { workspace = true } tonic-reflection.workspace = true tower.workspace = true tracing-core = { workspace = true } @@ -71,7 +71,7 @@ uuid = "1.15.1" url.workspace = true axum.workspace = true axum-server = { workspace = true } -matchit = "0.8.6" +matchit = "0.8.4" shadow-rs.workspace = true const-str = { version = "0.6.1", features = ["std", "proc"] } atoi = "2.0.0" From 99a5866680e0d512207cee8f7540092a7c866f2b Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Wed, 9 Apr 2025 03:27:03 +0000 Subject: [PATCH 072/103] degrade rand && object_store Signed-off-by: junxiang Mu <1948535941@qq.com> --- Cargo.lock | 48 +- Cargo.toml | 2 +- .../generated/flatbuffers_generated/models.rs | 207 +- .../src/generated/proto_gen/node_service.rs | 3838 ++++------------- ecstore/src/disk/local.rs | 2 +- s3select/api/Cargo.toml | 2 +- 6 files changed, 903 insertions(+), 3196 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fb4a60f3..6060c7347 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,7 +190,7 @@ dependencies = [ "futures", "futures-core", "http", - "object_store 0.12.0", + "object_store", "s3s", "snafu", "tokio", @@ -207,7 +207,7 @@ dependencies = [ "base64-simd", "common", "hex-simd", - "rand 0.9.0", + "rand 0.8.5", "rsa", "serde", "serde_json", @@ -1653,7 +1653,7 @@ dependencies = [ "chacha20poly1305", "jsonwebtoken", "pbkdf2", - "rand 0.9.0", + "rand 0.8.5", "serde_json", "sha2 0.10.8", "test-case", @@ -1843,7 +1843,7 @@ dependencies = [ "futures", "itertools 0.14.0", "log", - "object_store 0.11.2", + "object_store", "parking_lot 0.12.3", "parquet", "rand 0.8.5", @@ -1895,7 +1895,7 @@ dependencies = [ "datafusion-physical-plan", "futures", "log", - "object_store 0.11.2", + "object_store", "tokio", ] @@ -1914,7 +1914,7 @@ dependencies = [ "indexmap 2.8.0", "libc", "log", - "object_store 0.11.2", + "object_store", "parquet", "paste", "recursive", @@ -1958,7 +1958,7 @@ dependencies = [ "glob", "itertools 0.14.0", "log", - "object_store 0.11.2", + "object_store", "rand 0.8.5", "tokio", "tokio-util", @@ -1985,7 +1985,7 @@ dependencies = [ "datafusion-expr", "futures", "log", - "object_store 0.11.2", + "object_store", "parking_lot 0.12.3", "rand 0.8.5", "tempfile", @@ -3021,7 +3021,7 @@ dependencies = [ "pin-project-lite", "policy", "protos", - "rand 0.9.0", + "rand 0.8.5", "reed-solomon-erasure", "regex", "reqwest", @@ -4086,7 +4086,7 @@ dependencies = [ "lazy_static", "madmin", "policy", - "rand 0.9.0", + "rand 0.8.5", "regex", "serde", "serde_json", @@ -4746,7 +4746,7 @@ dependencies = [ "common", "lazy_static", "protos", - "rand 0.9.0", + "rand 0.8.5", "serde", "serde_json", "tokio", @@ -5504,28 +5504,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "object_store" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ce831b09395f933addbc56d894d889e4b226eba304d4e7adbab591e26daf1e" -dependencies = [ - "async-trait", - "bytes", - "chrono", - "futures", - "http", - "humantime", - "itertools 0.14.0", - "parking_lot 0.12.3", - "percent-encoding", - "thiserror 2.0.12", - "tokio", - "tracing", - "url", - "walkdir", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -5815,7 +5793,7 @@ dependencies = [ "lz4_flex", "num", "num-bigint", - "object_store 0.11.2", + "object_store", "paste", "seq-macro", "simdutf8", @@ -6200,7 +6178,7 @@ dependencies = [ "jsonwebtoken", "lazy_static", "madmin", - "rand 0.9.0", + "rand 0.8.5", "regex", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 388537c29..8618c151f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,7 +82,7 @@ prost-build = "0.13.4" prost-types = "0.13.4" protobuf = "3.7" protos = { path = "./common/protos" } -rand = "0.9.0" +rand = "0.8.5" rdkafka = { version = "0.37", features = ["tokio"] } reqwest = { version = "0.12.15", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream", "json", "blocking"] } rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } diff --git a/common/protos/src/generated/flatbuffers_generated/models.rs b/common/protos/src/generated/flatbuffers_generated/models.rs index aa1f6ae2f..e4949fdcf 100644 --- a/common/protos/src/generated/flatbuffers_generated/models.rs +++ b/common/protos/src/generated/flatbuffers_generated/models.rs @@ -1,10 +1,9 @@ // automatically generated by the FlatBuffers compiler, do not modify - // @generated -use core::mem; use core::cmp::Ordering; +use core::mem; extern crate flatbuffers; use self::flatbuffers::{EndianScalar, Follow}; @@ -12,112 +11,114 @@ use self::flatbuffers::{EndianScalar, Follow}; #[allow(unused_imports, dead_code)] pub mod models { - use core::mem; - use core::cmp::Ordering; + use core::cmp::Ordering; + use core::mem; - extern crate flatbuffers; - use self::flatbuffers::{EndianScalar, Follow}; + extern crate flatbuffers; + use self::flatbuffers::{EndianScalar, Follow}; -pub enum PingBodyOffset {} -#[derive(Copy, Clone, PartialEq)] + 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: 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> { - let mut builder = PingBodyBuilder::new(_fbb); - if let Some(x) = args.payload { builder.add_payload(x); } - builder.finish() - } - - - #[inline] - pub fn payload(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? - .finish(); - Ok(()) - } -} -pub struct PingBodyArgs<'a> { - pub payload: Option>>, -} -impl<'a> Default for PingBodyArgs<'a> { - #[inline] - fn default() -> Self { - PingBodyArgs { - payload: None, + pub struct PingBody<'a> { + pub _tab: flatbuffers::Table<'a>, } - } -} -pub struct PingBodyBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, -} -impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { - #[inline] - pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(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, + 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: flatbuffers::Table::new(buf, loc), + } + } } - } - #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { - 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 + 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> { + let mut builder = PingBodyBuilder::new(_fbb); + if let Some(x) = args.payload { + builder.add_payload(x); + } + builder.finish() + } + + #[inline] + pub fn payload(&self) -> Option> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { + self._tab + .get::>>(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::>>("payload", Self::VT_PAYLOAD, false)? + .finish(); + Ok(()) + } + } + pub struct PingBodyArgs<'a> { + pub payload: Option>>, + } + 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, + } + impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PingBodyBuilder<'a, 'b, A> { + #[inline] + pub fn add_payload(&mut self, payload: flatbuffers::WIPOffset>) { + self.fbb_ + .push_slot_always::>(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> { + 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 diff --git a/common/protos/src/generated/proto_gen/node_service.rs b/common/protos/src/generated/proto_gen/node_service.rs index b49c9391a..8a0c4b825 100644 --- a/common/protos/src/generated/proto_gen/node_service.rs +++ b/common/protos/src/generated/proto_gen/node_service.rs @@ -622,10 +622,7 @@ pub struct GenerallyLockResponse { #[derive(Clone, PartialEq, ::prost::Message)] pub struct Mss { #[prost(map = "string, string", tag = "1")] - pub value: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, + pub value: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, } #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct LocalStorageInfoRequest { @@ -789,10 +786,7 @@ pub struct DownloadProfileDataResponse { #[prost(bool, tag = "1")] pub success: bool, #[prost(map = "string, bytes", tag = "2")] - pub data: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::vec::Vec, - >, + pub data: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::vec::Vec>, #[prost(string, optional, tag = "3")] pub error_info: ::core::option::Option<::prost::alloc::string::String>, } @@ -1059,15 +1053,9 @@ pub struct LoadTransitionTierConfigResponse { } /// Generated client implementations. pub mod node_service_client { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] - use tonic::codegen::*; + #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] use tonic::codegen::http::Uri; + use tonic::codegen::*; #[derive(Debug, Clone)] pub struct NodeServiceClient { inner: tonic::client::Grpc, @@ -1098,22 +1086,16 @@ pub mod node_service_client { let inner = tonic::client::Grpc::with_origin(inner, origin); Self { inner } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> NodeServiceClient> + pub fn with_interceptor(inner: T, interceptor: F) -> NodeServiceClient> where F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< http::Request, - Response = http::Response< - >::ResponseBody, - >, + Response = http::Response<>::ResponseBody>, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { NodeServiceClient::new(InterceptedService::new(inner, interceptor)) } @@ -1156,15 +1138,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Ping", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Ping"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Ping")); @@ -1173,22 +1149,13 @@ pub mod node_service_client { pub async fn heal_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/HealBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/HealBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "HealBucket")); @@ -1197,22 +1164,13 @@ pub mod node_service_client { pub async fn list_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListBucket")); @@ -1221,22 +1179,13 @@ pub mod node_service_client { pub async fn make_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeBucket")); @@ -1245,22 +1194,13 @@ pub mod node_service_client { pub async fn get_bucket_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetBucketInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketInfo")); @@ -1269,22 +1209,13 @@ pub mod node_service_client { pub async fn delete_bucket( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteBucket", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucket"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucket")); @@ -1293,22 +1224,13 @@ pub mod node_service_client { pub async fn read_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadAll", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAll"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAll")); @@ -1317,22 +1239,13 @@ pub mod node_service_client { pub async fn write_all( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteAll", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteAll"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteAll")); @@ -1345,15 +1258,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Delete", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Delete"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Delete")); @@ -1362,22 +1269,13 @@ pub mod node_service_client { pub async fn verify_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/VerifyFile", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/VerifyFile"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "VerifyFile")); @@ -1386,22 +1284,13 @@ pub mod node_service_client { pub async fn check_parts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/CheckParts", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/CheckParts"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "CheckParts")); @@ -1410,22 +1299,13 @@ pub mod node_service_client { pub async fn rename_part( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenamePart", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenamePart"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenamePart")); @@ -1434,22 +1314,13 @@ pub mod node_service_client { pub async fn rename_file( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenameFile", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameFile"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameFile")); @@ -1462,15 +1333,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Write", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Write"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Write")); @@ -1479,22 +1344,13 @@ pub mod node_service_client { pub async fn write_stream( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteStream", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteStream"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteStream")); @@ -1504,22 +1360,13 @@ pub mod node_service_client { pub async fn read_at( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadAt", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadAt"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadAt")); @@ -1528,22 +1375,13 @@ pub mod node_service_client { pub async fn list_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListDir", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListDir"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListDir")); @@ -1552,22 +1390,13 @@ pub mod node_service_client { pub async fn walk_dir( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WalkDir", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WalkDir"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WalkDir")); @@ -1576,22 +1405,13 @@ pub mod node_service_client { pub async fn rename_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RenameData", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RenameData"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RenameData")); @@ -1600,22 +1420,13 @@ pub mod node_service_client { pub async fn make_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeVolumes", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolumes"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolumes")); @@ -1624,22 +1435,13 @@ pub mod node_service_client { pub async fn make_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/MakeVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/MakeVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "MakeVolume")); @@ -1648,22 +1450,13 @@ pub mod node_service_client { pub async fn list_volumes( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ListVolumes", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ListVolumes"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ListVolumes")); @@ -1672,22 +1465,13 @@ pub mod node_service_client { pub async fn stat_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StatVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StatVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StatVolume")); @@ -1696,22 +1480,13 @@ pub mod node_service_client { pub async fn delete_paths( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeletePaths", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePaths"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePaths")); @@ -1720,22 +1495,13 @@ pub mod node_service_client { pub async fn update_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UpdateMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetadata"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetadata")); @@ -1744,22 +1510,13 @@ pub mod node_service_client { pub async fn write_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/WriteMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/WriteMetadata"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "WriteMetadata")); @@ -1768,22 +1525,13 @@ pub mod node_service_client { pub async fn read_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadVersion", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadVersion"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadVersion")); @@ -1796,15 +1544,9 @@ pub mod node_service_client { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadXL", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadXL"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadXL")); @@ -1813,22 +1555,13 @@ pub mod node_service_client { pub async fn delete_version( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVersion", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersion"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersion")); @@ -1837,22 +1570,13 @@ pub mod node_service_client { pub async fn delete_versions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVersions", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVersions"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVersions")); @@ -1861,22 +1585,13 @@ pub mod node_service_client { pub async fn read_multiple( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReadMultiple", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReadMultiple"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReadMultiple")); @@ -1885,22 +1600,13 @@ pub mod node_service_client { pub async fn delete_volume( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteVolume", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteVolume"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteVolume")); @@ -1909,22 +1615,13 @@ pub mod node_service_client { pub async fn disk_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DiskInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DiskInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DiskInfo")); @@ -1933,22 +1630,13 @@ pub mod node_service_client { pub async fn ns_scanner( &mut self, request: impl tonic::IntoStreamingRequest, - ) -> std::result::Result< - tonic::Response>, - tonic::Status, - > { + ) -> std::result::Result>, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/NsScanner", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/NsScanner"); let mut req = request.into_streaming_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "NsScanner")); @@ -1957,22 +1645,13 @@ pub mod node_service_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Lock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Lock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Lock")); @@ -1981,22 +1660,13 @@ pub mod node_service_client { pub async fn un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "UnLock")); @@ -2005,22 +1675,13 @@ pub mod node_service_client { pub async fn r_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RLock")); @@ -2029,22 +1690,13 @@ pub mod node_service_client { pub async fn r_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/RUnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/RUnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "RUnLock")); @@ -2053,22 +1705,13 @@ pub mod node_service_client { pub async fn force_un_lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ForceUnLock", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ForceUnLock"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ForceUnLock")); @@ -2077,22 +1720,13 @@ pub mod node_service_client { pub async fn refresh( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/Refresh", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/Refresh"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "Refresh")); @@ -2101,22 +1735,13 @@ pub mod node_service_client { pub async fn local_storage_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LocalStorageInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LocalStorageInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LocalStorageInfo")); @@ -2125,22 +1750,13 @@ pub mod node_service_client { pub async fn server_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ServerInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ServerInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ServerInfo")); @@ -2149,22 +1765,13 @@ pub mod node_service_client { pub async fn get_cpus( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetCpus", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetCpus"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetCpus")); @@ -2173,22 +1780,13 @@ pub mod node_service_client { pub async fn get_net_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetNetInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetNetInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetNetInfo")); @@ -2197,22 +1795,13 @@ pub mod node_service_client { pub async fn get_partitions( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetPartitions", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetPartitions"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetPartitions")); @@ -2221,22 +1810,13 @@ pub mod node_service_client { pub async fn get_os_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetOsInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetOsInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetOsInfo")); @@ -2245,22 +1825,13 @@ pub mod node_service_client { pub async fn get_se_linux_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSELinuxInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSELinuxInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSELinuxInfo")); @@ -2269,22 +1840,13 @@ pub mod node_service_client { pub async fn get_sys_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSysConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysConfig"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysConfig")); @@ -2293,22 +1855,13 @@ pub mod node_service_client { pub async fn get_sys_errors( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSysErrors", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSysErrors"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSysErrors")); @@ -2317,22 +1870,13 @@ pub mod node_service_client { pub async fn get_mem_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMemInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMemInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMemInfo")); @@ -2341,22 +1885,13 @@ pub mod node_service_client { pub async fn get_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMetrics", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetrics"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetMetrics")); @@ -2365,22 +1900,13 @@ pub mod node_service_client { pub async fn get_proc_info( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetProcInfo", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetProcInfo"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetProcInfo")); @@ -2389,22 +1915,13 @@ pub mod node_service_client { pub async fn start_profiling( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StartProfiling", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StartProfiling"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StartProfiling")); @@ -2413,48 +1930,28 @@ pub mod node_service_client { pub async fn download_profile_data( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DownloadProfileData", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DownloadProfileData"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DownloadProfileData"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DownloadProfileData")); self.inner.unary(req, path, codec).await } pub async fn get_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetBucketStats", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetBucketStats"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetBucketStats")); @@ -2463,22 +1960,13 @@ pub mod node_service_client { pub async fn get_sr_metrics( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetSRMetrics", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetSRMetrics"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "GetSRMetrics")); @@ -2487,100 +1975,58 @@ pub mod node_service_client { pub async fn get_all_bucket_stats( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetAllBucketStats", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetAllBucketStats"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "GetAllBucketStats"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "GetAllBucketStats")); self.inner.unary(req, path, codec).await } pub async fn load_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadBucketMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadBucketMetadata"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadBucketMetadata")); self.inner.unary(req, path, codec).await } pub async fn delete_bucket_metadata( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteBucketMetadata", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteBucketMetadata"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DeleteBucketMetadata")); self.inner.unary(req, path, codec).await } pub async fn delete_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeletePolicy", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeletePolicy"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeletePolicy")); @@ -2589,22 +2035,13 @@ pub mod node_service_client { pub async fn load_policy( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadPolicy", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicy"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicy")); @@ -2613,48 +2050,28 @@ pub mod node_service_client { pub async fn load_policy_mapping( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadPolicyMapping", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadPolicyMapping"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadPolicyMapping")); self.inner.unary(req, path, codec).await } pub async fn delete_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteUser", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteUser"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "DeleteUser")); @@ -2663,48 +2080,28 @@ pub mod node_service_client { pub async fn delete_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/DeleteServiceAccount", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/DeleteServiceAccount"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "DeleteServiceAccount")); self.inner.unary(req, path, codec).await } pub async fn load_user( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadUser", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadUser"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadUser")); @@ -2713,48 +2110,28 @@ pub mod node_service_client { pub async fn load_service_account( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadServiceAccount", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadServiceAccount"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadServiceAccount"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadServiceAccount")); self.inner.unary(req, path, codec).await } pub async fn load_group( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadGroup", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadGroup"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "LoadGroup")); @@ -2763,30 +2140,16 @@ pub mod node_service_client { pub async fn reload_site_replication_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReloadSiteReplicationConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadSiteReplicationConfig"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new( - "node_service.NodeService", - "ReloadSiteReplicationConfig", - ), - ); + .insert(GrpcMethod::new("node_service.NodeService", "ReloadSiteReplicationConfig")); self.inner.unary(req, path, codec).await } /// rpc VerifyBinary() returns () {}; @@ -2794,22 +2157,13 @@ pub mod node_service_client { pub async fn signal_service( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/SignalService", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/SignalService"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "SignalService")); @@ -2818,100 +2172,58 @@ pub mod node_service_client { pub async fn background_heal_status( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/BackgroundHealStatus", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/BackgroundHealStatus"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "BackgroundHealStatus")); self.inner.unary(req, path, codec).await } pub async fn get_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/GetMetacacheListing", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/GetMetacacheListing"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "GetMetacacheListing"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "GetMetacacheListing")); self.inner.unary(req, path, codec).await } pub async fn update_metacache_listing( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/UpdateMetacacheListing", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/UpdateMetacacheListing"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "UpdateMetacacheListing")); self.inner.unary(req, path, codec).await } pub async fn reload_pool_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/ReloadPoolMeta", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/ReloadPoolMeta"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "ReloadPoolMeta")); @@ -2920,22 +2232,13 @@ pub mod node_service_client { pub async fn stop_rebalance( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/StopRebalance", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/StopRebalance"); let mut req = request.into_request(); req.extensions_mut() .insert(GrpcMethod::new("node_service.NodeService", "StopRebalance")); @@ -2944,69 +2247,38 @@ pub mod node_service_client { pub async fn load_rebalance_meta( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadRebalanceMeta", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadRebalanceMeta"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta"), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadRebalanceMeta")); self.inner.unary(req, path, codec).await } pub async fn load_transition_tier_config( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + .map_err(|e| tonic::Status::unknown(format!("Service was not ready: {}", e.into())))?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/node_service.NodeService/LoadTransitionTierConfig", - ); + let path = http::uri::PathAndQuery::from_static("/node_service.NodeService/LoadTransitionTierConfig"); let mut req = request.into_request(); req.extensions_mut() - .insert( - GrpcMethod::new( - "node_service.NodeService", - "LoadTransitionTierConfig", - ), - ); + .insert(GrpcMethod::new("node_service.NodeService", "LoadTransitionTierConfig")); self.inner.unary(req, path, codec).await } } } /// Generated server implementations. pub mod node_service_server { - #![allow( - unused_variables, - dead_code, - missing_docs, - clippy::wildcard_imports, - clippy::let_unit_value, - )] + #![allow(unused_variables, dead_code, missing_docs, clippy::wildcard_imports, clippy::let_unit_value)] use tonic::codegen::*; /// Generated trait containing gRPC methods that should be implemented for use with NodeServiceServer. #[async_trait] @@ -3019,38 +2291,23 @@ pub mod node_service_server { async fn heal_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn list_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_bucket_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_bucket( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_all( &self, request: tonic::Request, @@ -3058,10 +2315,7 @@ pub mod node_service_server { async fn write_all( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete( &self, request: tonic::Request, @@ -3069,52 +2323,33 @@ pub mod node_service_server { async fn verify_file( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn check_parts( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn rename_part( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn rename_file( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn write( &self, request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WriteStream method. - type WriteStreamStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type WriteStreamStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn write_stream( &self, request: tonic::Request>, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the ReadAt method. - type ReadAtStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type ReadAtStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; /// rpc Append(AppendRequest) returns (AppendResponse) {}; @@ -3127,9 +2362,7 @@ pub mod node_service_server { request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WalkDir method. - type WalkDirStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type WalkDirStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn walk_dir( @@ -3139,66 +2372,39 @@ pub mod node_service_server { async fn rename_data( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_volumes( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn make_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn list_volumes( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn stat_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_paths( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn update_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn write_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_version( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_xl( &self, request: tonic::Request, @@ -3206,42 +2412,25 @@ pub mod node_service_server { async fn delete_version( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_versions( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn read_multiple( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_volume( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn disk_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the NsScanner method. - type NsScannerStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, - > + type NsScannerStream: tonic::codegen::tokio_stream::Stream> + std::marker::Send + 'static; async fn ns_scanner( @@ -3251,59 +2440,35 @@ pub mod node_service_server { async fn lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn r_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn r_un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn force_un_lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn refresh( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn local_storage_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn server_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_cpus( &self, request: tonic::Request, @@ -3311,236 +2476,137 @@ pub mod node_service_server { async fn get_net_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_partitions( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_os_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_se_linux_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sys_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sys_errors( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_mem_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_metrics( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_proc_info( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn start_profiling( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn download_profile_data( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_sr_metrics( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_all_bucket_stats( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_bucket_metadata( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_policy( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_policy( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_policy_mapping( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_user( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn delete_service_account( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_user( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_service_account( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_group( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn reload_site_replication_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; /// rpc VerifyBinary() returns () {}; /// rpc CommitBinary() returns () {}; async fn signal_service( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn background_heal_status( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn get_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn update_metacache_listing( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn reload_pool_meta( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn stop_rebalance( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_rebalance_meta( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn load_transition_tier_config( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct NodeServiceServer { @@ -3563,10 +2629,7 @@ pub mod node_service_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -3610,10 +2673,7 @@ pub mod node_service_server { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -3621,21 +2681,12 @@ pub mod node_service_server { "/node_service.NodeService/Ping" => { #[allow(non_camel_case_types)] struct PingSvc(pub Arc); - impl tonic::server::UnaryService - for PingSvc { + impl tonic::server::UnaryService for PingSvc { type Response = super::PingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::ping(&inner, request).await - }; + let fut = async move { ::ping(&inner, request).await }; Box::pin(fut) } } @@ -3648,14 +2699,8 @@ pub mod node_service_server { let method = PingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3664,23 +2709,12 @@ pub mod node_service_server { "/node_service.NodeService/HealBucket" => { #[allow(non_camel_case_types)] struct HealBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for HealBucketSvc { + impl tonic::server::UnaryService for HealBucketSvc { type Response = super::HealBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::heal_bucket(&inner, request).await - }; + let fut = async move { ::heal_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3693,14 +2727,8 @@ pub mod node_service_server { let method = HealBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3709,23 +2737,12 @@ pub mod node_service_server { "/node_service.NodeService/ListBucket" => { #[allow(non_camel_case_types)] struct ListBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListBucketSvc { + impl tonic::server::UnaryService for ListBucketSvc { type Response = super::ListBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_bucket(&inner, request).await - }; + let fut = async move { ::list_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3738,14 +2755,8 @@ pub mod node_service_server { let method = ListBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3754,23 +2765,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeBucket" => { #[allow(non_camel_case_types)] struct MakeBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeBucketSvc { + impl tonic::server::UnaryService for MakeBucketSvc { type Response = super::MakeBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_bucket(&inner, request).await - }; + let fut = async move { ::make_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3783,14 +2783,8 @@ pub mod node_service_server { let method = MakeBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3799,23 +2793,12 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketInfo" => { #[allow(non_camel_case_types)] struct GetBucketInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetBucketInfoSvc { + impl tonic::server::UnaryService for GetBucketInfoSvc { type Response = super::GetBucketInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_bucket_info(&inner, request).await - }; + let fut = async move { ::get_bucket_info(&inner, request).await }; Box::pin(fut) } } @@ -3828,14 +2811,8 @@ pub mod node_service_server { let method = GetBucketInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3844,23 +2821,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucket" => { #[allow(non_camel_case_types)] struct DeleteBucketSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteBucketSvc { + impl tonic::server::UnaryService for DeleteBucketSvc { type Response = super::DeleteBucketResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_bucket(&inner, request).await - }; + let fut = async move { ::delete_bucket(&inner, request).await }; Box::pin(fut) } } @@ -3873,14 +2839,8 @@ pub mod node_service_server { let method = DeleteBucketSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3889,23 +2849,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadAll" => { #[allow(non_camel_case_types)] struct ReadAllSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadAllSvc { + impl tonic::server::UnaryService for ReadAllSvc { type Response = super::ReadAllResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_all(&inner, request).await - }; + let fut = async move { ::read_all(&inner, request).await }; Box::pin(fut) } } @@ -3918,14 +2867,8 @@ pub mod node_service_server { let method = ReadAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3934,23 +2877,12 @@ pub mod node_service_server { "/node_service.NodeService/WriteAll" => { #[allow(non_camel_case_types)] struct WriteAllSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for WriteAllSvc { + impl tonic::server::UnaryService for WriteAllSvc { type Response = super::WriteAllResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_all(&inner, request).await - }; + let fut = async move { ::write_all(&inner, request).await }; Box::pin(fut) } } @@ -3963,14 +2895,8 @@ pub mod node_service_server { let method = WriteAllSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -3979,23 +2905,12 @@ pub mod node_service_server { "/node_service.NodeService/Delete" => { #[allow(non_camel_case_types)] struct DeleteSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteSvc { + impl tonic::server::UnaryService for DeleteSvc { type Response = super::DeleteResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete(&inner, request).await - }; + let fut = async move { ::delete(&inner, request).await }; Box::pin(fut) } } @@ -4008,14 +2923,8 @@ pub mod node_service_server { let method = DeleteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4024,23 +2933,12 @@ pub mod node_service_server { "/node_service.NodeService/VerifyFile" => { #[allow(non_camel_case_types)] struct VerifyFileSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for VerifyFileSvc { + impl tonic::server::UnaryService for VerifyFileSvc { type Response = super::VerifyFileResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::verify_file(&inner, request).await - }; + let fut = async move { ::verify_file(&inner, request).await }; Box::pin(fut) } } @@ -4053,14 +2951,8 @@ pub mod node_service_server { let method = VerifyFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4069,23 +2961,12 @@ pub mod node_service_server { "/node_service.NodeService/CheckParts" => { #[allow(non_camel_case_types)] struct CheckPartsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for CheckPartsSvc { + impl tonic::server::UnaryService for CheckPartsSvc { type Response = super::CheckPartsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::check_parts(&inner, request).await - }; + let fut = async move { ::check_parts(&inner, request).await }; Box::pin(fut) } } @@ -4098,14 +2979,8 @@ pub mod node_service_server { let method = CheckPartsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4114,23 +2989,12 @@ pub mod node_service_server { "/node_service.NodeService/RenamePart" => { #[allow(non_camel_case_types)] struct RenamePartSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenamePartSvc { + impl tonic::server::UnaryService for RenamePartSvc { type Response = super::RenamePartResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_part(&inner, request).await - }; + let fut = async move { ::rename_part(&inner, request).await }; Box::pin(fut) } } @@ -4143,14 +3007,8 @@ pub mod node_service_server { let method = RenamePartSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4159,23 +3017,12 @@ pub mod node_service_server { "/node_service.NodeService/RenameFile" => { #[allow(non_camel_case_types)] struct RenameFileSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenameFileSvc { + impl tonic::server::UnaryService for RenameFileSvc { type Response = super::RenameFileResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_file(&inner, request).await - }; + let fut = async move { ::rename_file(&inner, request).await }; Box::pin(fut) } } @@ -4188,14 +3035,8 @@ pub mod node_service_server { let method = RenameFileSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4204,21 +3045,12 @@ pub mod node_service_server { "/node_service.NodeService/Write" => { #[allow(non_camel_case_types)] struct WriteSvc(pub Arc); - impl tonic::server::UnaryService - for WriteSvc { + impl tonic::server::UnaryService for WriteSvc { type Response = super::WriteResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write(&inner, request).await - }; + let fut = async move { ::write(&inner, request).await }; Box::pin(fut) } } @@ -4231,14 +3063,8 @@ pub mod node_service_server { let method = WriteSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4247,26 +3073,13 @@ pub mod node_service_server { "/node_service.NodeService/WriteStream" => { #[allow(non_camel_case_types)] struct WriteStreamSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for WriteStreamSvc { + impl tonic::server::StreamingService for WriteStreamSvc { type Response = super::WriteResponse; type ResponseStream = T::WriteStreamStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_stream(&inner, request).await - }; + let fut = async move { ::write_stream(&inner, request).await }; Box::pin(fut) } } @@ -4279,14 +3092,8 @@ pub mod node_service_server { let method = WriteStreamSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -4295,26 +3102,13 @@ pub mod node_service_server { "/node_service.NodeService/ReadAt" => { #[allow(non_camel_case_types)] struct ReadAtSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for ReadAtSvc { + impl tonic::server::StreamingService for ReadAtSvc { type Response = super::ReadAtResponse; type ResponseStream = T::ReadAtStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_at(&inner, request).await - }; + let fut = async move { ::read_at(&inner, request).await }; Box::pin(fut) } } @@ -4327,14 +3121,8 @@ pub mod node_service_server { let method = ReadAtSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -4343,23 +3131,12 @@ pub mod node_service_server { "/node_service.NodeService/ListDir" => { #[allow(non_camel_case_types)] struct ListDirSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListDirSvc { + impl tonic::server::UnaryService for ListDirSvc { type Response = super::ListDirResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_dir(&inner, request).await - }; + let fut = async move { ::list_dir(&inner, request).await }; Box::pin(fut) } } @@ -4372,14 +3149,8 @@ pub mod node_service_server { let method = ListDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4388,24 +3159,13 @@ pub mod node_service_server { "/node_service.NodeService/WalkDir" => { #[allow(non_camel_case_types)] struct WalkDirSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::ServerStreamingService - for WalkDirSvc { + impl tonic::server::ServerStreamingService for WalkDirSvc { type Response = super::WalkDirResponse; type ResponseStream = T::WalkDirStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::walk_dir(&inner, request).await - }; + let fut = async move { ::walk_dir(&inner, request).await }; Box::pin(fut) } } @@ -4418,14 +3178,8 @@ pub mod node_service_server { let method = WalkDirSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.server_streaming(method, req).await; Ok(res) }; @@ -4434,23 +3188,12 @@ pub mod node_service_server { "/node_service.NodeService/RenameData" => { #[allow(non_camel_case_types)] struct RenameDataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RenameDataSvc { + impl tonic::server::UnaryService for RenameDataSvc { type Response = super::RenameDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::rename_data(&inner, request).await - }; + let fut = async move { ::rename_data(&inner, request).await }; Box::pin(fut) } } @@ -4463,14 +3206,8 @@ pub mod node_service_server { let method = RenameDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4479,23 +3216,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolumes" => { #[allow(non_camel_case_types)] struct MakeVolumesSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeVolumesSvc { + impl tonic::server::UnaryService for MakeVolumesSvc { type Response = super::MakeVolumesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_volumes(&inner, request).await - }; + let fut = async move { ::make_volumes(&inner, request).await }; Box::pin(fut) } } @@ -4508,14 +3234,8 @@ pub mod node_service_server { let method = MakeVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4524,23 +3244,12 @@ pub mod node_service_server { "/node_service.NodeService/MakeVolume" => { #[allow(non_camel_case_types)] struct MakeVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for MakeVolumeSvc { + impl tonic::server::UnaryService for MakeVolumeSvc { type Response = super::MakeVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::make_volume(&inner, request).await - }; + let fut = async move { ::make_volume(&inner, request).await }; Box::pin(fut) } } @@ -4553,14 +3262,8 @@ pub mod node_service_server { let method = MakeVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4569,23 +3272,12 @@ pub mod node_service_server { "/node_service.NodeService/ListVolumes" => { #[allow(non_camel_case_types)] struct ListVolumesSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ListVolumesSvc { + impl tonic::server::UnaryService for ListVolumesSvc { type Response = super::ListVolumesResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_volumes(&inner, request).await - }; + let fut = async move { ::list_volumes(&inner, request).await }; Box::pin(fut) } } @@ -4598,14 +3290,8 @@ pub mod node_service_server { let method = ListVolumesSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4614,23 +3300,12 @@ pub mod node_service_server { "/node_service.NodeService/StatVolume" => { #[allow(non_camel_case_types)] struct StatVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StatVolumeSvc { + impl tonic::server::UnaryService for StatVolumeSvc { type Response = super::StatVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::stat_volume(&inner, request).await - }; + let fut = async move { ::stat_volume(&inner, request).await }; Box::pin(fut) } } @@ -4643,14 +3318,8 @@ pub mod node_service_server { let method = StatVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4659,23 +3328,12 @@ pub mod node_service_server { "/node_service.NodeService/DeletePaths" => { #[allow(non_camel_case_types)] struct DeletePathsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeletePathsSvc { + impl tonic::server::UnaryService for DeletePathsSvc { type Response = super::DeletePathsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_paths(&inner, request).await - }; + let fut = async move { ::delete_paths(&inner, request).await }; Box::pin(fut) } } @@ -4688,14 +3346,8 @@ pub mod node_service_server { let method = DeletePathsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4704,23 +3356,12 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetadata" => { #[allow(non_camel_case_types)] struct UpdateMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UpdateMetadataSvc { + impl tonic::server::UnaryService for UpdateMetadataSvc { type Response = super::UpdateMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::update_metadata(&inner, request).await - }; + let fut = async move { ::update_metadata(&inner, request).await }; Box::pin(fut) } } @@ -4733,14 +3374,8 @@ pub mod node_service_server { let method = UpdateMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4749,23 +3384,12 @@ pub mod node_service_server { "/node_service.NodeService/WriteMetadata" => { #[allow(non_camel_case_types)] struct WriteMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for WriteMetadataSvc { + impl tonic::server::UnaryService for WriteMetadataSvc { type Response = super::WriteMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::write_metadata(&inner, request).await - }; + let fut = async move { ::write_metadata(&inner, request).await }; Box::pin(fut) } } @@ -4778,14 +3402,8 @@ pub mod node_service_server { let method = WriteMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4794,23 +3412,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadVersion" => { #[allow(non_camel_case_types)] struct ReadVersionSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadVersionSvc { + impl tonic::server::UnaryService for ReadVersionSvc { type Response = super::ReadVersionResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_version(&inner, request).await - }; + let fut = async move { ::read_version(&inner, request).await }; Box::pin(fut) } } @@ -4823,14 +3430,8 @@ pub mod node_service_server { let method = ReadVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4839,23 +3440,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadXL" => { #[allow(non_camel_case_types)] struct ReadXLSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadXLSvc { + impl tonic::server::UnaryService for ReadXLSvc { type Response = super::ReadXlResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_xl(&inner, request).await - }; + let fut = async move { ::read_xl(&inner, request).await }; Box::pin(fut) } } @@ -4868,14 +3458,8 @@ pub mod node_service_server { let method = ReadXLSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4884,23 +3468,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersion" => { #[allow(non_camel_case_types)] struct DeleteVersionSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVersionSvc { + impl tonic::server::UnaryService for DeleteVersionSvc { type Response = super::DeleteVersionResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_version(&inner, request).await - }; + let fut = async move { ::delete_version(&inner, request).await }; Box::pin(fut) } } @@ -4913,14 +3486,8 @@ pub mod node_service_server { let method = DeleteVersionSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4929,23 +3496,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVersions" => { #[allow(non_camel_case_types)] struct DeleteVersionsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVersionsSvc { + impl tonic::server::UnaryService for DeleteVersionsSvc { type Response = super::DeleteVersionsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_versions(&inner, request).await - }; + let fut = async move { ::delete_versions(&inner, request).await }; Box::pin(fut) } } @@ -4958,14 +3514,8 @@ pub mod node_service_server { let method = DeleteVersionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -4974,23 +3524,12 @@ pub mod node_service_server { "/node_service.NodeService/ReadMultiple" => { #[allow(non_camel_case_types)] struct ReadMultipleSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReadMultipleSvc { + impl tonic::server::UnaryService for ReadMultipleSvc { type Response = super::ReadMultipleResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::read_multiple(&inner, request).await - }; + let fut = async move { ::read_multiple(&inner, request).await }; Box::pin(fut) } } @@ -5003,14 +3542,8 @@ pub mod node_service_server { let method = ReadMultipleSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5019,23 +3552,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteVolume" => { #[allow(non_camel_case_types)] struct DeleteVolumeSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteVolumeSvc { + impl tonic::server::UnaryService for DeleteVolumeSvc { type Response = super::DeleteVolumeResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_volume(&inner, request).await - }; + let fut = async move { ::delete_volume(&inner, request).await }; Box::pin(fut) } } @@ -5048,14 +3570,8 @@ pub mod node_service_server { let method = DeleteVolumeSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5064,23 +3580,12 @@ pub mod node_service_server { "/node_service.NodeService/DiskInfo" => { #[allow(non_camel_case_types)] struct DiskInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DiskInfoSvc { + impl tonic::server::UnaryService for DiskInfoSvc { type Response = super::DiskInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::disk_info(&inner, request).await - }; + let fut = async move { ::disk_info(&inner, request).await }; Box::pin(fut) } } @@ -5093,14 +3598,8 @@ pub mod node_service_server { let method = DiskInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5109,26 +3608,13 @@ pub mod node_service_server { "/node_service.NodeService/NsScanner" => { #[allow(non_camel_case_types)] struct NsScannerSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::StreamingService - for NsScannerSvc { + impl tonic::server::StreamingService for NsScannerSvc { type Response = super::NsScannerResponse; type ResponseStream = T::NsScannerStream; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - tonic::Streaming, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request>) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::ns_scanner(&inner, request).await - }; + let fut = async move { ::ns_scanner(&inner, request).await }; Box::pin(fut) } } @@ -5141,14 +3627,8 @@ pub mod node_service_server { let method = NsScannerSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.streaming(method, req).await; Ok(res) }; @@ -5157,23 +3637,12 @@ pub mod node_service_server { "/node_service.NodeService/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LockSvc { + impl tonic::server::UnaryService for LockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::lock(&inner, request).await - }; + let fut = async move { ::lock(&inner, request).await }; Box::pin(fut) } } @@ -5186,14 +3655,8 @@ pub mod node_service_server { let method = LockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5202,23 +3665,12 @@ pub mod node_service_server { "/node_service.NodeService/UnLock" => { #[allow(non_camel_case_types)] struct UnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UnLockSvc { + impl tonic::server::UnaryService for UnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::un_lock(&inner, request).await - }; + let fut = async move { ::un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5231,14 +3683,8 @@ pub mod node_service_server { let method = UnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5247,23 +3693,12 @@ pub mod node_service_server { "/node_service.NodeService/RLock" => { #[allow(non_camel_case_types)] struct RLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RLockSvc { + impl tonic::server::UnaryService for RLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::r_lock(&inner, request).await - }; + let fut = async move { ::r_lock(&inner, request).await }; Box::pin(fut) } } @@ -5276,14 +3711,8 @@ pub mod node_service_server { let method = RLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5292,23 +3721,12 @@ pub mod node_service_server { "/node_service.NodeService/RUnLock" => { #[allow(non_camel_case_types)] struct RUnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RUnLockSvc { + impl tonic::server::UnaryService for RUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::r_un_lock(&inner, request).await - }; + let fut = async move { ::r_un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5321,14 +3739,8 @@ pub mod node_service_server { let method = RUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5337,23 +3749,12 @@ pub mod node_service_server { "/node_service.NodeService/ForceUnLock" => { #[allow(non_camel_case_types)] struct ForceUnLockSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ForceUnLockSvc { + impl tonic::server::UnaryService for ForceUnLockSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::force_un_lock(&inner, request).await - }; + let fut = async move { ::force_un_lock(&inner, request).await }; Box::pin(fut) } } @@ -5366,14 +3767,8 @@ pub mod node_service_server { let method = ForceUnLockSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5382,23 +3777,12 @@ pub mod node_service_server { "/node_service.NodeService/Refresh" => { #[allow(non_camel_case_types)] struct RefreshSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for RefreshSvc { + impl tonic::server::UnaryService for RefreshSvc { type Response = super::GenerallyLockResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::refresh(&inner, request).await - }; + let fut = async move { ::refresh(&inner, request).await }; Box::pin(fut) } } @@ -5411,14 +3795,8 @@ pub mod node_service_server { let method = RefreshSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5427,24 +3805,12 @@ pub mod node_service_server { "/node_service.NodeService/LocalStorageInfo" => { #[allow(non_camel_case_types)] struct LocalStorageInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LocalStorageInfoSvc { + impl tonic::server::UnaryService for LocalStorageInfoSvc { type Response = super::LocalStorageInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::local_storage_info(&inner, request) - .await - }; + let fut = async move { ::local_storage_info(&inner, request).await }; Box::pin(fut) } } @@ -5457,14 +3823,8 @@ pub mod node_service_server { let method = LocalStorageInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5473,23 +3833,12 @@ pub mod node_service_server { "/node_service.NodeService/ServerInfo" => { #[allow(non_camel_case_types)] struct ServerInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ServerInfoSvc { + impl tonic::server::UnaryService for ServerInfoSvc { type Response = super::ServerInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::server_info(&inner, request).await - }; + let fut = async move { ::server_info(&inner, request).await }; Box::pin(fut) } } @@ -5502,14 +3851,8 @@ pub mod node_service_server { let method = ServerInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5518,23 +3861,12 @@ pub mod node_service_server { "/node_service.NodeService/GetCpus" => { #[allow(non_camel_case_types)] struct GetCpusSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetCpusSvc { + impl tonic::server::UnaryService for GetCpusSvc { type Response = super::GetCpusResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_cpus(&inner, request).await - }; + let fut = async move { ::get_cpus(&inner, request).await }; Box::pin(fut) } } @@ -5547,14 +3879,8 @@ pub mod node_service_server { let method = GetCpusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5563,23 +3889,12 @@ pub mod node_service_server { "/node_service.NodeService/GetNetInfo" => { #[allow(non_camel_case_types)] struct GetNetInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetNetInfoSvc { + impl tonic::server::UnaryService for GetNetInfoSvc { type Response = super::GetNetInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_net_info(&inner, request).await - }; + let fut = async move { ::get_net_info(&inner, request).await }; Box::pin(fut) } } @@ -5592,14 +3907,8 @@ pub mod node_service_server { let method = GetNetInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5608,23 +3917,12 @@ pub mod node_service_server { "/node_service.NodeService/GetPartitions" => { #[allow(non_camel_case_types)] struct GetPartitionsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetPartitionsSvc { + impl tonic::server::UnaryService for GetPartitionsSvc { type Response = super::GetPartitionsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_partitions(&inner, request).await - }; + let fut = async move { ::get_partitions(&inner, request).await }; Box::pin(fut) } } @@ -5637,14 +3935,8 @@ pub mod node_service_server { let method = GetPartitionsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5653,23 +3945,12 @@ pub mod node_service_server { "/node_service.NodeService/GetOsInfo" => { #[allow(non_camel_case_types)] struct GetOsInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetOsInfoSvc { + impl tonic::server::UnaryService for GetOsInfoSvc { type Response = super::GetOsInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_os_info(&inner, request).await - }; + let fut = async move { ::get_os_info(&inner, request).await }; Box::pin(fut) } } @@ -5682,14 +3963,8 @@ pub mod node_service_server { let method = GetOsInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5698,23 +3973,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSELinuxInfo" => { #[allow(non_camel_case_types)] struct GetSELinuxInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSELinuxInfoSvc { + impl tonic::server::UnaryService for GetSELinuxInfoSvc { type Response = super::GetSeLinuxInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_se_linux_info(&inner, request).await - }; + let fut = async move { ::get_se_linux_info(&inner, request).await }; Box::pin(fut) } } @@ -5727,14 +3991,8 @@ pub mod node_service_server { let method = GetSELinuxInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5743,23 +4001,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSysConfig" => { #[allow(non_camel_case_types)] struct GetSysConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSysConfigSvc { + impl tonic::server::UnaryService for GetSysConfigSvc { type Response = super::GetSysConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sys_config(&inner, request).await - }; + let fut = async move { ::get_sys_config(&inner, request).await }; Box::pin(fut) } } @@ -5772,14 +4019,8 @@ pub mod node_service_server { let method = GetSysConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5788,23 +4029,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSysErrors" => { #[allow(non_camel_case_types)] struct GetSysErrorsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSysErrorsSvc { + impl tonic::server::UnaryService for GetSysErrorsSvc { type Response = super::GetSysErrorsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sys_errors(&inner, request).await - }; + let fut = async move { ::get_sys_errors(&inner, request).await }; Box::pin(fut) } } @@ -5817,14 +4047,8 @@ pub mod node_service_server { let method = GetSysErrorsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5833,23 +4057,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMemInfo" => { #[allow(non_camel_case_types)] struct GetMemInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMemInfoSvc { + impl tonic::server::UnaryService for GetMemInfoSvc { type Response = super::GetMemInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_mem_info(&inner, request).await - }; + let fut = async move { ::get_mem_info(&inner, request).await }; Box::pin(fut) } } @@ -5862,14 +4075,8 @@ pub mod node_service_server { let method = GetMemInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5878,23 +4085,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMetrics" => { #[allow(non_camel_case_types)] struct GetMetricsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMetricsSvc { + impl tonic::server::UnaryService for GetMetricsSvc { type Response = super::GetMetricsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_metrics(&inner, request).await - }; + let fut = async move { ::get_metrics(&inner, request).await }; Box::pin(fut) } } @@ -5907,14 +4103,8 @@ pub mod node_service_server { let method = GetMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5923,23 +4113,12 @@ pub mod node_service_server { "/node_service.NodeService/GetProcInfo" => { #[allow(non_camel_case_types)] struct GetProcInfoSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetProcInfoSvc { + impl tonic::server::UnaryService for GetProcInfoSvc { type Response = super::GetProcInfoResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proc_info(&inner, request).await - }; + let fut = async move { ::get_proc_info(&inner, request).await }; Box::pin(fut) } } @@ -5952,14 +4131,8 @@ pub mod node_service_server { let method = GetProcInfoSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -5968,23 +4141,12 @@ pub mod node_service_server { "/node_service.NodeService/StartProfiling" => { #[allow(non_camel_case_types)] struct StartProfilingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StartProfilingSvc { + impl tonic::server::UnaryService for StartProfilingSvc { type Response = super::StartProfilingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::start_profiling(&inner, request).await - }; + let fut = async move { ::start_profiling(&inner, request).await }; Box::pin(fut) } } @@ -5997,14 +4159,8 @@ pub mod node_service_server { let method = StartProfilingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6013,24 +4169,12 @@ pub mod node_service_server { "/node_service.NodeService/DownloadProfileData" => { #[allow(non_camel_case_types)] struct DownloadProfileDataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DownloadProfileDataSvc { + impl tonic::server::UnaryService for DownloadProfileDataSvc { type Response = super::DownloadProfileDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::download_profile_data(&inner, request) - .await - }; + let fut = async move { ::download_profile_data(&inner, request).await }; Box::pin(fut) } } @@ -6043,14 +4187,8 @@ pub mod node_service_server { let method = DownloadProfileDataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6059,23 +4197,12 @@ pub mod node_service_server { "/node_service.NodeService/GetBucketStats" => { #[allow(non_camel_case_types)] struct GetBucketStatsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetBucketStatsSvc { + impl tonic::server::UnaryService for GetBucketStatsSvc { type Response = super::GetBucketStatsDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_bucket_stats(&inner, request).await - }; + let fut = async move { ::get_bucket_stats(&inner, request).await }; Box::pin(fut) } } @@ -6088,14 +4215,8 @@ pub mod node_service_server { let method = GetBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6104,23 +4225,12 @@ pub mod node_service_server { "/node_service.NodeService/GetSRMetrics" => { #[allow(non_camel_case_types)] struct GetSRMetricsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetSRMetricsSvc { + impl tonic::server::UnaryService for GetSRMetricsSvc { type Response = super::GetSrMetricsDataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_sr_metrics(&inner, request).await - }; + let fut = async move { ::get_sr_metrics(&inner, request).await }; Box::pin(fut) } } @@ -6133,14 +4243,8 @@ pub mod node_service_server { let method = GetSRMetricsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6149,24 +4253,12 @@ pub mod node_service_server { "/node_service.NodeService/GetAllBucketStats" => { #[allow(non_camel_case_types)] struct GetAllBucketStatsSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetAllBucketStatsSvc { + impl tonic::server::UnaryService for GetAllBucketStatsSvc { type Response = super::GetAllBucketStatsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_all_bucket_stats(&inner, request) - .await - }; + let fut = async move { ::get_all_bucket_stats(&inner, request).await }; Box::pin(fut) } } @@ -6179,14 +4271,8 @@ pub mod node_service_server { let method = GetAllBucketStatsSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6195,24 +4281,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadBucketMetadata" => { #[allow(non_camel_case_types)] struct LoadBucketMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadBucketMetadataSvc { + impl tonic::server::UnaryService for LoadBucketMetadataSvc { type Response = super::LoadBucketMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_bucket_metadata(&inner, request) - .await - }; + let fut = async move { ::load_bucket_metadata(&inner, request).await }; Box::pin(fut) } } @@ -6225,14 +4299,8 @@ pub mod node_service_server { let method = LoadBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6241,24 +4309,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteBucketMetadata" => { #[allow(non_camel_case_types)] struct DeleteBucketMetadataSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteBucketMetadataSvc { + impl tonic::server::UnaryService for DeleteBucketMetadataSvc { type Response = super::DeleteBucketMetadataResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_bucket_metadata(&inner, request) - .await - }; + let fut = async move { ::delete_bucket_metadata(&inner, request).await }; Box::pin(fut) } } @@ -6271,14 +4327,8 @@ pub mod node_service_server { let method = DeleteBucketMetadataSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6287,23 +4337,12 @@ pub mod node_service_server { "/node_service.NodeService/DeletePolicy" => { #[allow(non_camel_case_types)] struct DeletePolicySvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeletePolicySvc { + impl tonic::server::UnaryService for DeletePolicySvc { type Response = super::DeletePolicyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_policy(&inner, request).await - }; + let fut = async move { ::delete_policy(&inner, request).await }; Box::pin(fut) } } @@ -6316,14 +4355,8 @@ pub mod node_service_server { let method = DeletePolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6332,23 +4365,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicy" => { #[allow(non_camel_case_types)] struct LoadPolicySvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadPolicySvc { + impl tonic::server::UnaryService for LoadPolicySvc { type Response = super::LoadPolicyResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_policy(&inner, request).await - }; + let fut = async move { ::load_policy(&inner, request).await }; Box::pin(fut) } } @@ -6361,14 +4383,8 @@ pub mod node_service_server { let method = LoadPolicySvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6377,24 +4393,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadPolicyMapping" => { #[allow(non_camel_case_types)] struct LoadPolicyMappingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadPolicyMappingSvc { + impl tonic::server::UnaryService for LoadPolicyMappingSvc { type Response = super::LoadPolicyMappingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_policy_mapping(&inner, request) - .await - }; + let fut = async move { ::load_policy_mapping(&inner, request).await }; Box::pin(fut) } } @@ -6407,14 +4411,8 @@ pub mod node_service_server { let method = LoadPolicyMappingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6423,23 +4421,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteUser" => { #[allow(non_camel_case_types)] struct DeleteUserSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteUserSvc { + impl tonic::server::UnaryService for DeleteUserSvc { type Response = super::DeleteUserResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_user(&inner, request).await - }; + let fut = async move { ::delete_user(&inner, request).await }; Box::pin(fut) } } @@ -6452,14 +4439,8 @@ pub mod node_service_server { let method = DeleteUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6468,24 +4449,12 @@ pub mod node_service_server { "/node_service.NodeService/DeleteServiceAccount" => { #[allow(non_camel_case_types)] struct DeleteServiceAccountSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for DeleteServiceAccountSvc { + impl tonic::server::UnaryService for DeleteServiceAccountSvc { type Response = super::DeleteServiceAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::delete_service_account(&inner, request) - .await - }; + let fut = async move { ::delete_service_account(&inner, request).await }; Box::pin(fut) } } @@ -6498,14 +4467,8 @@ pub mod node_service_server { let method = DeleteServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6514,23 +4477,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadUser" => { #[allow(non_camel_case_types)] struct LoadUserSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadUserSvc { + impl tonic::server::UnaryService for LoadUserSvc { type Response = super::LoadUserResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_user(&inner, request).await - }; + let fut = async move { ::load_user(&inner, request).await }; Box::pin(fut) } } @@ -6543,14 +4495,8 @@ pub mod node_service_server { let method = LoadUserSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6559,24 +4505,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadServiceAccount" => { #[allow(non_camel_case_types)] struct LoadServiceAccountSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadServiceAccountSvc { + impl tonic::server::UnaryService for LoadServiceAccountSvc { type Response = super::LoadServiceAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_service_account(&inner, request) - .await - }; + let fut = async move { ::load_service_account(&inner, request).await }; Box::pin(fut) } } @@ -6589,14 +4523,8 @@ pub mod node_service_server { let method = LoadServiceAccountSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6605,23 +4533,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadGroup" => { #[allow(non_camel_case_types)] struct LoadGroupSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadGroupSvc { + impl tonic::server::UnaryService for LoadGroupSvc { type Response = super::LoadGroupResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_group(&inner, request).await - }; + let fut = async move { ::load_group(&inner, request).await }; Box::pin(fut) } } @@ -6634,14 +4551,8 @@ pub mod node_service_server { let method = LoadGroupSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6650,30 +4561,14 @@ pub mod node_service_server { "/node_service.NodeService/ReloadSiteReplicationConfig" => { #[allow(non_camel_case_types)] struct ReloadSiteReplicationConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService< - super::ReloadSiteReplicationConfigRequest, - > for ReloadSiteReplicationConfigSvc { + impl tonic::server::UnaryService + for ReloadSiteReplicationConfigSvc + { type Response = super::ReloadSiteReplicationConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::ReloadSiteReplicationConfigRequest, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::reload_site_replication_config( - &inner, - request, - ) - .await - }; + let fut = async move { ::reload_site_replication_config(&inner, request).await }; Box::pin(fut) } } @@ -6686,14 +4581,8 @@ pub mod node_service_server { let method = ReloadSiteReplicationConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6702,23 +4591,12 @@ pub mod node_service_server { "/node_service.NodeService/SignalService" => { #[allow(non_camel_case_types)] struct SignalServiceSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for SignalServiceSvc { + impl tonic::server::UnaryService for SignalServiceSvc { type Response = super::SignalServiceResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::signal_service(&inner, request).await - }; + let fut = async move { ::signal_service(&inner, request).await }; Box::pin(fut) } } @@ -6731,14 +4609,8 @@ pub mod node_service_server { let method = SignalServiceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6747,24 +4619,12 @@ pub mod node_service_server { "/node_service.NodeService/BackgroundHealStatus" => { #[allow(non_camel_case_types)] struct BackgroundHealStatusSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for BackgroundHealStatusSvc { + impl tonic::server::UnaryService for BackgroundHealStatusSvc { type Response = super::BackgroundHealStatusResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::background_heal_status(&inner, request) - .await - }; + let fut = async move { ::background_heal_status(&inner, request).await }; Box::pin(fut) } } @@ -6777,14 +4637,8 @@ pub mod node_service_server { let method = BackgroundHealStatusSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6793,24 +4647,12 @@ pub mod node_service_server { "/node_service.NodeService/GetMetacacheListing" => { #[allow(non_camel_case_types)] struct GetMetacacheListingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for GetMetacacheListingSvc { + impl tonic::server::UnaryService for GetMetacacheListingSvc { type Response = super::GetMetacacheListingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::get_metacache_listing(&inner, request) - .await - }; + let fut = async move { ::get_metacache_listing(&inner, request).await }; Box::pin(fut) } } @@ -6823,14 +4665,8 @@ pub mod node_service_server { let method = GetMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6839,27 +4675,12 @@ pub mod node_service_server { "/node_service.NodeService/UpdateMetacacheListing" => { #[allow(non_camel_case_types)] struct UpdateMetacacheListingSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for UpdateMetacacheListingSvc { + impl tonic::server::UnaryService for UpdateMetacacheListingSvc { type Response = super::UpdateMetacacheListingResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::update_metacache_listing( - &inner, - request, - ) - .await - }; + let fut = async move { ::update_metacache_listing(&inner, request).await }; Box::pin(fut) } } @@ -6872,14 +4693,8 @@ pub mod node_service_server { let method = UpdateMetacacheListingSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6888,23 +4703,12 @@ pub mod node_service_server { "/node_service.NodeService/ReloadPoolMeta" => { #[allow(non_camel_case_types)] struct ReloadPoolMetaSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for ReloadPoolMetaSvc { + impl tonic::server::UnaryService for ReloadPoolMetaSvc { type Response = super::ReloadPoolMetaResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::reload_pool_meta(&inner, request).await - }; + let fut = async move { ::reload_pool_meta(&inner, request).await }; Box::pin(fut) } } @@ -6917,14 +4721,8 @@ pub mod node_service_server { let method = ReloadPoolMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6933,23 +4731,12 @@ pub mod node_service_server { "/node_service.NodeService/StopRebalance" => { #[allow(non_camel_case_types)] struct StopRebalanceSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for StopRebalanceSvc { + impl tonic::server::UnaryService for StopRebalanceSvc { type Response = super::StopRebalanceResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::stop_rebalance(&inner, request).await - }; + let fut = async move { ::stop_rebalance(&inner, request).await }; Box::pin(fut) } } @@ -6962,14 +4749,8 @@ pub mod node_service_server { let method = StopRebalanceSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -6978,24 +4759,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadRebalanceMeta" => { #[allow(non_camel_case_types)] struct LoadRebalanceMetaSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadRebalanceMetaSvc { + impl tonic::server::UnaryService for LoadRebalanceMetaSvc { type Response = super::LoadRebalanceMetaResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_rebalance_meta(&inner, request) - .await - }; + let fut = async move { ::load_rebalance_meta(&inner, request).await }; Box::pin(fut) } } @@ -7008,14 +4777,8 @@ pub mod node_service_server { let method = LoadRebalanceMetaSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; @@ -7024,29 +4787,12 @@ pub mod node_service_server { "/node_service.NodeService/LoadTransitionTierConfig" => { #[allow(non_camel_case_types)] struct LoadTransitionTierConfigSvc(pub Arc); - impl< - T: NodeService, - > tonic::server::UnaryService - for LoadTransitionTierConfigSvc { + impl tonic::server::UnaryService for LoadTransitionTierConfigSvc { type Response = super::LoadTransitionTierConfigResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request< - super::LoadTransitionTierConfigRequest, - >, - ) -> Self::Future { + type Future = BoxFuture, tonic::Status>; + fn call(&mut self, request: tonic::Request) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::load_transition_tier_config( - &inner, - request, - ) - .await - }; + let fut = async move { ::load_transition_tier_config(&inner, request).await }; Box::pin(fut) } } @@ -7059,38 +4805,20 @@ pub mod node_service_server { let method = LoadTransitionTierConfigSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); + .apply_compression_config(accept_compression_encodings, send_compression_encodings) + .apply_max_message_size_config(max_decoding_message_size, max_encoding_message_size); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new( - tonic::body::Body::default(), - ); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(tonic::body::Body::default()); + let headers = response.headers_mut(); + headers.insert(tonic::Status::GRPC_STATUS, (tonic::Code::Unimplemented as i32).into()); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 5a69f7615..279902b3e 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -14,7 +14,7 @@ use crate::bucket::metadata_sys::{self}; use crate::cache_value::cache::{Cache, Opts, UpdateFn}; use crate::disk::error::{ convert_access_error, is_err_os_not_exist, is_sys_err_handle_invalid, is_sys_err_invalid_arg, is_sys_err_is_dir, - is_sys_err_not_dir, map_err_not_exists, os_err_to_file_err, FileAccessDeniedWithContext + is_sys_err_not_dir, map_err_not_exists, os_err_to_file_err, FileAccessDeniedWithContext, }; use crate::disk::os::{check_path_length, is_empty_dir}; use crate::disk::STORAGE_FORMAT_FILE; diff --git a/s3select/api/Cargo.toml b/s3select/api/Cargo.toml index e8c683665..1936e846a 100644 --- a/s3select/api/Cargo.toml +++ b/s3select/api/Cargo.toml @@ -12,7 +12,7 @@ ecstore.workspace = true futures = { workspace = true } futures-core = "0.3.31" http.workspace = true -object_store = "0.12.0" +object_store = "0.11.2" s3s.workspace = true snafu = { workspace = true, features = ["backtrace"] } tokio.workspace = true From c900faba81ebfc78f30c200fb8d1cbe667a59fe0 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Wed, 9 Apr 2025 06:19:36 +0000 Subject: [PATCH 073/103] fix upgrade axum bug Signed-off-by: junxiang Mu <1948535941@qq.com> --- Cargo.lock | 23 +++++++++++++++++++++++ Cargo.toml | 3 ++- rustfs/Cargo.toml | 1 + rustfs/src/console.rs | 2 +- rustfs/src/service.rs | 3 +-- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6060c7347..ca4e5b4e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -752,6 +752,28 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum-extra" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d" +dependencies = [ + "axum", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "serde", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-server" version = "0.7.2" @@ -7082,6 +7104,7 @@ dependencies = [ "async-trait", "atoi", "axum", + "axum-extra", "axum-server", "bytes", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 8618c151f..a7d2b06d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ common = { path = "./common/common" } policy = { path = "./policy" } hex = "0.4.3" hyper = "1.6.0" -hyper-util = { version = "0.1.10", features = [ +hyper-util = { version = "0.1.11", features = [ "tokio", "server-auto", "server-graceful", @@ -133,6 +133,7 @@ uuid = { version = "1.15.1", features = [ "macro-diagnostics", ] } axum = "0.8.3" +axum-extra = "0.10.1" axum-server = { version = "0.7.2", features = ["tls-rustls"] } md-5 = "0.10.6" workers = { path = "./common/workers" } diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 09938aaad..1ab8beb8a 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -70,6 +70,7 @@ transform-stream.workspace = true uuid = "1.15.1" url.workspace = true axum.workspace = true +axum-extra = { workspace = true } axum-server = { workspace = true } matchit = "0.8.4" shadow-rs.workspace = true diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index bf50a4239..6b3e507fd 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -1,12 +1,12 @@ use crate::license::get_license; use axum::{ body::Body, - extract::Host, http::{Response, StatusCode}, response::IntoResponse, routing::get, Router, }; +use axum_extra::extract::Host; use axum_server::tls_rustls::RustlsConfig; use mime_guess::from_path; use rust_embed::RustEmbed; diff --git a/rustfs/src/service.rs b/rustfs/src/service.rs index 7262fb689..d04729e25 100644 --- a/rustfs/src/service.rs +++ b/rustfs/src/service.rs @@ -80,8 +80,7 @@ pin_project! { impl Default for HybridBody where RestBody: Default, - - GrpcBody: Default, + // GrpcBody: Default, { fn default() -> Self { Self::Rest { From a07ca8ae8157ea8b387b2a452341fcc45ca6449b Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 15:12:31 +0800 Subject: [PATCH 074/103] improve code for obs --- Cargo.toml | 7 ++++--- {packages => crates}/obs/Cargo.toml | 0 {packages => crates}/obs/examples/config.toml | 0 {packages => crates}/obs/examples/server.rs | 0 {packages => crates}/obs/src/config.rs | 0 {packages => crates}/obs/src/entry/args.rs | 0 {packages => crates}/obs/src/entry/audit.rs | 0 {packages => crates}/obs/src/entry/base.rs | 0 {packages => crates}/obs/src/entry/mod.rs | 15 ++++++++------- {packages => crates}/obs/src/entry/unified.rs | 10 +++++++++- {packages => crates}/obs/src/global.rs | 0 {packages => crates}/obs/src/lib.rs | 0 {packages => crates}/obs/src/logger.rs | 7 ++++--- {packages => crates}/obs/src/sink.rs | 2 +- {packages => crates}/obs/src/telemetry.rs | 0 {packages => crates}/obs/src/utils.rs | 0 {packages => crates}/obs/src/worker.rs | 0 17 files changed, 26 insertions(+), 15 deletions(-) rename {packages => crates}/obs/Cargo.toml (100%) rename {packages => crates}/obs/examples/config.toml (100%) rename {packages => crates}/obs/examples/server.rs (100%) rename {packages => crates}/obs/src/config.rs (100%) rename {packages => crates}/obs/src/entry/args.rs (100%) rename {packages => crates}/obs/src/entry/audit.rs (100%) rename {packages => crates}/obs/src/entry/base.rs (100%) rename {packages => crates}/obs/src/entry/mod.rs (96%) rename {packages => crates}/obs/src/entry/unified.rs (98%) rename {packages => crates}/obs/src/global.rs (100%) rename {packages => crates}/obs/src/lib.rs (100%) rename {packages => crates}/obs/src/logger.rs (98%) rename {packages => crates}/obs/src/sink.rs (99%) rename {packages => crates}/obs/src/telemetry.rs (100%) rename {packages => crates}/obs/src/utils.rs (100%) rename {packages => crates}/obs/src/worker.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index a7d2b06d3..83e25a062 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,10 @@ members = [ "iam", # Identity and Access Management "crypto", # Cryptography and security features "cli/rustfs-gui", # Graphical user interface client - "packages/obs", # Observability utilities + "crates/obs", # Observability utilities "s3select/api", - "s3select/query", "appauth", + "s3select/query", + "appauth", ] resolver = "2" @@ -88,7 +89,7 @@ reqwest = { version = "0.12.15", default-features = false, features = ["rustls-t rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } rmp = "0.8.14" rmp-serde = "1.3.0" -rustfs-obs = { path = "packages/obs", version = "0.0.1" } +rustfs-obs = { path = "crates/obs", version = "0.0.1" } rust-embed = "8.6.0" rustls = { version = "0.23" } rustls-pki-types = "1.11.0" diff --git a/packages/obs/Cargo.toml b/crates/obs/Cargo.toml similarity index 100% rename from packages/obs/Cargo.toml rename to crates/obs/Cargo.toml diff --git a/packages/obs/examples/config.toml b/crates/obs/examples/config.toml similarity index 100% rename from packages/obs/examples/config.toml rename to crates/obs/examples/config.toml diff --git a/packages/obs/examples/server.rs b/crates/obs/examples/server.rs similarity index 100% rename from packages/obs/examples/server.rs rename to crates/obs/examples/server.rs diff --git a/packages/obs/src/config.rs b/crates/obs/src/config.rs similarity index 100% rename from packages/obs/src/config.rs rename to crates/obs/src/config.rs diff --git a/packages/obs/src/entry/args.rs b/crates/obs/src/entry/args.rs similarity index 100% rename from packages/obs/src/entry/args.rs rename to crates/obs/src/entry/args.rs diff --git a/packages/obs/src/entry/audit.rs b/crates/obs/src/entry/audit.rs similarity index 100% rename from packages/obs/src/entry/audit.rs rename to crates/obs/src/entry/audit.rs diff --git a/packages/obs/src/entry/base.rs b/crates/obs/src/entry/base.rs similarity index 100% rename from packages/obs/src/entry/base.rs rename to crates/obs/src/entry/base.rs diff --git a/packages/obs/src/entry/mod.rs b/crates/obs/src/entry/mod.rs similarity index 96% rename from packages/obs/src/entry/mod.rs rename to crates/obs/src/entry/mod.rs index 72dae2611..6718e5050 100644 --- a/packages/obs/src/entry/mod.rs +++ b/crates/obs/src/entry/mod.rs @@ -46,10 +46,17 @@ impl ObjectVersion { } } +impl Default for ObjectVersion { + fn default() -> Self { + Self::new() + } +} + /// Log kind/level enum -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)] pub enum LogKind { #[serde(rename = "INFO")] + #[default] Info, #[serde(rename = "WARNING")] Warning, @@ -59,12 +66,6 @@ pub enum LogKind { Fatal, } -impl Default for LogKind { - fn default() -> Self { - LogKind::Info - } -} - /// Trait for types that can be serialized to JSON and have a timestamp /// This trait is used by `ServerLogEntry` to convert the log entry to JSON /// and get the timestamp of the log entry diff --git a/packages/obs/src/entry/unified.rs b/crates/obs/src/entry/unified.rs similarity index 98% rename from packages/obs/src/entry/unified.rs rename to crates/obs/src/entry/unified.rs index 598ebe792..877b2f8fc 100644 --- a/packages/obs/src/entry/unified.rs +++ b/crates/obs/src/entry/unified.rs @@ -99,6 +99,7 @@ impl LogRecord for ServerLogEntry { /// - `console_msg` - the console message /// - `node_name` - the node name /// - `err` - the error message +/// /// The `ConsoleLogEntry` structure contains the following methods: /// - `new` - create a new `ConsoleLogEntry` /// - `new_with_console_msg` - create a new `ConsoleLogEntry` with console message and node name @@ -107,6 +108,7 @@ impl LogRecord for ServerLogEntry { /// - `set_node_name` - set the node name /// - `set_console_msg` - set the console message /// - `set_err` - set the error message +/// /// # Example /// ``` /// use rustfs_obs::ConsoleLogEntry; @@ -180,6 +182,12 @@ impl ConsoleLogEntry { } } +impl Default for ConsoleLogEntry { + fn default() -> Self { + Self::new() + } +} + impl LogRecord for ConsoleLogEntry { fn to_json(&self) -> String { serde_json::to_string(self).unwrap_or_else(|_| String::from("{}")) @@ -217,7 +225,7 @@ pub enum UnifiedLogEntry { Server(ServerLogEntry), #[serde(rename = "audit")] - Audit(AuditLogEntry), + Audit(Box), #[serde(rename = "console")] Console(ConsoleLogEntry), diff --git a/packages/obs/src/global.rs b/crates/obs/src/global.rs similarity index 100% rename from packages/obs/src/global.rs rename to crates/obs/src/global.rs diff --git a/packages/obs/src/lib.rs b/crates/obs/src/lib.rs similarity index 100% rename from packages/obs/src/lib.rs rename to crates/obs/src/lib.rs diff --git a/packages/obs/src/logger.rs b/crates/obs/src/logger.rs similarity index 98% rename from packages/obs/src/logger.rs rename to crates/obs/src/logger.rs index 77862a942..55f4bd0e3 100644 --- a/packages/obs/src/logger.rs +++ b/crates/obs/src/logger.rs @@ -50,7 +50,7 @@ impl Logger { /// Log an audit entry #[tracing::instrument(skip(self), fields(log_source = "logger_audit"))] pub async fn log_audit_entry(&self, entry: AuditLogEntry) -> Result<(), LogError> { - self.log_entry(UnifiedLogEntry::Audit(entry)).await + self.log_entry(UnifiedLogEntry::Audit(Box::new(entry))).await } /// Log a console entry @@ -61,13 +61,14 @@ impl Logger { /// Asynchronous logging of unified log entries #[tracing::instrument(skip(self), fields(log_source = "logger"))] + #[tracing::instrument(level = "error", skip_all)] pub async fn log_entry(&self, entry: UnifiedLogEntry) -> Result<(), LogError> { // Extract information for tracing based on entry type match &entry { UnifiedLogEntry::Server(server) => { tracing::Span::current() - .record("log_level", &server.level.0.as_str()) - .record("log_message", &server.base.message.as_deref().unwrap_or("")) + .record("log_level", server.level.0.as_str()) + .record("log_message", server.base.message.as_deref().unwrap_or("log message not set")) .record("source", &server.source); // Generate tracing event based on log level diff --git a/packages/obs/src/sink.rs b/crates/obs/src/sink.rs similarity index 99% rename from packages/obs/src/sink.rs rename to crates/obs/src/sink.rs index 4a44f0ea4..1f1c481f8 100644 --- a/packages/obs/src/sink.rs +++ b/crates/obs/src/sink.rs @@ -284,7 +284,7 @@ impl FileSink { // If the file does not exist, create it debug!("FileSink: File does not exist, creating a new file."); // Create the file and write a header or initial content if needed - OpenOptions::new().create(true).write(true).open(&path).await? + OpenOptions::new().create(true).truncate(true).write(true).open(&path).await? }; let writer = io::BufWriter::with_capacity(buffer_size, file); let now = std::time::SystemTime::now() diff --git a/packages/obs/src/telemetry.rs b/crates/obs/src/telemetry.rs similarity index 100% rename from packages/obs/src/telemetry.rs rename to crates/obs/src/telemetry.rs diff --git a/packages/obs/src/utils.rs b/crates/obs/src/utils.rs similarity index 100% rename from packages/obs/src/utils.rs rename to crates/obs/src/utils.rs diff --git a/packages/obs/src/worker.rs b/crates/obs/src/worker.rs similarity index 100% rename from packages/obs/src/worker.rs rename to crates/obs/src/worker.rs From d3ce2e04faaef221963824b258172a70be48e06c Mon Sep 17 00:00:00 2001 From: weisd Date: Wed, 9 Apr 2025 15:49:12 +0800 Subject: [PATCH 075/103] fix: #305 --- ecstore/src/disk/local.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 76b5f3ac3..3031a6069 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -472,13 +472,14 @@ impl LocalDisk { let meta = f.metadata().await?; if meta.is_dir() { - return Err(Error::new(DiskError::FileNotFound)); + // fix use io::Error + return Err(std::io::Error::new(ErrorKind::NotFound, "is dir").into()); } let meta = f.metadata().await.map_err(os_err_to_file_err)?; if meta.is_dir() { - return Err(Error::new(DiskError::FileNotFound)); + return Err(std::io::Error::new(ErrorKind::NotFound, "is dir").into()); } let size = meta.len() as usize; @@ -816,8 +817,6 @@ impl LocalDisk { // 第一层过滤 for item in entries.iter_mut() { - // warn!("walk_dir get entry {:?}", &entry); - let entry = item.clone(); // check limit if opts.limit > 0 && *objs_returned >= opts.limit { @@ -857,7 +856,10 @@ impl LocalDisk { let metadata = self .read_metadata(self.get_object_path(bucket, format!("{}/{}", ¤t, &entry).as_str())?) .await?; - let name = entry.trim_end_matches(STORAGE_FORMAT_FILE).trim_end_matches(SLASH_SEPARATOR); + + // 用strip_suffix只删除一次 + let entry = entry.strip_suffix(STORAGE_FORMAT_FILE).unwrap_or_default().to_owned(); + let name = entry.trim_end_matches(SLASH_SEPARATOR); let name = decode_dir_object(format!("{}/{}", ¤t, &name).as_str()); out.write_obj(&MetaCacheEntry { @@ -887,7 +889,6 @@ impl LocalDisk { let mut dir_stack: Vec = Vec::with_capacity(5); for entry in entries.iter() { - // if opts.limit > 0 && *objs_returned >= opts.limit { return Ok(()); } From 3201ad9315e34dde5bd1308ce09bcbd98268fe04 Mon Sep 17 00:00:00 2001 From: weisd Date: Wed, 9 Apr 2025 17:21:21 +0800 Subject: [PATCH 076/103] delete files when move to trash --- ecstore/src/disk/local.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index c5a23fa77..e07cf989e 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -51,8 +51,6 @@ use path_absolutize::Absolutize; use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::io::SeekFrom; -#[cfg(unix)] -use std::os::unix::fs::MetadataExt; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::Arc; use std::time::{Duration, SystemTime}; @@ -309,7 +307,19 @@ impl LocalDisk { // }) // } + #[allow(unreachable_code)] + #[allow(unused_variables)] pub async fn move_to_trash(&self, delete_path: &PathBuf, recursive: bool, immediate_purge: bool) -> Result<()> { + if recursive { + remove_all(delete_path).await?; + } else { + remove(delete_path).await?; + } + + return Ok(()); + + // TODO: 异步通知 检测硬盘空间 清空回收站 + let trash_path = self.get_object_path(super::RUSTFS_META_TMP_DELETED_BUCKET, Uuid::new_v4().to_string().as_str())?; if let Some(parent) = trash_path.parent() { if !parent.exists() { @@ -348,7 +358,6 @@ impl LocalDisk { return Ok(()); } - // TODO: 异步通知 检测硬盘空间 清空回收站 Ok(()) } From c872901269746fc53ef1ea1c0fbb9064b92fb3dd Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 18:36:17 +0800 Subject: [PATCH 077/103] improve Cargo.toml and modify README.md conosel web static url --- Cargo.lock | 37 ++++++++++++++++++++++++++--- Cargo.toml | 16 ++++++++----- README.md | 3 ++- rustfs/Cargo.toml | 60 ++++++++++++++++++++--------------------------- 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca4e5b4e9..68b1892ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3035,7 +3035,7 @@ dependencies = [ "madmin", "md-5", "netif", - "nix", + "nix 0.29.0", "num", "num_cpus", "path-absolutize", @@ -4698,6 +4698,24 @@ dependencies = [ "libc", ] +[[package]] +name = "libsystemd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c592dc396b464005f78a5853555b9f240bc5378bf5221acc4e129910b2678869" +dependencies = [ + "hmac 0.12.1", + "libc", + "log", + "nix 0.27.1", + "nom", + "once_cell", + "serde", + "sha2 0.10.8", + "thiserror 1.0.69", + "uuid", +] + [[package]] name = "libxdo" version = "0.6.0" @@ -5113,6 +5131,18 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.9.0", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "nix" version = "0.29.0" @@ -7125,6 +7155,7 @@ dependencies = [ "iam", "jsonwebtoken", "lazy_static", + "libsystemd", "local-ip-address", "lock", "madmin", @@ -9894,7 +9925,7 @@ dependencies = [ "futures-sink", "futures-util", "hex", - "nix", + "nix 0.29.0", "ordered-stream", "rand 0.8.5", "serde", @@ -9925,7 +9956,7 @@ dependencies = [ "futures-core", "futures-lite", "hex", - "nix", + "nix 0.29.0", "ordered-stream", "serde", "serde_repr", diff --git a/Cargo.toml b/Cargo.toml index 83e25a062..5a126ae34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,8 +33,12 @@ all = "warn" [workspace.dependencies] madmin = { path = "./madmin" } +atoi = "2.0.0" async-recursion = "1.0.5" async-trait = "0.1.87" +axum = "0.8.3" +axum-extra = "0.10.1" +axum-server = { version = "0.7.2", features = ["tls-rustls"] } backon = "1.3.0" bytes = "1.9.0" bytesize = "1.3.0" @@ -64,7 +68,10 @@ humantime = "2.1.0" keyring = { version = "3.6.1", features = ["apple-native", "windows-native", "sync-secret-service"] } lock = { path = "./common/lock" } lazy_static = "1.5.0" +libsystemd = "0.7.0" local-ip-address = "0.6.3" +matchit = "0.8.4" +md-5 = "0.10.6" mime = "0.3.17" netif = "0.1.6" once_cell = "1.21.1" @@ -101,8 +108,11 @@ s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb shadow-rs = { version = "0.38.0", default-features = false } serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.138" +serde_urlencoded = "0.7.1" sha2 = "0.10.8" +snafu = "0.8.5" tempfile = "3.16.0" +test-case = "3.3.1" thiserror = "2.0.12" time = { version = "0.3.41", features = [ "std", @@ -133,13 +143,7 @@ uuid = { version = "1.15.1", features = [ "fast-rng", "macro-diagnostics", ] } -axum = "0.8.3" -axum-extra = "0.10.1" -axum-server = { version = "0.7.2", features = ["tls-rustls"] } -md-5 = "0.10.6" workers = { path = "./common/workers" } -test-case = "3.3.1" -snafu = "0.8.5" [profile.wasm-dev] inherits = "dev" diff --git a/README.md b/README.md index 217ab3c14..9882ae927 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ Or use Docker: # How to add Console web -1. wget [http://dl.rustfs.com/console/console.latest.tar.gz](https://dl.rustfs.com/console/rustfs-console-latest.zip) +1. +wget [http://dl.rustfs.com/console/console.latest.tar.gz](https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip) 2. mkdir in this repos folder `./rustfs/static` diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 1ab8beb8a..902e0053c 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -16,12 +16,21 @@ workspace = true [dependencies] madmin.workspace = true +api = { path = "../s3select/api" } +appauth = { version = "0.0.1", path = "../appauth" } +atoi = { workspace = true } +axum.workspace = true +axum-extra = { workspace = true } +axum-server = { workspace = true } async-trait.workspace = true bytes.workspace = true +chrono = { workspace = true } clap.workspace = true csv = "1.3.1" +crypto = { path = "../crypto" } datafusion = { workspace = true } common.workspace = true +const-str = { version = "0.6.1", features = ["std", "proc"] } ecstore.workspace = true policy.workspace = true flatbuffers.workspace = true @@ -32,8 +41,14 @@ hyper.workspace = true hyper-util.workspace = true http.workspace = true http-body.workspace = true +iam = { path = "../iam" } +jsonwebtoken = "9.3.0" +libsystemd = { workspace = true } lock.workspace = true +local-ip-address = { workspace = true } +matchit = { workspace = true } mime.workspace = true +mime_guess = "2.0.5" netif.workspace = true once_cell.workspace = true pin-project-lite.workspace = true @@ -41,22 +56,22 @@ prost.workspace = true prost-types.workspace = true protos.workspace = true protobuf.workspace = true +query = { path = "../s3select/query" } rmp-serde.workspace = true +rustfs-obs = { workspace = true } rustls.workspace = true rustls-pemfile.workspace = true rustls-pki-types.workspace = true +rust-embed = { workspace = true, features = ["interpolate-folder-path"] } s3s.workspace = true serde.workspace = true serde_json.workspace = true +serde_urlencoded = { workspace = true } +shadow-rs.workspace = true tracing.workspace = true time = { workspace = true, features = ["parsing", "formatting", "serde"] } tokio-util.workspace = true -tokio = { workspace = true, features = [ - "rt-multi-thread", - "macros", - "net", - "signal", -] } +tokio = { workspace = true, features = ["rt-multi-thread", "macros", "net", "signal"] } tokio-rustls.workspace = true lazy_static.workspace = true tokio-stream.workspace = true @@ -67,28 +82,9 @@ tracing-core = { workspace = true } tracing-error.workspace = true tracing-subscriber.workspace = true transform-stream.workspace = true -uuid = "1.15.1" -url.workspace = true -axum.workspace = true -axum-extra = { workspace = true } -axum-server = { workspace = true } -matchit = "0.8.4" -shadow-rs.workspace = true -const-str = { version = "0.6.1", features = ["std", "proc"] } -atoi = "2.0.0" -serde_urlencoded = "0.7.1" -crypto = { path = "../crypto" } -query = { path = "../s3select/query" } -api = { path = "../s3select/api" } -iam = { path = "../iam" } -jsonwebtoken = "9.3.0" tower-http.workspace = true -mime_guess = "2.0.5" -rust-embed = { workspace = true, features = ["interpolate-folder-path"] } -local-ip-address = { workspace = true } -chrono = { workspace = true } -rustfs-obs = { workspace = true } -appauth = { version = "0.0.1", path = "../appauth" } +url.workspace = true +uuid = "1.15.1" [build-dependencies] prost-build.workspace = true @@ -101,13 +97,9 @@ futures-util.workspace = true ecstore = { path = "../ecstore" } s3s.workspace = true clap = { workspace = true } -tracing-subscriber = { version = "0.3.19", features = ["env-filter", "time"] } -hyper-util = { version = "0.1.10", features = [ - "tokio", - "server-auto", - "server-graceful", -] } -transform-stream = "0.3.1" +tracing-subscriber = { workspace = true, features = ["env-filter", "time"] } +hyper-util = { workspace = true, features = ["tokio", "server-auto", "server-graceful"] } +transform-stream = { workspace = true } netif = "0.1.6" shadow-rs.workspace = true # pin-utils = "0.1.0" From 952f04149f7ddd8203a2dcbc8578019af2df3c69 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 19:11:31 +0800 Subject: [PATCH 078/103] add notify systemd --- Cargo.toml | 2 +- rustfs/Cargo.toml | 5 ++++- rustfs/src/console.rs | 2 +- rustfs/src/main.rs | 41 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5a126ae34..9f1b721ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ humantime = "2.1.0" keyring = { version = "3.6.1", features = ["apple-native", "windows-native", "sync-secret-service"] } lock = { path = "./common/lock" } lazy_static = "1.5.0" -libsystemd = "0.7.0" +libsystemd = { version = "0.7" } local-ip-address = "0.6.3" matchit = "0.8.4" md-5 = "0.10.6" diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 902e0053c..00c10bebd 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -43,7 +43,7 @@ http.workspace = true http-body.workspace = true iam = { path = "../iam" } jsonwebtoken = "9.3.0" -libsystemd = { workspace = true } +libsystemd = { workspace = true, optional = true } lock.workspace = true local-ip-address = { workspace = true } matchit = { workspace = true } @@ -86,6 +86,9 @@ tower-http.workspace = true url.workspace = true uuid = "1.15.1" +[target.'cfg(target_os = "linux")'.dependencies] +libsystemd = "0.7" + [build-dependencies] prost-build.workspace = true tonic-build.workspace = true diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index 6b3e507fd..1eff0e906 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -216,7 +216,7 @@ pub async fn start_static_file_server( let app = Router::new() .route("/license", get(license_handler)) .route("/config.json", get(config_handler)) - .nest_service("/", get(static_handler)); + .fallback_service(get(static_handler)); let local_addr: SocketAddr = addrs.parse().expect("Failed to parse socket address"); info!("WebUI: http://{}:{} http://127.0.0.1:{}", local_ip, local_addr.port(), local_addr.port()); info!(" RootUser: {}", access_key); diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 4481525bb..bd6d66d06 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -53,6 +53,27 @@ use tracing::{debug, error, info, info_span, warn}; use tracing_error::ErrorLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; +#[cfg(target_os = "linux")] +fn notify_systemd(state: &str) { + use libsystemd::daemon::{notify, NotifyState}; + let notify_state = match state { + "ready" => NotifyState::Ready, + "stopping" => NotifyState::Stopping, + _ => return, + }; + + if let Err(e) = notify(false, &[notify_state]) { + error!("Failed to notify systemd: {}", e); + } else { + debug!("Successfully notified systemd: {}", state); + } +} + +#[cfg(not(target_os = "linux"))] +fn notify_systemd(state: &str) { + debug!("Systemd notifications are not available on this platform (state: {})", state); +} + #[allow(dead_code)] fn setup_tracing() { use tracing_subscriber::EnvFilter; @@ -260,6 +281,9 @@ async fn run(opt: config::Opt) -> Result<()> { None }; + // Create a oneshot channel to wait for the service to start + let (tx, rx) = tokio::sync::oneshot::channel(); + tokio::spawn(async move { let hyper_service = service.into_shared(); let hybrid_service = TowerToHyperService::new( @@ -272,6 +296,10 @@ async fn run(opt: config::Opt) -> Result<()> { let mut ctrl_c = std::pin::pin!(tokio::signal::ctrl_c()); let graceful = hyper_util::server::graceful::GracefulShutdown::new(); debug!("graceful initiated"); + + // Send a message to the main thread to indicate that the server has started + let _ = tx.send(()); + loop { debug!("waiting for SIGINT or SIGTERM has_tls_certs: {}", has_tls_certs); // Wait for a connection @@ -286,9 +314,12 @@ async fn run(opt: config::Opt) -> Result<()> { } } _ = ctrl_c.as_mut() => { + drop(listener); + eprintln!("Ctrl-C received, starting shutdown"); break; } }; + if has_tls_certs { debug!("TLS certificates found, starting with SIGINT"); let tls_socket = match tls_acceptor @@ -353,7 +384,7 @@ async fn run(opt: config::Opt) -> Result<()> { })?; debug!("init store success!"); - init_iam_sys(store.clone()).await.unwrap(); + init_iam_sys(store.clone()).await?; new_global_notification_sys(endpoint_pools.clone()).await.map_err(|err| { error!("new_global_notification_sys failed {:?}", &err); @@ -386,9 +417,15 @@ async fn run(opt: config::Opt) -> Result<()> { }); } + // Wait for the HTTP service to finish starting + if rx.await.is_ok() { + notify_systemd("ready"); + } + tokio::select! { _ = tokio::signal::ctrl_c() => { - + eprintln!("Ctrl-C received, starting shutdown"); + notify_systemd("stopping"); } } From f73bc6a82b9077dc6b12f7f20e6a7fe8574f2a80 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 19:11:56 +0800 Subject: [PATCH 079/103] add rsutfs.service and run.md --- rustfs-zh.service | 102 ++++++++++++++++++++++++++++++++++++++++++++++ rustfs.run-zh.md | 90 ++++++++++++++++++++++++++++++++++++++++ rustfs.run.md | 90 ++++++++++++++++++++++++++++++++++++++++ rustfs.service | 60 +++++++++++++++++++++++++++ 4 files changed, 342 insertions(+) create mode 100644 rustfs-zh.service create mode 100644 rustfs.run-zh.md create mode 100644 rustfs.run.md create mode 100644 rustfs.service diff --git a/rustfs-zh.service b/rustfs-zh.service new file mode 100644 index 000000000..2541ec77c --- /dev/null +++ b/rustfs-zh.service @@ -0,0 +1,102 @@ +[Unit] +Description=RustFS Object Storage Server +# 定义服务的描述,说明这是一个 RustFS 对象存储服务器,显示在 systemctl status 中。 +Documentation=https://rustfs.com/docs/ +# 提供服务的官方文档链接,方便管理员查阅,占位符需替换为实际 URL。 +After=network-online.target +# 指定服务在 network-online.target(网络就绪)之后启动,确保网络可用。 +Wants=network-online.target +# 表示服务希望依赖 network-online.target,但不是强依赖,即使网络未就绪也尝试启动。 +# If you're using a database, you'll need to add the corresponding dependencies +# 如果服务依赖数据库,可以添加数据库相关的依赖项(当前为注释,未启用)。 +# After=postgresql.service +# 示例:若依赖 PostgreSQL,则在 PostgreSQL 服务后启动(当前未启用)。 +# Requires=postgresql.service +# 示例:若强制依赖 PostgreSQL,则要求其启动成功(当前未启用)。 + +[Service] +Type=notify +# 服务类型为 notify,表示服务通过 sd_notify 通知 systemd 其状态(如就绪)。 +NotifyAccess=main +# 指定只有主进程可以发送通知给 systemd,避免子进程干扰。 +User=rustfs +# 以 rustfs 用户身份运行服务,需预先创建此用户,提升安全性。 +Group=rustfs +# 以 rustfs 组身份运行服务,与 User 配合使用。 + +# environment variable configuration +# 定义环境变量配置,用于传递给服务程序。 +Environment=RUST_LOG=info +# 设置日志级别为 info,控制服务日志输出(需服务支持此变量)。 +Environment=RUSTFS_ACCESS_KEY=rustfsadmin +# 设置访问密钥为 rustfsadmin,用于 RustFS 的认证。 +Environment=RUSTFS_SECRET_KEY=rustfsadmin +# 设置秘密密钥为 rustfsadmin,与访问密钥配套使用。 + +# working directory +WorkingDirectory=/opt/rustfs +# 设置服务的工作目录为 /opt/rustfs,影响相对路径的解析。 + +# main program +ExecStart=/usr/local/bin/rustfs \ + --address 0.0.0.0:9000 \ + --volumes /data/rustfs/vol1,/data/rustfs/vol2 \ + --obs-config /etc/rustfs/obs.yaml \ + --console-enable \ + --console-address 0.0.0.0:9002 +# 定义启动命令,运行 /usr/local/bin/rustfs,带参数: +# --address 0.0.0.0:9000:服务监听所有接口的 9000 端口。 +# --volumes:指定存储卷路径为 /data/rustfs/vol1 和 /data/rustfs/vol2。 +# --obs-config:指定配置文件路径为 /etc/rustfs/obs.yaml。 +# --console-enable:启用控制台功能。 +# --console-address 0.0.0.0:9002:控制台监听所有接口的 9002 端口。 + +# resource constraints +LimitNOFILE=1048576 +# 设置文件描述符上限为 1048576,支持高并发连接。 +LimitNPROC=32768 +# 设置进程数上限为 32768,限制子进程数量。 +TasksMax=infinity +# 允许服务创建无限数量的线程(谨慎使用,可能耗尽资源)。 + +# restart the policy +Restart=always +# 服务异常退出时总是重启,提高可用性。 +RestartSec=10s +# 重启前等待 10 秒,避免频繁重启导致资源浪费。 + +# graceful exit configuration +TimeoutStartSec=30s +# 启动超时时间为 30 秒,若超时则认为启动失败。 +TimeoutStopSec=30s +# 停止超时时间为 30 秒,若超时则强制停止。 + +# security settings +NoNewPrivileges=true +# 禁止服务提升权限,增强安全性。 +ProtectSystem=full +# 保护系统目录(如 /usr、/boot、/etc)为只读,防止服务修改。 +ProtectHome=true +# 保护用户主目录(如 /home、/root),禁止服务访问。 +PrivateTmp=true +# 为服务提供私有 /tmp 目录,隔离临时文件。 +PrivateDevices=true +# 禁止服务访问硬件设备(如 /dev),提升安全性。 +ProtectClock=true +# 保护系统时钟,禁止服务修改时间。 +ProtectKernelTunables=true +# 保护内核参数(/proc/sys),禁止服务修改。 +ProtectKernelModules=true +# 禁止服务加载或卸载内核模块。 +ProtectControlGroups=true +# 保护控制组(cgroups),禁止服务修改。 +RestrictSUIDSGID=true +# 禁止服务使用 SUID/SGID 文件,提升安全性。 +RestrictRealtime=true +# 禁止服务使用实时调度,防止资源滥用。 +ReadWritePaths=/data/rustfs +# 允许服务对 /data/rustfs 目录读写,限制其他路径访问。 + +[Install] +WantedBy=multi-user.target +# 服务在多用户模式下自动启动,配合 systemctl enable 使用。 \ No newline at end of file diff --git a/rustfs.run-zh.md b/rustfs.run-zh.md new file mode 100644 index 000000000..85def56e7 --- /dev/null +++ b/rustfs.run-zh.md @@ -0,0 +1,90 @@ +# RustFS 服务安装配置教程 + +## 1. 准备工作 + +### 1.1 创建系统用户 + +```bash +# 创建 rustfs 系统用户和用户组,禁止登录shell +sudo useradd -r -s /sbin/nologin rustfs +``` + +### 1.2 创建必要目录 + +```bash +# 创建程序目录 +sudo mkdir -p /opt/rustfs + +# 创建数据目录 +sudo mkdir -p /data/rustfs/{vol1,vol2} + +# 创建配置目录 +sudo mkdir -p /etc/rustfs + +# 设置目录权限 +sudo chown -R rustfs:rustfs /opt/rustfs /data/rustfs +sudo chmod 755 /opt/rustfs /data/rustfs +``` + +## 2. 安装 RustFS + +```bash +# 复制 RustFS 二进制文件 +sudo cp rustfs /usr/local/bin/ +sudo chmod +x /usr/local/bin/rustfs + +# 复制配置文件 +sudo cp obs.yaml /etc/rustfs/ +sudo chown -R rustfs:rustfs /etc/rustfs +``` + +## 3. 配置 Systemd 服务 + +```bash +# 复制服务单元文件 +sudo cp rustfs.service /etc/systemd/system/ + +# 重新加载 systemd 配置 +sudo systemctl daemon-reload +``` + +## 4. 服务管理 + +### 4.1 启动服务 + +```bash +sudo systemctl start rustfs +``` + +### 4.2 查看服务状态 + +```bash +sudo systemctl status rustfs +``` + +### 4.3 启用开机自启 + +```bash +sudo systemctl enable rustfs +``` + +### 4.4 查看服务日志 + +```bash +# 查看实时日志 +sudo journalctl -u rustfs -f + +# 查看今天的日志 +sudo journalctl -u rustfs --since today +``` + +## 5. 验证安装 + +```bash +# 检查服务端口 +ss -tunlp | grep 9000 +ss -tunlp | grep 9002 + +# 测试服务可用性 +curl -I http://localhost:9000 +``` diff --git a/rustfs.run.md b/rustfs.run.md new file mode 100644 index 000000000..2e26ea31a --- /dev/null +++ b/rustfs.run.md @@ -0,0 +1,90 @@ +# RustFS Service Installation Guide + +## 1. Prerequisites + +### 1.1 Create System User + +```bash +# Create rustfs system user and group without login shell +sudo useradd -r -s /sbin/nologin rustfs +``` + +### 1.2 Create Required Directories + +```bash +# Create program directory +sudo mkdir -p /opt/rustfs + +# Create data directories +sudo mkdir -p /data/rustfs/{vol1,vol2} + +# Create configuration directory +sudo mkdir -p /etc/rustfs + +# Set directory permissions +sudo chown -R rustfs:rustfs /opt/rustfs /data/rustfs +sudo chmod 755 /opt/rustfs /data/rustfs +``` + +## 2. Install RustFS + +```bash +# Copy RustFS binary +sudo cp rustfs /usr/local/bin/ +sudo chmod +x /usr/local/bin/rustfs + +# Copy configuration file +sudo cp obs.yaml /etc/rustfs/ +sudo chown -R rustfs:rustfs /etc/rustfs +``` + +## 3. Configure Systemd Service + +```bash +# Copy service unit file +sudo cp rustfs.service /etc/systemd/system/ + +# Reload systemd configuration +sudo systemctl daemon-reload +``` + +## 4. Service Management + +### 4.1 Start Service + +```bash +sudo systemctl start rustfs +``` + +### 4.2 Check Service Status + +```bash +sudo systemctl status rustfs +``` + +### 4.3 Enable Auto-start + +```bash +sudo systemctl enable rustfs +``` + +### 4.4 View Service Logs + +```bash +# View real-time logs +sudo journalctl -u rustfs -f + +# View today's logs +sudo journalctl -u rustfs --since today +``` + +## 5. Verify Installation + +```bash +# Check service ports +ss -tunlp | grep 9000 +ss -tunlp | grep 9002 + +# Test service availability +curl -I http://localhost:9000 +``` diff --git a/rustfs.service b/rustfs.service new file mode 100644 index 000000000..53db8a64a --- /dev/null +++ b/rustfs.service @@ -0,0 +1,60 @@ +[Unit] +Description=RustFS Object Storage Server +Documentation=https://rustfs.com/docs/ +After=network-online.target +Wants=network-online.target +# If you're using a database, you'll need to add the corresponding dependencies +# After=postgresql.service +# Requires=postgresql.service + +[Service] +Type=notify +NotifyAccess=main +User=rustfs +Group=rustfs + +# environment variable configuration +Environment=RUST_LOG=info +Environment=RUSTFS_ACCESS_KEY=rustfsadmin +Environment=RUSTFS_SECRET_KEY=rustfsadmin + +# working directory +WorkingDirectory=/opt/rustfs + +# main program +ExecStart=/usr/local/bin/rustfs \ + --address 0.0.0.0:9000 \ + --volumes /data/rustfs/vol1,/data/rustfs/vol2 \ + --obs-config /etc/rustfs/obs.yaml \ + --console-enable \ + --console-address 0.0.0.0:9002 + +# resource constraints +LimitNOFILE=1048576 +LimitNPROC=32768 +TasksMax=infinity + +# restart the policy +Restart=always +RestartSec=10s + +# graceful exit configuration +TimeoutStartSec=30s +TimeoutStopSec=30s + +# security settings +NoNewPrivileges=true +ProtectSystem=full +ProtectHome=true +PrivateTmp=true +PrivateDevices=true +ProtectClock=true +ProtectKernelTunables=true +ProtectKernelModules=true +ProtectControlGroups=true +RestrictSUIDSGID=true +RestrictRealtime=true +ReadWritePaths=/data/rustfs + +[Install] +WantedBy=multi-user.target \ No newline at end of file From f48d8fc65e7ee7405bd592e20968d7855e1ed751 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 19:15:49 +0800 Subject: [PATCH 080/103] Update rustfs/src/main.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rustfs/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index bd6d66d06..2e6760ed4 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -59,7 +59,10 @@ fn notify_systemd(state: &str) { let notify_state = match state { "ready" => NotifyState::Ready, "stopping" => NotifyState::Stopping, - _ => return, + _ => { + warn!("Unsupported state passed to notify_systemd: {}", state); + return; + }, }; if let Err(e) = notify(false, &[notify_state]) { From fdd7b1482530fbc31f59097b297b5c907eb59806 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 21:52:30 +0800 Subject: [PATCH 081/103] create get default log path func --- crates/obs/examples/server.rs | 2 +- crates/obs/src/config.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/obs/examples/server.rs b/crates/obs/examples/server.rs index 0af2fcd02..55977b10c 100644 --- a/crates/obs/examples/server.rs +++ b/crates/obs/examples/server.rs @@ -7,7 +7,7 @@ use tracing_core::Level; #[tokio::main] async fn main() { - let obs_conf = Some("packages/obs/examples/config.toml".to_string()); + let obs_conf = Some("crates/obs/examples/config.toml".to_string()); let config = load_config(obs_conf); let (_logger, _guard) = init_obs(config.clone()).await; let span = tracing::span!(Level::INFO, "main"); diff --git a/crates/obs/src/config.rs b/crates/obs/src/config.rs index be20c5b0b..4106834e3 100644 --- a/crates/obs/src/config.rs +++ b/crates/obs/src/config.rs @@ -67,11 +67,24 @@ pub struct FileSinkConfig { pub flush_threshold: Option, // Refresh threshold, default 100 logs } +impl FileSinkConfig { + pub fn get_default_log_path() -> String { + let temp_dir = env::temp_dir().join("rustfs").join("logs"); + + if let Err(e) = std::fs::create_dir_all(&temp_dir) { + eprintln!("Failed to create log directory: {}", e); + return "logs/app.log".to_string(); + } + + temp_dir.join("app.log").to_str().unwrap_or("logs/app.log").to_string() + } +} + impl Default for FileSinkConfig { fn default() -> Self { FileSinkConfig { enabled: true, - path: "logs/app.log".to_string(), + path: Self::get_default_log_path(), buffer_size: Some(8192), flush_interval_ms: Some(1000), flush_threshold: Some(100), From dc61d0720689c3cd57697e886cb0fe539e248674 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 23:45:53 +0800 Subject: [PATCH 082/103] improve code --- rustfs/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 2e6760ed4..9d211859c 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -62,7 +62,7 @@ fn notify_systemd(state: &str) { _ => { warn!("Unsupported state passed to notify_systemd: {}", state); return; - }, + } }; if let Err(e) = notify(false, &[notify_state]) { @@ -70,11 +70,12 @@ fn notify_systemd(state: &str) { } else { debug!("Successfully notified systemd: {}", state); } + info!("Systemd notifications are enabled on linux (state: {})", state); } #[cfg(not(target_os = "linux"))] fn notify_systemd(state: &str) { - debug!("Systemd notifications are not available on this platform (state: {})", state); + info!("Systemd notifications are not available on this platform not linux (state: {})", state); } #[allow(dead_code)] @@ -284,7 +285,7 @@ async fn run(opt: config::Opt) -> Result<()> { None }; - // Create a oneshot channel to wait for the service to start + // Create an oneshot channel to wait for the service to start let (tx, rx) = tokio::sync::oneshot::channel(); tokio::spawn(async move { @@ -420,9 +421,13 @@ async fn run(opt: config::Opt) -> Result<()> { }); } + // 执行休眠 1 秒钟 + tokio::time::sleep(std::time::Duration::from_secs(1)).await; // Wait for the HTTP service to finish starting if rx.await.is_ok() { notify_systemd("ready"); + } else { + info!("Failed to start the server"); } tokio::select! { From 10b787b85226e21c45427c1e685633c2b09c36b7 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 10 Apr 2025 00:38:17 +0800 Subject: [PATCH 083/103] improve code for signal --- rustfs/src/main.rs | 106 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 9d211859c..e8889fb02 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -46,6 +46,7 @@ use service::hybrid; use std::sync::Arc; use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; +use tokio::signal::unix::{signal, SignalKind}; use tokio_rustls::TlsAcceptor; use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; @@ -287,8 +288,27 @@ async fn run(opt: config::Opt) -> Result<()> { // Create an oneshot channel to wait for the service to start let (tx, rx) = tokio::sync::oneshot::channel(); - + // 启动服务 + notify_service_state(ServiceState::Starting); tokio::spawn(async move { + // 错误处理改进 + let sigterm_inner = match signal(SignalKind::terminate()) { + Ok(signal) => signal, + Err(e) => { + error!("Failed to create SIGTERM signal handler: {}", e); + return; + } + }; + let sigint_inner = match signal(SignalKind::interrupt()) { + Ok(signal) => signal, + Err(e) => { + error!("Failed to create SIGINT signal handler: {}", e); + return; + } + }; + + let mut sigterm_inner = sigterm_inner; + let mut sigint_inner = sigint_inner; let hyper_service = service.into_shared(); let hybrid_service = TowerToHyperService::new( tower::ServiceBuilder::new() @@ -322,6 +342,15 @@ async fn run(opt: config::Opt) -> Result<()> { eprintln!("Ctrl-C received, starting shutdown"); break; } + + _ = sigint_inner.recv() => { + info!("SIGINT received in worker thread"); + break; + } + _ = sigterm_inner.recv() => { + info!("SIGTERM received in worker thread"); + break; + } }; if has_tls_certs { @@ -430,13 +459,88 @@ async fn run(opt: config::Opt) -> Result<()> { info!("Failed to start the server"); } + // 主线程中监听信号 + let mut sigterm = signal(SignalKind::terminate())?; + let mut sigint = signal(SignalKind::interrupt())?; tokio::select! { _ = tokio::signal::ctrl_c() => { eprintln!("Ctrl-C received, starting shutdown"); notify_systemd("stopping"); } + + _ = sigint.recv() => { + info!("SIGINT received, starting shutdown"); + notify_systemd("stopping"); + } + _ = sigterm.recv() => { + info!("SIGTERM received, starting shutdown"); + notify_systemd("stopping"); + } } info!("server is stopped"); Ok(()) } + +#[allow(dead_code)] +#[derive(Debug)] +enum ShutdownSignal { + CtrlC, + Sigterm, + Sigint, +} +#[allow(dead_code)] +async fn wait_for_shutdown() -> ShutdownSignal { + let mut sigterm = signal(SignalKind::terminate()).unwrap(); + let mut sigint = signal(SignalKind::interrupt()).unwrap(); + + tokio::select! { + _ = tokio::signal::ctrl_c() => { + info!("Received Ctrl-C signal"); + ShutdownSignal::CtrlC + } + _ = sigint.recv() => { + info!("Received SIGINT signal"); + ShutdownSignal::Sigint + } + _ = sigterm.recv() => { + info!("Received SIGTERM signal"); + ShutdownSignal::Sigterm + } + } +} +#[allow(dead_code)] +#[derive(Debug)] +enum ServiceState { + Starting, + Ready, + Stopping, + Stopped, +} +#[allow(dead_code)] +fn notify_service_state(state: ServiceState) { + match state { + ServiceState::Starting => { + info!("Service is starting..."); + #[cfg(target_os = "linux")] + if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...")]) { + error!("Failed to notify systemd of starting state: {}", e); + } + } + ServiceState::Ready => { + info!("Service is ready"); + notify_systemd("ready"); + } + ServiceState::Stopping => { + info!("Service is stopping..."); + notify_systemd("stopping"); + } + ServiceState::Stopped => { + info!("Service has stopped"); + #[cfg(target_os = "linux")] + if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped")]) { + error!("Failed to notify systemd of stopped state: {}", e); + } + } + } +} From 6d31834799c69ef8938db9af93a5aa0af129e68b Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 10 Apr 2025 00:43:55 +0800 Subject: [PATCH 084/103] fix --- rustfs/src/main.rs | 127 ++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index e8889fb02..cd1c72d1c 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -288,8 +288,7 @@ async fn run(opt: config::Opt) -> Result<()> { // Create an oneshot channel to wait for the service to start let (tx, rx) = tokio::sync::oneshot::channel(); - // 启动服务 - notify_service_state(ServiceState::Starting); + tokio::spawn(async move { // 错误处理改进 let sigterm_inner = match signal(SignalKind::terminate()) { @@ -482,65 +481,65 @@ async fn run(opt: config::Opt) -> Result<()> { Ok(()) } -#[allow(dead_code)] -#[derive(Debug)] -enum ShutdownSignal { - CtrlC, - Sigterm, - Sigint, -} -#[allow(dead_code)] -async fn wait_for_shutdown() -> ShutdownSignal { - let mut sigterm = signal(SignalKind::terminate()).unwrap(); - let mut sigint = signal(SignalKind::interrupt()).unwrap(); - - tokio::select! { - _ = tokio::signal::ctrl_c() => { - info!("Received Ctrl-C signal"); - ShutdownSignal::CtrlC - } - _ = sigint.recv() => { - info!("Received SIGINT signal"); - ShutdownSignal::Sigint - } - _ = sigterm.recv() => { - info!("Received SIGTERM signal"); - ShutdownSignal::Sigterm - } - } -} -#[allow(dead_code)] -#[derive(Debug)] -enum ServiceState { - Starting, - Ready, - Stopping, - Stopped, -} -#[allow(dead_code)] -fn notify_service_state(state: ServiceState) { - match state { - ServiceState::Starting => { - info!("Service is starting..."); - #[cfg(target_os = "linux")] - if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...")]) { - error!("Failed to notify systemd of starting state: {}", e); - } - } - ServiceState::Ready => { - info!("Service is ready"); - notify_systemd("ready"); - } - ServiceState::Stopping => { - info!("Service is stopping..."); - notify_systemd("stopping"); - } - ServiceState::Stopped => { - info!("Service has stopped"); - #[cfg(target_os = "linux")] - if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped")]) { - error!("Failed to notify systemd of stopped state: {}", e); - } - } - } -} +// #[allow(dead_code)] +// #[derive(Debug)] +// enum ShutdownSignal { +// CtrlC, +// Sigterm, +// Sigint, +// } +// #[allow(dead_code)] +// async fn wait_for_shutdown() -> ShutdownSignal { +// let mut sigterm = signal(SignalKind::terminate()).unwrap(); +// let mut sigint = signal(SignalKind::interrupt()).unwrap(); +// +// tokio::select! { +// _ = tokio::signal::ctrl_c() => { +// info!("Received Ctrl-C signal"); +// ShutdownSignal::CtrlC +// } +// _ = sigint.recv() => { +// info!("Received SIGINT signal"); +// ShutdownSignal::Sigint +// } +// _ = sigterm.recv() => { +// info!("Received SIGTERM signal"); +// ShutdownSignal::Sigterm +// } +// } +// } +// #[allow(dead_code)] +// #[derive(Debug)] +// enum ServiceState { +// Starting, +// Ready, +// Stopping, +// Stopped, +// } +// #[allow(dead_code)] +// fn notify_service_state(state: ServiceState) { +// match state { +// ServiceState::Starting => { +// info!("Service is starting..."); +// #[cfg(target_os = "linux")] +// if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...")]) { +// error!("Failed to notify systemd of starting state: {}", e); +// } +// } +// ServiceState::Ready => { +// info!("Service is ready"); +// notify_systemd("ready"); +// } +// ServiceState::Stopping => { +// info!("Service is stopping..."); +// notify_systemd("stopping"); +// } +// ServiceState::Stopped => { +// info!("Service has stopped"); +// #[cfg(target_os = "linux")] +// if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped")]) { +// error!("Failed to notify systemd of stopped state: {}", e); +// } +// } +// } +// } From f5a97b63b9512daddb97ee7527c47c53636af784 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 10 Apr 2025 11:49:44 +0800 Subject: [PATCH 085/103] chore(ci): optimize build workflow and update protoc version - Update protoc version from 27.0 to 30.2 for better compatibility - Improve build workflow parameters handling --- .github/actions/setup/action.yml | 2 +- .github/workflows/build.yml | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index c7b62a004..f74dc6fbe 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -24,7 +24,7 @@ runs: - uses: arduino/setup-protoc@v3 with: - version: "27.0" + version: "30.2" - uses: Nugine/setup-flatc@v1 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30717df32..01e49f6c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,10 +16,10 @@ jobs: strategy: matrix: variant: - - { profile: dev, target: x86_64-unknown-linux-musl, glibc: "default" } + # - { profile: dev, target: x86_64-unknown-linux-musl, glibc: "default" } - { profile: release, target: x86_64-unknown-linux-musl, glibc: "default" } - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "default" } - - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "2.31" } + # - { profile: release, target: x86_64-unknown-linux-gnu, glibc: "2.31" } steps: - uses: actions/checkout@v4 @@ -102,20 +102,22 @@ jobs: ls -R unzip -o -j "rustfs-${{ matrix.variant.profile }}-${{ matrix.variant.target }}.zip" -d ./cli/rustfs-gui/embedded-rustfs/ ls -la cli/rustfs-gui/embedded-rustfs - - name: Cache dioxus-cli - uses: actions/cache@v4 + # - name: Cache dioxus-cli + # uses: actions/cache@v4 + # with: + # path: ~/.cargo/bin/dx + # key: ${{ runner.os }}-dioxus-cli-${{ hashFiles('**/Cargo.lock') }} + # restore-keys: | + # ${{ runner.os }}-dioxus-cli- + # + # - name: Install dioxus-cli + # run: | + # if [ ! -f ~/.cargo/bin/dx ]; then + # cargo install dioxus-cli + # fi + - uses: taiki-e/cache-cargo-install-action@v2 with: - path: ~/.cargo/bin/dx - key: ${{ runner.os }}-dioxus-cli-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-dioxus-cli- - - - name: Install dioxus-cli - run: | - if [ ! -f ~/.cargo/bin/dx ]; then - cargo install dioxus-cli - fi - + tool: dioxus-cli - name: Build and Bundle rustfs-gui run: | ls -la From 6a4fffaae793d2cb7aed6f2f69a037bf86167a67 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 10 Apr 2025 18:57:48 +0800 Subject: [PATCH 086/103] improve systemd relation config --- .gitignore | 4 +-- deploy/README.md | 35 +++++++++++++++++++ .../build/rustfs-zh.service | 19 +++++----- .../build/rustfs.run-zh.md | 0 rustfs.run.md => deploy/build/rustfs.run.md | 0 rustfs.service => deploy/build/rustfs.service | 13 +++---- {config => deploy}/certs/README.md | 0 deploy/config/obs-zh.example.toml | 33 +++++++++++++++++ {config => deploy/config}/obs.example.toml | 0 deploy/config/rustfs-zh.env | 26 ++++++++++++++ deploy/config/rustfs.env | 26 ++++++++++++++ deploy/data/README.md | 1 + deploy/logs/README.md | 1 + rustfs/README.md | 30 ++++++++++++++++ rustfs/src/{utils.rs => utils/mod.rs} | 0 15 files changed, 170 insertions(+), 18 deletions(-) create mode 100644 deploy/README.md rename rustfs-zh.service => deploy/build/rustfs-zh.service (95%) rename rustfs.run-zh.md => deploy/build/rustfs.run-zh.md (100%) rename rustfs.run.md => deploy/build/rustfs.run.md (100%) rename rustfs.service => deploy/build/rustfs.service (81%) rename {config => deploy}/certs/README.md (100%) create mode 100644 deploy/config/obs-zh.example.toml rename {config => deploy/config}/obs.example.toml (100%) create mode 100644 deploy/config/rustfs-zh.env create mode 100644 deploy/config/rustfs.env create mode 100644 deploy/data/README.md create mode 100644 deploy/logs/README.md create mode 100644 rustfs/README.md rename rustfs/src/{utils.rs => utils/mod.rs} (100%) diff --git a/.gitignore b/.gitignore index 8513695bf..9b8266092 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,6 @@ rustfs/static/* vendor cli/rustfs-gui/embedded-rustfs/rustfs -config/obs.toml +deploy/config/obs.toml *.log -config/certs/* +deploy/certs/* diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 000000000..4d3d4476a --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,35 @@ +# RustFS Deploy + +This directory contains the deployment scripts and configurations for the project. +The deployment process is divided into two main parts: the RustFS binary and the RustFS console. The RustFS binary is +responsible for the core functionality of the system, while the RustFS console provides a web-based interface for +managing and monitoring the system. + +# Directory Structure + +```text +|--data // data directory +| |--vol1 // volume 1 not created +| |--vol2 // volume 2 not created +| |--vol3 // volume 3 not created +| |--vol4 // volume 4 not created +| |--README.md // data directory readme +|--logs // log directory +| |--rustfs.log // RustFS log +| |--README.md // logs directory readme +|--build +| |--rustfs.run.md // deployment script for RustFS +| |--rustfs.run-zh.md // deployment script for RustFS in Chinese +| |--rustfs.service // systemd service file +| |--rustfs-zh.service.md // systemd service file in Chinese +|--certs +| |--README.md // certs readme +| |--rustfs_tls_cert.pem // API cert.pem +| |--rustfs_tls_key.pem // API key.pem +| |--rustfs_console_tls_cert.pem // console cert.pem +| |--rustfs_console_tls_key.pem // console key.pem +|--config +| |--obs.example.yaml // example config +| |--rustfs.env // env config +| |--rustfs-zh.env // env config in Chinese +``` \ No newline at end of file diff --git a/rustfs-zh.service b/deploy/build/rustfs-zh.service similarity index 95% rename from rustfs-zh.service rename to deploy/build/rustfs-zh.service index 2541ec77c..a2bc1a41d 100644 --- a/rustfs-zh.service +++ b/deploy/build/rustfs-zh.service @@ -24,20 +24,15 @@ User=rustfs Group=rustfs # 以 rustfs 组身份运行服务,与 User 配合使用。 -# environment variable configuration -# 定义环境变量配置,用于传递给服务程序。 -Environment=RUST_LOG=info -# 设置日志级别为 info,控制服务日志输出(需服务支持此变量)。 -Environment=RUSTFS_ACCESS_KEY=rustfsadmin -# 设置访问密钥为 rustfsadmin,用于 RustFS 的认证。 -Environment=RUSTFS_SECRET_KEY=rustfsadmin -# 设置秘密密钥为 rustfsadmin,与访问密钥配套使用。 - # working directory WorkingDirectory=/opt/rustfs # 设置服务的工作目录为 /opt/rustfs,影响相对路径的解析。 -# main program +# 定义环境变量配置,用于传递给服务程序。 +Environment=RUSTFS_ACCESS_KEY=rustfsadmin +# 设置访问密钥为 rustfsadmin,用于 RustFS 的认证。 +Environment=RUSTFS_SECRET_KEY=rustfsadmin +# 设置秘密密钥为 rustfsadmin,与访问密钥配套使用。 ExecStart=/usr/local/bin/rustfs \ --address 0.0.0.0:9000 \ --volumes /data/rustfs/vol1,/data/rustfs/vol2 \ @@ -51,6 +46,10 @@ ExecStart=/usr/local/bin/rustfs \ # --console-enable:启用控制台功能。 # --console-address 0.0.0.0:9002:控制台监听所有接口的 9002 端口。 +# 定义环境变量配置,用于传递给服务程序,推荐使用且简洁 +EnvironmentFile=-/etc/default/rustfs +ExecStart=/usr/local/bin/rustfs $RUSTFS_VOLUMES $RUSTFS_OPTS + # resource constraints LimitNOFILE=1048576 # 设置文件描述符上限为 1048576,支持高并发连接。 diff --git a/rustfs.run-zh.md b/deploy/build/rustfs.run-zh.md similarity index 100% rename from rustfs.run-zh.md rename to deploy/build/rustfs.run-zh.md diff --git a/rustfs.run.md b/deploy/build/rustfs.run.md similarity index 100% rename from rustfs.run.md rename to deploy/build/rustfs.run.md diff --git a/rustfs.service b/deploy/build/rustfs.service similarity index 81% rename from rustfs.service rename to deploy/build/rustfs.service index 53db8a64a..e8c82de4c 100644 --- a/rustfs.service +++ b/deploy/build/rustfs.service @@ -13,15 +13,12 @@ NotifyAccess=main User=rustfs Group=rustfs -# environment variable configuration -Environment=RUST_LOG=info -Environment=RUSTFS_ACCESS_KEY=rustfsadmin -Environment=RUSTFS_SECRET_KEY=rustfsadmin - # working directory WorkingDirectory=/opt/rustfs -# main program +# environment variable configuration and main program (Option 1: Directly specify arguments) +Environment=RUSTFS_ACCESS_KEY=rustfsadmin +Environment=RUSTFS_SECRET_KEY=rustfsadmin ExecStart=/usr/local/bin/rustfs \ --address 0.0.0.0:9000 \ --volumes /data/rustfs/vol1,/data/rustfs/vol2 \ @@ -29,6 +26,10 @@ ExecStart=/usr/local/bin/rustfs \ --console-enable \ --console-address 0.0.0.0:9002 +# environment variable configuration (Option 2: Use environment variables) +EnvironmentFile=-/etc/default/rustfs +ExecStart=/usr/local/bin/rustfs $RUSTFS_VOLUMES $RUSTFS_OPTS + # resource constraints LimitNOFILE=1048576 LimitNPROC=32768 diff --git a/config/certs/README.md b/deploy/certs/README.md similarity index 100% rename from config/certs/README.md rename to deploy/certs/README.md diff --git a/deploy/config/obs-zh.example.toml b/deploy/config/obs-zh.example.toml new file mode 100644 index 000000000..c3cbe8f60 --- /dev/null +++ b/deploy/config/obs-zh.example.toml @@ -0,0 +1,33 @@ +[observability] +endpoint = "http://localhost:4317" # 可观测性数据上报的终端地址,默认为"http://localhost:4317" +use_stdout = true # 是否将日志输出到标准输出 +sample_ratio = 2.0 # 采样率,表示每 2 条数据采样 1 条 +meter_interval = 30 # 指标收集间隔,单位为秒 +service_name = "rustfs" # 服务名称,用于标识当前服务 +service_version = "0.1.0" # 服务版本号 +environments = "develop" # 运行环境,如开发环境 (develop) +logger_level = "debug" # 日志级别,可选 debug/info/warn/error 等 + +[sinks] +[sinks.kafka] # Kafka 接收器配置 +enabled = false # 是否启用 Kafka 接收器,默认禁用 +bootstrap_servers = "localhost:9092" # Kafka 服务器地址 +topic = "logs" # Kafka 主题名称 +batch_size = 100 # 批处理大小,每次发送的消息数量 +batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 + +[sinks.webhook] # Webhook 接收器配置 +enabled = false # 是否启用 Webhook 接收器 +endpoint = "http://localhost:8080/webhook" # Webhook 接收地址 +auth_token = "" # 认证令牌 +batch_size = 100 # 批处理大小 +batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 + +[sinks.file] # 文件接收器配置 +enabled = true # 是否启用文件接收器 +path = "/Users/qun/Documents/rust/rustfs/s3-rustfs/logs/app.log" # 日志文件路径 +batch_size = 10 # 批处理大小 +batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 + +[logger] # 日志器配置 +queue_capacity = 10 # 日志队列容量,表示可以缓存的日志条数 \ No newline at end of file diff --git a/config/obs.example.toml b/deploy/config/obs.example.toml similarity index 100% rename from config/obs.example.toml rename to deploy/config/obs.example.toml diff --git a/deploy/config/rustfs-zh.env b/deploy/config/rustfs-zh.env new file mode 100644 index 000000000..b9700adb8 --- /dev/null +++ b/deploy/config/rustfs-zh.env @@ -0,0 +1,26 @@ +# RustFS 管理员用户名 +RUSTFS_ROOT_USER=rustfsadmin +# RustFS 管理员密码 +RUSTFS_ROOT_PASSWORD=rustfsadmin + +# 数据卷配置示例路径:deploy/data/rustfs.env +# RustFS 数据卷存储路径,支持多卷配置,vol1 到 vol4 +RUSTFS_VOLUMES="./deploy/deploy/vol{1...4}" +# RustFS 服务启动参数,指定监听地址和端口 +RUSTFS_OPTS="--address 0.0.0.0:9000" +# RustFS 服务监听地址和端口 +RUSTFS_ADDRESS="0.0.0.0:9000" +# 是否启用 RustFS 控制台功能 +RUSTFS_CONSOLE_ENABLE=true +# RustFS 控制台监听地址和端口 +RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" +# RustFS 服务端点地址,用于客户端访问 +RUSTFS_SERVER_ENDPOINT="http://127.0.0.1:9000" +# RustFS 服务域名配置 +RUSTFS_SERVER_DOMAINS=127.0.0.1:9002 +# RustFS 许可证内容 +RUSTFS_LICENSE="license content" +# 可观测性配置文件路径:deploy/config/obs.example.toml +RUSTFS_OBS_CONFIG=/etc/default/obs.toml +# TLS 证书目录路径:deploy/certs +RUSTFS_TLS_PATH=/etc/default/tls \ No newline at end of file diff --git a/deploy/config/rustfs.env b/deploy/config/rustfs.env new file mode 100644 index 000000000..ec7d31b48 --- /dev/null +++ b/deploy/config/rustfs.env @@ -0,0 +1,26 @@ +# RustFS administrator username +RUSTFS_ROOT_USER=rustfsadmin +# RustFS administrator password +RUSTFS_ROOT_PASSWORD=rustfsadmin + +# Data volume configuration example path: deploy/data/rustfs.env +# RustFS data volume storage paths, supports multiple volumes from vol1 to vol4 +RUSTFS_VOLUMES="./deploy/deploy/vol{1...4}" +# RustFS service startup parameters, specifying listen address and port +RUSTFS_OPTS="--address 0.0.0.0:9000" +# RustFS service listen address and port +RUSTFS_ADDRESS="0.0.0.0:9000" +# Enable RustFS console functionality +RUSTFS_CONSOLE_ENABLE=true +# RustFS console listen address and port +RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" +# RustFS service endpoint for client access +RUSTFS_SERVER_ENDPOINT="http://127.0.0.1:9000" +# RustFS service domain configuration +RUSTFS_SERVER_DOMAINS=127.0.0.1:9002 +# RustFS license content +RUSTFS_LICENSE="license content" +# Observability configuration file path: deploy/config/obs.example.toml +RUSTFS_OBS_CONFIG=/etc/default/obs.toml +# TLS certificates directory path: deploy/certs +RUSTFS_TLS_PATH=/etc/default/tls \ No newline at end of file diff --git a/deploy/data/README.md b/deploy/data/README.md new file mode 100644 index 000000000..ac7023e57 --- /dev/null +++ b/deploy/data/README.md @@ -0,0 +1 @@ +# Data Volumes \ No newline at end of file diff --git a/deploy/logs/README.md b/deploy/logs/README.md new file mode 100644 index 000000000..b2c0294c2 --- /dev/null +++ b/deploy/logs/README.md @@ -0,0 +1 @@ +# RustFS Logs \ No newline at end of file diff --git a/rustfs/README.md b/rustfs/README.md new file mode 100644 index 000000000..86b2ab767 --- /dev/null +++ b/rustfs/README.md @@ -0,0 +1,30 @@ +rustfs/ +├── Cargo.toml +├── src/ +│ ├── main.rs # 主入口 +│ ├── admin/ +│ │ └── mod.rs # 管理接口 +│ ├── auth/ +│ │ └── mod.rs # 认证模块 +│ ├── config/ +│ │ ├── mod.rs # 配置模块 +│ │ └── options.rs # 命令行参数 +│ ├── console/ +│ │ ├── mod.rs # 控制台模块 +│ │ └── server.rs # 控制台服务器 +│ ├── grpc/ +│ │ └── mod.rs # gRPC 服务 +│ ├── license/ +│ │ └── mod.rs # 许可证管理 +│ ├── logging/ +│ │ └── mod.rs # 日志管理 +│ ├── server/ +│ │ ├── mod.rs # 服务器实现 +│ │ ├── connection.rs # 连接处理 +│ │ ├── service.rs # 服务实现 +│ │ └── state.rs # 状态管理 +│ ├── storage/ +│ │ ├── mod.rs # 存储模块 +│ │ └── fs.rs # 文件系统实现 +│ └── utils/ +│ └── mod.rs # 工具函数 \ No newline at end of file diff --git a/rustfs/src/utils.rs b/rustfs/src/utils/mod.rs similarity index 100% rename from rustfs/src/utils.rs rename to rustfs/src/utils/mod.rs From 0c435c6a05924bcd8f997004431d6b27e447ac8e Mon Sep 17 00:00:00 2001 From: weisd Date: Thu, 10 Apr 2025 14:57:54 +0800 Subject: [PATCH 087/103] add admin policy check for user operation --- Cargo.lock | 1 + ecstore/src/config/storageclass.rs | 8 +- ecstore/src/disk/local.rs | 9 +- ecstore/src/heal/heal_ops.rs | 5 +- ecstore/src/peer.rs | 7 +- ecstore/src/set_disk.rs | 15 +- ecstore/src/store_list_objects.rs | 12 +- iam/src/store/object.rs | 8 +- iam/src/sys.rs | 12 + madmin/Cargo.toml | 1 + madmin/src/user.rs | 40 +++ policy/src/policy/action.rs | 237 +++++++++++++++++- policy/src/policy/policy.rs | 4 +- rustfs/Cargo.toml | 15 +- rustfs/src/admin/handlers.rs | 224 ++++++++++++++--- .../admin/handlers/{policy.rs => policys.rs} | 3 +- rustfs/src/admin/handlers/service_account.rs | 159 ++++++++++-- rustfs/src/admin/handlers/user.rs | 71 ++++-- rustfs/src/admin/mod.rs | 13 +- 19 files changed, 699 insertions(+), 145 deletions(-) rename rustfs/src/admin/handlers/{policy.rs => policys.rs} (99%) diff --git a/Cargo.lock b/Cargo.lock index 68b1892ce..60bd0acbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4862,6 +4862,7 @@ dependencies = [ "common", "humantime", "hyper", + "s3s", "serde", "serde_json", "time", diff --git a/ecstore/src/config/storageclass.rs b/ecstore/src/config/storageclass.rs index 3859fcb5e..edb2095f9 100644 --- a/ecstore/src/config/storageclass.rs +++ b/ecstore/src/config/storageclass.rs @@ -189,13 +189,7 @@ pub fn lookup_config(kvs: &KVS, set_drive_count: usize) -> Result { validate_parity_inner(standard.parity, rrs.parity, set_drive_count)?; - let optimize = { - if let Ok(ev) = env::var(OPTIMIZE_ENV) { - Some(ev) - } else { - None - } - }; + let optimize = { env::var(OPTIMIZE_ENV).ok() }; let inline_block = { if let Ok(ev) = env::var(INLINE_BLOCK_ENV) { diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index e07cf989e..93681d91f 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -1232,7 +1232,7 @@ impl DiskAPI for LocalDisk { .join(path) .join(fi.data_dir.map_or("".to_string(), |dir| dir.to_string())) .join(format!("part.{}", part.number)); - let err = match self + let err = (self .bitrot_verify( &part_path, erasure.shard_file_size(part.size), @@ -1240,11 +1240,8 @@ impl DiskAPI for LocalDisk { &checksum_info.hash, erasure.shard_size(erasure.block_size), ) - .await - { - Ok(_) => None, - Err(err) => Some(err), - }; + .await) + .err(); resp.results[i] = conv_part_err_to_int(&err); if resp.results[i] == CHECK_PART_UNKNOWN { if let Some(err) = err { diff --git a/ecstore/src/heal/heal_ops.rs b/ecstore/src/heal/heal_ops.rs index d5c4544f3..6f4614578 100644 --- a/ecstore/src/heal/heal_ops.rs +++ b/ecstore/src/heal/heal_ops.rs @@ -406,10 +406,7 @@ impl HealSequence { async fn traverse_and_heal(h: Arc) { let buckets_only = false; - let result = match Self::heal_items(h.clone(), buckets_only).await { - Ok(_) => None, - Err(err) => Some(err), - }; + let result = (Self::heal_items(h.clone(), buckets_only).await).err(); let _ = h.traverse_and_heal_done_tx.read().await.send(result).await; } diff --git a/ecstore/src/peer.rs b/ecstore/src/peer.rs index 5328cbc9b..f352121f9 100644 --- a/ecstore/src/peer.rs +++ b/ecstore/src/peer.rs @@ -80,12 +80,7 @@ impl S3PeerSys { let mut futures = Vec::with_capacity(self.clients.len()); for client in self.clients.iter() { // client_clon - futures.push(async move { - match client.get_bucket_info(bucket, &BucketOptions::default()).await { - Ok(_) => None, - Err(err) => Some(err), - } - }); + futures.push(async move { (client.get_bucket_info(bucket, &BucketOptions::default()).await).err() }); } let errs = join_all(futures).await; diff --git a/ecstore/src/set_disk.rs b/ecstore/src/set_disk.rs index 754681fe6..04b3254a4 100644 --- a/ecstore/src/set_disk.rs +++ b/ecstore/src/set_disk.rs @@ -1230,7 +1230,7 @@ impl SetDisks { let shallow_versions: Vec> = metadata_shallow_versions.iter().flatten().cloned().collect(); - let read_quorum = (fileinfos.len() + 1) / 2; + let read_quorum = fileinfos.len().div_ceil(2); let versions = merge_file_meta_versions(read_quorum, false, 1, &shallow_versions); let meta = FileMeta { versions, @@ -5085,7 +5085,7 @@ fn is_object_dang_ling( }); if !valid_meta.is_valid() { - let data_blocks = (meta_arr.len() + 1) / 2; + let data_blocks = meta_arr.len().div_ceil(2); if not_found_parts_errs > data_blocks { return Ok(valid_meta); } @@ -5098,7 +5098,7 @@ fn is_object_dang_ling( } if valid_meta.deleted { - let data_blocks = (errs.len() + 1) / 2; + let data_blocks = errs.len().div_ceil(2); if not_found_meta_errs > data_blocks { return Ok(valid_meta); } @@ -5313,7 +5313,7 @@ async fn disks_with_all_parts( if let Some(data) = &meta.data { let checksum_info = meta.erasure.get_checksum_info(meta.parts[0].number); let data_len = data.len(); - let verify_err = match bitrot_verify( + let verify_err = (bitrot_verify( Box::new(Cursor::new(data.clone())), data_len, meta.erasure.shard_file_size(meta.size), @@ -5321,11 +5321,8 @@ async fn disks_with_all_parts( checksum_info.hash, meta.erasure.shard_size(meta.erasure.block_size), ) - .await - { - Ok(_) => None, - Err(err) => Some(err), - }; + .await) + .err(); if let Some(vec) = data_errs_by_part.get_mut(&0) { if index < vec.len() { diff --git a/ecstore/src/store_list_objects.rs b/ecstore/src/store_list_objects.rs index 08c671e77..8b9118de3 100644 --- a/ecstore/src/store_list_objects.rs +++ b/ecstore/src/store_list_objects.rs @@ -698,7 +698,7 @@ impl ECStore { futures.push(async move { let mut ask_disks = get_list_quorum(&opts.ask_disks, set.set_drive_count as i32); if ask_disks == -1 { - let new_disks = get_quorum_disks(&disks, &infos, (disks.len() + 1) / 2); + let new_disks = get_quorum_disks(&disks, &infos, disks.len().div_ceil(2)); if !new_disks.is_empty() { disks = new_disks; } else { @@ -1156,13 +1156,7 @@ async fn merge_entry_channels( if let Some(entry) = &best { let mut versions = Vec::with_capacity(to_merge.len() + 1); - let mut has_xl = { - if let Ok(meta) = entry.clone().xl_meta() { - Some(meta) - } else { - None - } - }; + let mut has_xl = { entry.clone().xl_meta().ok() }; if let Some(x) = &has_xl { versions.push(x.versions.clone()); @@ -1229,7 +1223,7 @@ impl SetDisks { let mut ask_disks = get_list_quorum(&opts.ask_disks, self.set_drive_count as i32); if ask_disks == -1 { - let new_disks = get_quorum_disks(&disks, &infos, (disks.len() + 1) / 2); + let new_disks = get_quorum_disks(&disks, &infos, disks.len().div_ceil(2)); if !new_disks.is_empty() { disks = new_disks; ask_disks = 1; diff --git a/iam/src/store/object.rs b/iam/src/store/object.rs index cf365f562..94c56fb07 100644 --- a/iam/src/store/object.rs +++ b/iam/src/store/object.rs @@ -675,11 +675,11 @@ impl Store for ObjectStore { async fn load_all(&self, cache: &Cache) -> Result<()> { let listed_config_items = self.list_all_iamconfig_items().await?; + let mut policy_docs_cache = CacheEntity::new(get_default_policyes()); + if let Some(policies_list) = listed_config_items.get(POLICIES_LIST_KEY) { let mut policies_list = policies_list.clone(); - let mut policy_docs_cache = CacheEntity::new(get_default_policyes()); - loop { if policies_list.len() < 32 { let policy_docs = self.load_policy_doc_concurrent(&policies_list).await?; @@ -712,10 +712,10 @@ impl Store for ObjectStore { policies_list = policies_list.split_off(32); } - - cache.policy_docs.store(Arc::new(policy_docs_cache.update_load_time())); } + cache.policy_docs.store(Arc::new(policy_docs_cache.update_load_time())); + let mut user_items_cache = CacheEntity::default(); // users diff --git a/iam/src/sys.rs b/iam/src/sys.rs index ee2a26b61..175dae6bc 100644 --- a/iam/src/sys.rs +++ b/iam/src/sys.rs @@ -121,6 +121,18 @@ impl IamSys { // TODO: notification } + pub async fn get_role_policy(&self, arn_str: &str) -> Result<(ARN, String)> { + let Some(arn) = ARN::parse(arn_str).ok() else { + return Err(Error::msg("Invalid ARN")); + }; + + let Some(policy) = self.roles_map.get(&arn) else { + return Err(Error::msg("No such role")); + }; + + Ok((arn, policy.clone())) + } + pub async fn delete_user(&self, name: &str, _notify: bool) -> Result<()> { self.store.delete_user(name, UserType::Reg).await // TODO: notification diff --git a/madmin/Cargo.toml b/madmin/Cargo.toml index 8977a66ad..18bea2bae 100644 --- a/madmin/Cargo.toml +++ b/madmin/Cargo.toml @@ -18,3 +18,4 @@ serde.workspace = true serde_json.workspace = true time.workspace = true tracing.workspace = true +s3s.workspace = true diff --git a/madmin/src/user.rs b/madmin/src/user.rs index 3a398c51f..a13fa1710 100644 --- a/madmin/src/user.rs +++ b/madmin/src/user.rs @@ -1,6 +1,9 @@ use serde::{Deserialize, Serialize}; +use std::collections::HashMap; use time::OffsetDateTime; +use crate::BackendInfo; + #[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq)] pub enum AccountStatus { #[serde(rename = "enabled")] @@ -221,3 +224,40 @@ impl UpdateServiceAccountReq { Ok(()) } } + +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct AccountInfo { + pub account_name: String, + pub server: BackendInfo, + pub policy: serde_json::Value, // Use iam/policy::parse to parse the result, to be done by the caller. + pub buckets: Vec, +} + +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct BucketAccessInfo { + pub name: String, + pub size: u64, + pub objects: u64, + pub object_sizes_histogram: HashMap, + pub object_versions_histogram: HashMap, + pub details: Option, + pub prefix_usage: HashMap, + #[serde(rename = "expiration", with = "time::serde::rfc3339::option")] + pub created: Option, + pub access: AccountAccess, +} + +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct BucketDetails { + pub versioning: bool, + pub versioning_suspended: bool, + pub locking: bool, + pub replication: bool, + // pub tagging: Option, +} + +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct AccountAccess { + pub read: bool, + pub write: bool, +} diff --git a/policy/src/policy/action.rs b/policy/src/policy/action.rs index e152e89b7..b9df63b6c 100644 --- a/policy/src/policy/action.rs +++ b/policy/src/policy/action.rs @@ -54,6 +54,7 @@ pub enum Action { AdminAction(AdminAction), StsAction(StsAction), KmsAction(KmsAction), + None, } impl Action { @@ -69,6 +70,7 @@ impl From<&Action> for &str { Action::AdminAction(s) => s.into(), Action::StsAction(s) => s.into(), Action::KmsAction(s) => s.into(), + Action::None => "", } } } @@ -232,35 +234,254 @@ pub enum S3Action { PutObjectFanOutAction, } +// #[derive(Serialize, Deserialize, Hash, PartialEq, Eq, Clone, EnumString, IntoStaticStr, Debug, Copy)] +// #[serde(try_from = "&str", into = "&str")] +// pub enum AdminAction { +// #[strum(serialize = "admin:*")] +// AllActions, +// #[strum(serialize = "admin:Profiling")] +// ProfilingAdminAction, +// #[strum(serialize = "admin:ServerTrace")] +// TraceAdminAction, +// #[strum(serialize = "admin:ConsoleLog")] +// ConsoleLogAdminAction, +// #[strum(serialize = "admin:ServerInfo")] +// ServerInfoAdminAction, +// #[strum(serialize = "admin:OBDInfo")] +// HealthInfoAdminAction, +// #[strum(serialize = "admin:TopLocksInfo")] +// TopLocksAdminAction, +// #[strum(serialize = "admin:LicenseInfo")] +// LicenseInfoAdminAction, +// #[strum(serialize = "admin:BandwidthMonitor")] +// BandwidthMonitorAction, +// #[strum(serialize = "admin:InspectData")] +// InspectDataAction, +// #[strum(serialize = "admin:Prometheus")] +// PrometheusAdminAction, +// #[strum(serialize = "admin:ListServiceAccounts")] +// ListServiceAccountsAdminAction, +// #[strum(serialize = "admin:CreateServiceAccount")] +// CreateServiceAccountAdminAction, +// } + +// AdminAction - admin policy action. #[derive(Serialize, Deserialize, Hash, PartialEq, Eq, Clone, EnumString, IntoStaticStr, Debug, Copy)] #[serde(try_from = "&str", into = "&str")] pub enum AdminAction { - #[strum(serialize = "admin:*")] - AllActions, + #[strum(serialize = "admin:Heal")] + HealAdminAction, + #[strum(serialize = "admin:Decommission")] + DecommissionAdminAction, + #[strum(serialize = "admin:Rebalance")] + RebalanceAdminAction, + #[strum(serialize = "admin:StorageInfo")] + StorageInfoAdminAction, + #[strum(serialize = "admin:Prometheus")] + PrometheusAdminAction, + #[strum(serialize = "admin:DataUsageInfo")] + DataUsageInfoAdminAction, + #[strum(serialize = "admin:ForceUnlock")] + ForceUnlockAdminAction, + #[strum(serialize = "admin:TopLocksInfo")] + TopLocksAdminAction, #[strum(serialize = "admin:Profiling")] ProfilingAdminAction, #[strum(serialize = "admin:ServerTrace")] TraceAdminAction, #[strum(serialize = "admin:ConsoleLog")] ConsoleLogAdminAction, + #[strum(serialize = "admin:KMSCreateKey")] + KMSCreateKeyAdminAction, + #[strum(serialize = "admin:KMSKeyStatus")] + KMSKeyStatusAdminAction, #[strum(serialize = "admin:ServerInfo")] ServerInfoAdminAction, #[strum(serialize = "admin:OBDInfo")] HealthInfoAdminAction, - #[strum(serialize = "admin:TopLocksInfo")] - TopLocksAdminAction, #[strum(serialize = "admin:LicenseInfo")] LicenseInfoAdminAction, #[strum(serialize = "admin:BandwidthMonitor")] BandwidthMonitorAction, #[strum(serialize = "admin:InspectData")] InspectDataAction, - #[strum(serialize = "admin:Prometheus")] - PrometheusAdminAction, - #[strum(serialize = "admin:ListServiceAccounts")] - ListServiceAccountsAdminAction, + #[strum(serialize = "admin:ServerUpdate")] + ServerUpdateAdminAction, + #[strum(serialize = "admin:ServiceRestart")] + ServiceRestartAdminAction, + #[strum(serialize = "admin:ServiceStop")] + ServiceStopAdminAction, + #[strum(serialize = "admin:ServiceFreeze")] + ServiceFreezeAdminAction, + #[strum(serialize = "admin:ConfigUpdate")] + ConfigUpdateAdminAction, + #[strum(serialize = "admin:CreateUser")] + CreateUserAdminAction, + #[strum(serialize = "admin:DeleteUser")] + DeleteUserAdminAction, + #[strum(serialize = "admin:ListUsers")] + ListUsersAdminAction, + #[strum(serialize = "admin:EnableUser")] + EnableUserAdminAction, + #[strum(serialize = "admin:DisableUser")] + DisableUserAdminAction, + #[strum(serialize = "admin:GetUser")] + GetUserAdminAction, + #[strum(serialize = "admin:SiteReplicationAdd")] + SiteReplicationAddAction, + #[strum(serialize = "admin:SiteReplicationDisable")] + SiteReplicationDisableAction, + #[strum(serialize = "admin:SiteReplicationRemove")] + SiteReplicationRemoveAction, + #[strum(serialize = "admin:SiteReplicationResync")] + SiteReplicationResyncAction, + #[strum(serialize = "admin:SiteReplicationInfo")] + SiteReplicationInfoAction, + #[strum(serialize = "admin:SiteReplicationOperation")] + SiteReplicationOperationAction, #[strum(serialize = "admin:CreateServiceAccount")] CreateServiceAccountAdminAction, + #[strum(serialize = "admin:UpdateServiceAccount")] + UpdateServiceAccountAdminAction, + #[strum(serialize = "admin:RemoveServiceAccount")] + RemoveServiceAccountAdminAction, + #[strum(serialize = "admin:ListServiceAccounts")] + ListServiceAccountsAdminAction, + #[strum(serialize = "admin:ListTemporaryAccounts")] + ListTemporaryAccountsAdminAction, + #[strum(serialize = "admin:AddUserToGroup")] + AddUserToGroupAdminAction, + #[strum(serialize = "admin:RemoveUserFromGroup")] + RemoveUserFromGroupAdminAction, + #[strum(serialize = "admin:GetGroup")] + GetGroupAdminAction, + #[strum(serialize = "admin:ListGroups")] + ListGroupsAdminAction, + #[strum(serialize = "admin:EnableGroup")] + EnableGroupAdminAction, + #[strum(serialize = "admin:DisableGroup")] + DisableGroupAdminAction, + #[strum(serialize = "admin:CreatePolicy")] + CreatePolicyAdminAction, + #[strum(serialize = "admin:DeletePolicy")] + DeletePolicyAdminAction, + #[strum(serialize = "admin:GetPolicy")] + GetPolicyAdminAction, + #[strum(serialize = "admin:AttachUserOrGroupPolicy")] + AttachPolicyAdminAction, + #[strum(serialize = "admin:UpdatePolicyAssociation")] + UpdatePolicyAssociationAction, + #[strum(serialize = "admin:ListUserPolicies")] + ListUserPoliciesAdminAction, + #[strum(serialize = "admin:SetBucketQuota")] + SetBucketQuotaAdminAction, + #[strum(serialize = "admin:GetBucketQuota")] + GetBucketQuotaAdminAction, + #[strum(serialize = "admin:SetBucketTarget")] + SetBucketTargetAction, + #[strum(serialize = "admin:GetBucketTarget")] + GetBucketTargetAction, + #[strum(serialize = "admin:ReplicationDiff")] + ReplicationDiff, + #[strum(serialize = "admin:ImportBucketMetadata")] + ImportBucketMetadataAction, + #[strum(serialize = "admin:ExportBucketMetadata")] + ExportBucketMetadataAction, + #[strum(serialize = "admin:SetTier")] + SetTierAction, + #[strum(serialize = "admin:ListTier")] + ListTierAction, + #[strum(serialize = "admin:ExportIAM")] + ExportIAMAction, + #[strum(serialize = "admin:ImportIAM")] + ImportIAMAction, + #[strum(serialize = "admin:ListBatchJobs")] + ListBatchJobsAction, + #[strum(serialize = "admin:DescribeBatchJob")] + DescribeBatchJobAction, + #[strum(serialize = "admin:StartBatchJob")] + StartBatchJobAction, + #[strum(serialize = "admin:CancelBatchJob")] + CancelBatchJobAction, + #[strum(serialize = "admin:*")] + AllAdminActions, +} + +impl AdminAction { + // IsValid - checks if action is valid or not. + pub fn is_valid(&self) -> bool { + matches!( + self, + AdminAction::HealAdminAction + | AdminAction::DecommissionAdminAction + | AdminAction::RebalanceAdminAction + | AdminAction::StorageInfoAdminAction + | AdminAction::PrometheusAdminAction + | AdminAction::DataUsageInfoAdminAction + | AdminAction::ForceUnlockAdminAction + | AdminAction::TopLocksAdminAction + | AdminAction::ProfilingAdminAction + | AdminAction::TraceAdminAction + | AdminAction::ConsoleLogAdminAction + | AdminAction::KMSCreateKeyAdminAction + | AdminAction::KMSKeyStatusAdminAction + | AdminAction::ServerInfoAdminAction + | AdminAction::HealthInfoAdminAction + | AdminAction::LicenseInfoAdminAction + | AdminAction::BandwidthMonitorAction + | AdminAction::InspectDataAction + | AdminAction::ServerUpdateAdminAction + | AdminAction::ServiceRestartAdminAction + | AdminAction::ServiceStopAdminAction + | AdminAction::ServiceFreezeAdminAction + | AdminAction::ConfigUpdateAdminAction + | AdminAction::CreateUserAdminAction + | AdminAction::DeleteUserAdminAction + | AdminAction::ListUsersAdminAction + | AdminAction::EnableUserAdminAction + | AdminAction::DisableUserAdminAction + | AdminAction::GetUserAdminAction + | AdminAction::SiteReplicationAddAction + | AdminAction::SiteReplicationDisableAction + | AdminAction::SiteReplicationRemoveAction + | AdminAction::SiteReplicationResyncAction + | AdminAction::SiteReplicationInfoAction + | AdminAction::SiteReplicationOperationAction + | AdminAction::CreateServiceAccountAdminAction + | AdminAction::UpdateServiceAccountAdminAction + | AdminAction::RemoveServiceAccountAdminAction + | AdminAction::ListServiceAccountsAdminAction + | AdminAction::ListTemporaryAccountsAdminAction + | AdminAction::AddUserToGroupAdminAction + | AdminAction::RemoveUserFromGroupAdminAction + | AdminAction::GetGroupAdminAction + | AdminAction::ListGroupsAdminAction + | AdminAction::EnableGroupAdminAction + | AdminAction::DisableGroupAdminAction + | AdminAction::CreatePolicyAdminAction + | AdminAction::DeletePolicyAdminAction + | AdminAction::GetPolicyAdminAction + | AdminAction::AttachPolicyAdminAction + | AdminAction::UpdatePolicyAssociationAction + | AdminAction::ListUserPoliciesAdminAction + | AdminAction::SetBucketQuotaAdminAction + | AdminAction::GetBucketQuotaAdminAction + | AdminAction::SetBucketTargetAction + | AdminAction::GetBucketTargetAction + | AdminAction::ReplicationDiff + | AdminAction::ImportBucketMetadataAction + | AdminAction::ExportBucketMetadataAction + | AdminAction::SetTierAction + | AdminAction::ListTierAction + | AdminAction::ExportIAMAction + | AdminAction::ImportIAMAction + | AdminAction::ListBatchJobsAction + | AdminAction::DescribeBatchJobAction + | AdminAction::StartBatchJobAction + | AdminAction::CancelBatchJobAction + | AdminAction::AllAdminActions + ) + } } #[derive(Serialize, Deserialize, Hash, PartialEq, Eq, Clone, EnumString, IntoStaticStr, Debug, Copy)] diff --git a/policy/src/policy/policy.rs b/policy/src/policy/policy.rs index f1de3790c..b96f66e41 100644 --- a/policy/src/policy/policy.rs +++ b/policy/src/policy/policy.rs @@ -240,7 +240,7 @@ fn get_values_from_claims(claims: &HashMap, claim_name: &str) -> (s, false) } -fn get_policies_from_claims(claims: &HashMap, policy_claim_name: &str) -> (HashSet, bool) { +pub fn get_policies_from_claims(claims: &HashMap, policy_claim_name: &str) -> (HashSet, bool) { get_values_from_claims(claims, policy_claim_name) } @@ -401,7 +401,7 @@ pub mod default { effect: Effect::Allow, actions: ActionSet({ let mut hash_set = HashSet::new(); - hash_set.insert(Action::AdminAction(AdminAction::AllActions)); + hash_set.insert(Action::AdminAction(AdminAction::AllAdminActions)); hash_set }), not_actions: ActionSet(Default::default()), diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 00c10bebd..7d9e743f0 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -43,7 +43,7 @@ http.workspace = true http-body.workspace = true iam = { path = "../iam" } jsonwebtoken = "9.3.0" -libsystemd = { workspace = true, optional = true } + lock.workspace = true local-ip-address = { workspace = true } matchit = { workspace = true } @@ -71,7 +71,12 @@ shadow-rs.workspace = true tracing.workspace = true time = { workspace = true, features = ["parsing", "formatting", "serde"] } tokio-util.workspace = true -tokio = { workspace = true, features = ["rt-multi-thread", "macros", "net", "signal"] } +tokio = { workspace = true, features = [ + "rt-multi-thread", + "macros", + "net", + "signal", +] } tokio-rustls.workspace = true lazy_static.workspace = true tokio-stream.workspace = true @@ -101,7 +106,11 @@ ecstore = { path = "../ecstore" } s3s.workspace = true clap = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter", "time"] } -hyper-util = { workspace = true, features = ["tokio", "server-auto", "server-graceful"] } +hyper-util = { workspace = true, features = [ + "tokio", + "server-auto", + "server-graceful", +] } transform-stream = { workspace = true } netif = "0.1.6" shadow-rs.workspace = true diff --git a/rustfs/src/admin/handlers.rs b/rustfs/src/admin/handlers.rs index 3a53de3c9..4476bbc12 100644 --- a/rustfs/src/admin/handlers.rs +++ b/rustfs/src/admin/handlers.rs @@ -1,12 +1,12 @@ use super::router::Operation; +use crate::auth::check_key_valid; +use crate::auth::get_condition_values; +use crate::auth::get_session_token; use crate::storage::error::to_s3_error; -use ::policy::policy::action::{Action, S3Action}; -use ::policy::policy::resource::Resource; -use ::policy::policy::statement::BPStatement; -use ::policy::policy::{ActionSet, BucketPolicy, Effect, ResourceSet}; use bytes::Bytes; use common::error::Error as ec_Error; use ecstore::admin_server_info::get_server_info; +use ecstore::bucket::versioning_sys::BucketVersioningSys; use ecstore::global::GLOBAL_ALlHealState; use ecstore::heal::data_usage::load_data_usage_from_backend; use ecstore::heal::heal_commands::HealOpts; @@ -15,15 +15,23 @@ use ecstore::metrics_realtime::{collect_local_metrics, CollectMetricsOpts, Metri use ecstore::new_object_layer_fn; use ecstore::peer::is_reserved_or_invalid_bucket; use ecstore::store::is_valid_object_prefix; +use ecstore::store_api::BucketOptions; use ecstore::store_api::StorageAPI; use ecstore::utils::path::path_join; use ecstore::GLOBAL_Endpoints; use futures::{Stream, StreamExt}; use http::{HeaderMap, Uri}; use hyper::StatusCode; +use iam::get_global_action_cred; +use iam::store::MappedPolicy; use madmin::metrics::RealtimeMetrics; use madmin::utils::parse_duration; use matchit::Params; +use policy::policy::action::Action; +use policy::policy::action::S3Action; +use policy::policy::default::DEFAULT_POLICIES; +use policy::policy::Args; +use policy::policy::BucketPolicy; use s3s::header::CONTENT_TYPE; use s3s::stream::{ByteStream, DynByteStream}; use s3s::{s3_error, Body, S3Error, S3Request, S3Response, S3Result}; @@ -43,7 +51,7 @@ use tokio_stream::wrappers::ReceiverStream; use tracing::{error, info, warn}; pub mod group; -pub mod policy; +pub mod policys; pub mod service_account; pub mod sts; pub mod trace; @@ -61,49 +69,187 @@ pub struct AccountInfoHandler {} #[async_trait::async_trait] impl Operation for AccountInfoHandler { async fn call(&self, req: S3Request, _params: Params<'_, '_>) -> S3Result> { - warn!("handle AccountInfoHandler"); - - let Some(cred) = req.credentials else { return Err(s3_error!(InvalidRequest, "get cred failed")) }; - - warn!("AccountInfoHandler cread {:?}", &cred); - let Some(store) = new_object_layer_fn() else { return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string())); }; - // test policy + let Some(input_cred) = req.credentials else { + return Err(s3_error!(InvalidRequest, "get cred failed")); + }; - let mut s3_all_act = HashSet::with_capacity(1); - s3_all_act.insert(Action::S3Action(S3Action::AllActions)); + let (cred, owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; - let mut all_res = HashSet::with_capacity(1); - all_res.insert(Resource::S3("*".to_string())); + let Ok(iam_store) = iam::get() else { return Err(s3_error!(InvalidRequest, "iam not init")) }; - let bucket_policy = BucketPolicy { - id: "".into(), - version: "2012-10-17".to_owned(), - statements: vec![BPStatement { - sid: "".into(), - effect: Effect::Allow, - actions: ActionSet(s3_all_act.clone()), - resources: ResourceSet(all_res), + let default_claims = HashMap::new(); + let claims = cred.claims.as_ref().unwrap_or(&default_claims); + + let cred_clone = cred.clone(); + let conditions = get_condition_values(&req.headers, &cred_clone); + let cred_clone = Arc::new(cred_clone); + let conditions = Arc::new(conditions); + + let is_allow = Box::new({ + let iam_clone = Arc::clone(&iam_store); + let cred_clone = Arc::clone(&cred_clone); + let conditions = Arc::clone(&conditions); + move |name: String| { + let iam_clone = Arc::clone(&iam_clone); + let cred_clone = Arc::clone(&cred_clone); + let conditions = Arc::clone(&conditions); + async move { + let (mut rd, mut wr) = (false, false); + if !iam_clone + .is_allowed(&Args { + account: &cred_clone.access_key, + groups: &cred_clone.groups, + action: Action::S3Action(S3Action::ListBucketAction), + bucket: &name, + conditions: &conditions, + is_owner: owner, + object: "", + claims, + deny_only: false, + }) + .await + { + rd = true + } + + if !iam_clone + .is_allowed(&Args { + account: &cred_clone.access_key, + groups: &cred_clone.groups, + action: Action::S3Action(S3Action::GetBucketLocationAction), + bucket: &name, + conditions: &conditions, + is_owner: owner, + object: "", + claims, + deny_only: false, + }) + .await + { + rd = true + } + + if !iam_clone + .is_allowed(&Args { + account: &cred_clone.access_key, + groups: &cred_clone.groups, + action: Action::S3Action(S3Action::PutObjectAction), + bucket: &name, + conditions: &conditions, + is_owner: owner, + object: "", + claims, + deny_only: false, + }) + .await + { + wr = true + } + + (rd, wr) + } + } + }); + + let account_name = if cred.is_temp() || cred.is_service_account() { + cred.parent_user.clone() + } else { + cred.access_key.clone() + }; + + let claims_args = Args { + account: "", + groups: &None, + action: Action::None, + bucket: "", + conditions: &HashMap::new(), + is_owner: false, + object: "", + claims, + deny_only: false, + }; + + let role_arn = claims_args.get_role_arn(); + + // TODO: get_policies_from_claims(claims); + + let Some(admin_cred) = get_global_action_cred() else { + return Err(S3Error::with_message( + S3ErrorCode::InternalError, + "get_global_action_cred failed".to_string(), + )); + }; + + let mut effective_policy: policy::policy::Policy = Default::default(); + + if account_name == admin_cred.access_key { + for (name, p) in DEFAULT_POLICIES.iter() { + if *name == "consoleAdmin" { + effective_policy = p.clone(); + break; + } + } + } else if let Some(arn) = role_arn { + let (_, policy_name) = iam_store + .get_role_policy(arn) + .await + .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, e.to_string()))?; + + let policies = MappedPolicy::new(&policy_name).to_slice(); + effective_policy = iam_store.get_combined_policy(&policies).await; + } else { + let policies = iam_store + .policy_db_get(&account_name, &cred.groups) + .await + .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("get policy failed: {}", e)))?; + + effective_policy = iam_store.get_combined_policy(&policies).await; + }; + + let policy_str = serde_json::to_string(&effective_policy) + .map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse policy failed"))?; + + let mut account_info = madmin::AccountInfo { + account_name, + server: store.backend_info().await, + policy: serde_json::Value::String(policy_str), + ..Default::default() + }; + + // TODO: bucket policy + let buckets = store + .list_bucket(&BucketOptions { + cached: true, ..Default::default() - }], - }; + }) + .await + .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, e.to_string()))?; - // let policy = bucket_policy - // .marshal_msg() - // .map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse policy failed"))?; + for bucket in buckets.iter() { + let (rd, wr) = is_allow(bucket.name.clone()).await; + if rd || wr { + // TODO: BucketQuotaSys + // TODO: other attributes + account_info.buckets.push(madmin::BucketAccessInfo { + name: bucket.name.clone(), + details: Some(madmin::BucketDetails { + versioning: BucketVersioningSys::enabled(bucket.name.as_str()).await, + versioning_suspended: BucketVersioningSys::suspended(bucket.name.as_str()).await, + ..Default::default() + }), + created: bucket.created, + access: madmin::AccountAccess { read: rd, write: wr }, + ..Default::default() + }); + } + } - let backend_info = store.backend_info().await; - - let info = AccountInfo { - account_name: cred.access_key, - server: backend_info, - policy: bucket_policy, - }; - - let data = serde_json::to_vec(&info) + let data = serde_json::to_vec(&account_info) .map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?; let mut header = HeaderMap::new(); @@ -128,8 +274,6 @@ pub struct ServerInfoHandler {} #[async_trait::async_trait] impl Operation for ServerInfoHandler { async fn call(&self, _req: S3Request, _params: Params<'_, '_>) -> S3Result> { - warn!("handle ServerInfoHandler"); - let info = get_server_info(true).await; let data = serde_json::to_vec(&info) diff --git a/rustfs/src/admin/handlers/policy.rs b/rustfs/src/admin/handlers/policys.rs similarity index 99% rename from rustfs/src/admin/handlers/policy.rs rename to rustfs/src/admin/handlers/policys.rs index 4d650a593..2ef7f42f8 100644 --- a/rustfs/src/admin/handlers/policy.rs +++ b/rustfs/src/admin/handlers/policys.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use crate::admin::{router::Operation, utils::has_space_be}; use http::{HeaderMap, StatusCode}; use iam::{error::is_err_no_such_user, get_global_action_cred, store::MappedPolicy}; @@ -8,6 +6,7 @@ use policy::policy::Policy; use s3s::{header::CONTENT_TYPE, s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result}; use serde::Deserialize; use serde_urlencoded::from_bytes; +use std::collections::HashMap; use tracing::warn; #[derive(Debug, Deserialize, Default)] diff --git a/rustfs/src/admin/handlers/service_account.rs b/rustfs/src/admin/handlers/service_account.rs index 942bf4e59..f7d561ed5 100644 --- a/rustfs/src/admin/handlers/service_account.rs +++ b/rustfs/src/admin/handlers/service_account.rs @@ -1,5 +1,5 @@ use crate::admin::utils::has_space_be; -use crate::auth::get_session_token; +use crate::auth::{get_condition_values, get_session_token}; use crate::{admin::router::Operation, auth::check_key_valid}; use http::HeaderMap; use hyper::StatusCode; @@ -13,7 +13,8 @@ use madmin::{ ServiceAccountInfo, UpdateServiceAccountReq, }; use matchit::Params; -use policy::policy::Policy; +use policy::policy::action::{Action, AdminAction}; +use policy::policy::{Args, Policy}; use s3s::S3ErrorCode::InvalidRequest; use s3s::{header::CONTENT_TYPE, s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result}; use serde::Deserialize; @@ -30,7 +31,7 @@ impl Operation for AddServiceAccount { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = + let (cred, owner) = check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &req_cred.access_key).await?; let mut input = req.input; @@ -91,6 +92,25 @@ impl Operation for AddServiceAccount { let Ok(iam_store) = iam::get() else { return Err(s3_error!(InvalidRequest, "iam not init")) }; + let deny_only = cred.access_key == target_user || cred.parent_user == target_user; + + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::CreateServiceAccountAdminAction), + bucket: "", + conditions: &get_condition_values(&req.headers, &cred), + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only, + }) + .await + { + return Err(s3_error!(AccessDenied, "access denied")); + } + if target_user != cred.access_key { let has_user = iam_store.get_user(&target_user).await; if has_user.is_none() && target_user != sys_cred.access_key { @@ -212,7 +232,31 @@ impl Operation for UpdateServiceAccount { update_req .validate() .map_err(|e| S3Error::with_message(InvalidRequest, e.to_string()))?; - // TODO: is_allowed + + let Some(input_cred) = req.credentials else { + return Err(s3_error!(InvalidRequest, "get cred failed")); + }; + + let (cred, owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; + + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::UpdateServiceAccountAdminAction), + bucket: "", + conditions: &get_condition_values(&req.headers, &cred), + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only: false, + }) + .await + { + return Err(s3_error!(AccessDenied, "access denied")); + } + let sp = { if let Some(policy) = update_req.new_policy { let sp = Policy::parse_config(policy.as_bytes()).map_err(|e| { @@ -280,7 +324,36 @@ impl Operation for InfoServiceAccount { s3_error!(InternalError, "get service account failed") })?; - // TODO: is_allowed + let Some(input_cred) = req.credentials else { + return Err(s3_error!(InvalidRequest, "get cred failed")); + }; + + let (cred, owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; + + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::ListServiceAccountsAdminAction), + bucket: "", + conditions: &get_condition_values(&req.headers, &cred), + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only: false, + }) + .await + { + let user = if cred.parent_user.is_empty() { + &cred.access_key + } else { + &cred.parent_user + }; + if user != &svc_account.parent_user { + return Err(s3_error!(AccessDenied, "access denied")); + } + } let implied_policy = if let Some(policy) = session_policy.as_ref() { policy.version.is_empty() && policy.statements.is_empty() @@ -359,7 +432,7 @@ impl Operation for ListServiceAccount { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = + let (cred, owner) = check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key) .await .map_err(|e| { @@ -367,22 +440,47 @@ impl Operation for ListServiceAccount { s3_error!(InternalError, "check key failed") })?; - let target_account = if let Some(user) = query.user { - if user != input_cred.access_key { - user - } else if cred.parent_user.is_empty() { - input_cred.access_key - } else { - cred.parent_user + // let target_account = if let Some(user) = query.user { + // if user != input_cred.access_key { + // user + // } else if cred.parent_user.is_empty() { + // input_cred.access_key + // } else { + // cred.parent_user + // } + // } else if cred.parent_user.is_empty() { + // input_cred.access_key + // } else { + // cred.parent_user + // }; + + let Ok(iam_store) = iam::get() else { return Err(s3_error!(InvalidRequest, "iam not init")) }; + + let target_account = if query.user.as_ref().is_some_and(|v| v != &cred.access_key) { + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::UpdateServiceAccountAdminAction), + bucket: "", + conditions: &get_condition_values(&req.headers, &cred), + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only: false, + }) + .await + { + return Err(s3_error!(AccessDenied, "access denied")); } + + query.user.unwrap_or_default() } else if cred.parent_user.is_empty() { - input_cred.access_key + cred.access_key } else { cred.parent_user }; - let Ok(iam_store) = iam::get() else { return Err(s3_error!(InvalidRequest, "iam not init")) }; - let service_accounts = iam_store.list_service_accounts(&target_account).await.map_err(|e| { debug!("list service account failed: {e:?}"); s3_error!(InternalError, "list service account failed") @@ -420,7 +518,7 @@ impl Operation for DeleteServiceAccount { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (_cred, _owner) = + let (cred, owner) = check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key) .await .map_err(|e| { @@ -444,7 +542,7 @@ impl Operation for DeleteServiceAccount { let Ok(iam_store) = iam::get() else { return Err(s3_error!(InvalidRequest, "iam not init")) }; - let _svc_account = match iam_store.get_service_account(&query.access_key).await { + let svc_account = match iam_store.get_service_account(&query.access_key).await { Ok((res, _)) => Some(res), Err(err) => { if is_err_no_such_service_account(&err) { @@ -455,7 +553,30 @@ impl Operation for DeleteServiceAccount { } }; - // TODO: is_allowed + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::RemoveServiceAccountAdminAction), + bucket: "", + conditions: &get_condition_values(&req.headers, &cred), + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only: false, + }) + .await + { + let user = if cred.parent_user.is_empty() { + &cred.access_key + } else { + &cred.parent_user + }; + + if svc_account.is_some_and(|v| &v.parent_user != user) { + return Err(s3_error!(InvalidRequest, "service account not exist")); + } + } iam_store.delete_service_account(&query.access_key).await.map_err(|e| { debug!("delete service account failed, e: {:?}", e); diff --git a/rustfs/src/admin/handlers/user.rs b/rustfs/src/admin/handlers/user.rs index 06e2b9872..36d7c5939 100644 --- a/rustfs/src/admin/handlers/user.rs +++ b/rustfs/src/admin/handlers/user.rs @@ -1,9 +1,13 @@ -use std::str::from_utf8; +use std::{collections::HashMap, str::from_utf8}; use http::{HeaderMap, StatusCode}; use iam::get_global_action_cred; use madmin::{AccountStatus, AddOrUpdateUserReq}; use matchit::Params; +use policy::policy::{ + action::{Action, AdminAction}, + Args, +}; use s3s::{header::CONTENT_TYPE, s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result}; use serde::Deserialize; use serde_urlencoded::from_bytes; @@ -11,7 +15,7 @@ use tracing::warn; use crate::{ admin::{router::Operation, utils::has_space_be}, - auth::{check_key_valid, get_session_token}, + auth::{check_key_valid, get_condition_values, get_session_token}, }; #[derive(Debug, Deserialize, Default)] @@ -39,7 +43,7 @@ impl Operation for AddUser { return Err(s3_error!(InvalidRequest, "get cred failed")); }; - let (cred, _owner) = + let (cred, owner) = check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; let ak = query.access_key.as_deref().unwrap_or_default(); @@ -63,8 +67,6 @@ impl Operation for AddUser { let args: AddOrUpdateUserReq = serde_json::from_slice(&body) .map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("unmarshal body err {}", e)))?; - warn!("add user args {:?}", args); - if args.secret_key.is_empty() { return Err(s3_error!(InvalidArgument, "access key is empty")); } @@ -89,13 +91,24 @@ impl Operation for AddUser { return Err(s3_error!(InvalidArgument, "access key is not utf8")); } - // let check_deny_only = if ak == cred.access_key { - // true - // } else { - // false - // }; - - // TODO: is_allowed + let deny_only = ak == cred.access_key; + let conditions = get_condition_values(&req.headers, &cred); + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::CreateUserAdminAction), + bucket: "", + conditions: &conditions, + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only, + }) + .await + { + return Err(s3_error!(AccessDenied, "access denied")); + } iam_store .create_user(ak, &args) @@ -113,8 +126,6 @@ pub struct SetUserStatus {} #[async_trait::async_trait] impl Operation for SetUserStatus { async fn call(&self, req: S3Request, _params: Params<'_, '_>) -> S3Result> { - warn!("handle SetUserStatus"); - let query = { if let Some(query) = req.uri.query() { let input: AddUserQuery = @@ -165,8 +176,6 @@ pub struct ListUsers {} #[async_trait::async_trait] impl Operation for ListUsers { async fn call(&self, req: S3Request, _params: Params<'_, '_>) -> S3Result> { - warn!("handle ListUsers"); - let query = { if let Some(query) = req.uri.query() { let input: BucketQuery = @@ -214,8 +223,6 @@ pub struct RemoveUser {} #[async_trait::async_trait] impl Operation for RemoveUser { async fn call(&self, req: S3Request, _params: Params<'_, '_>) -> S3Result> { - warn!("handle RemoveUser"); - let query = { if let Some(query) = req.uri.query() { let input: AddUserQuery = @@ -277,8 +284,6 @@ pub struct GetUserInfo {} #[async_trait::async_trait] impl Operation for GetUserInfo { async fn call(&self, req: S3Request, _params: Params<'_, '_>) -> S3Result> { - warn!("handle GetUserInfo"); - let query = { if let Some(query) = req.uri.query() { let input: AddUserQuery = @@ -297,6 +302,32 @@ impl Operation for GetUserInfo { let Ok(iam_store) = iam::get() else { return Err(s3_error!(InvalidRequest, "iam not init")) }; + let Some(input_cred) = req.credentials else { + return Err(s3_error!(InvalidRequest, "get cred failed")); + }; + + let (cred, owner) = + check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?; + + let deny_only = ak == cred.access_key; + let conditions = get_condition_values(&req.headers, &cred); + if !iam_store + .is_allowed(&Args { + account: &cred.access_key, + groups: &cred.groups, + action: Action::AdminAction(AdminAction::GetUserAdminAction), + bucket: "", + conditions: &conditions, + is_owner: owner, + object: "", + claims: cred.claims.as_ref().unwrap_or(&HashMap::new()), + deny_only, + }) + .await + { + return Err(s3_error!(AccessDenied, "access denied")); + } + let info = iam_store .get_user_info(ak) .await diff --git a/rustfs/src/admin/mod.rs b/rustfs/src/admin/mod.rs index 4b3981327..094a8c8e2 100644 --- a/rustfs/src/admin/mod.rs +++ b/rustfs/src/admin/mod.rs @@ -6,10 +6,11 @@ pub mod utils; use common::error::Result; // use ecstore::global::{is_dist_erasure, is_erasure}; use handlers::{ - group, policy, + group, policys, service_account::{AddServiceAccount, DeleteServiceAccount, InfoServiceAccount, ListServiceAccount, UpdateServiceAccount}, sts, user, }; + use hyper::Method; use router::{AdminOperation, S3Router}; use rpc::regist_rpc_route; @@ -231,35 +232,35 @@ fn regist_user_route(r: &mut S3Router) -> Result<()> { r.insert( Method::GET, format!("{}{}", ADMIN_PREFIX, "/v3/list-canned-policies").as_str(), - AdminOperation(&policy::ListCannedPolicies {}), + AdminOperation(&policys::ListCannedPolicies {}), )?; // info-canned-policy?name=xxx r.insert( Method::GET, format!("{}{}", ADMIN_PREFIX, "/v3/info-canned-policy").as_str(), - AdminOperation(&policy::InfoCannedPolicy {}), + AdminOperation(&policys::InfoCannedPolicy {}), )?; // add-canned-policy?name=xxx r.insert( Method::PUT, format!("{}{}", ADMIN_PREFIX, "/v3/add-canned-policy").as_str(), - AdminOperation(&policy::AddCannedPolicy {}), + AdminOperation(&policys::AddCannedPolicy {}), )?; // remove-canned-policy?name=xxx r.insert( Method::DELETE, format!("{}{}", ADMIN_PREFIX, "/v3/remove-canned-policy").as_str(), - AdminOperation(&policy::RemoveCannedPolicy {}), + AdminOperation(&policys::RemoveCannedPolicy {}), )?; // set-user-or-group-policy?policyName=xxx&userOrGroup=xxx&isGroup=xxx r.insert( Method::PUT, format!("{}{}", ADMIN_PREFIX, "/v3/set-user-or-group-policy").as_str(), - AdminOperation(&policy::SetPolicyForUserOrGroup {}), + AdminOperation(&policys::SetPolicyForUserOrGroup {}), )?; Ok(()) From f97c262a1b425ba3d28a10bcb850b8a07ee622e1 Mon Sep 17 00:00:00 2001 From: weisd Date: Fri, 11 Apr 2025 11:33:44 +0800 Subject: [PATCH 088/103] fix:#309 add head_object options --- rustfs/src/storage/ecfs.rs | 65 +++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index f517220a3..a235542b8 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -261,14 +261,7 @@ impl S3 for FS { .await .map_err(to_s3_error)?; - let version_id = opts - .version_id - .as_ref() - .map(|v| match Uuid::parse_str(v) { - Ok(id) => Some(id), - Err(_) => None, - }) - .unwrap_or_default(); + let version_id = opts.version_id.as_ref().map(|v| Uuid::parse_str(v).ok()).unwrap_or_default(); let dobj = ObjectToDelete { object_name: key, version_id, @@ -325,14 +318,7 @@ impl S3 for FS { .objects .iter() .map(|v| { - let version_id = v - .version_id - .as_ref() - .map(|v| match Uuid::parse_str(v) { - Ok(id) => Some(id), - Err(_) => None, - }) - .unwrap_or_default(); + let version_id = v.version_id.as_ref().map(|v| Uuid::parse_str(v).ok()).unwrap_or_default(); ObjectToDelete { object_name: v.key.clone(), version_id, @@ -407,8 +393,6 @@ impl S3 for FS { async fn get_object(&self, req: S3Request) -> S3Result> { // mc get 3 - // warn!("get_object input {:?}, vid {:?}", &req.input, req.input.version_id); - let GetObjectInput { bucket, key, @@ -447,8 +431,6 @@ impl S3 for FS { return Err(s3_error!(InvalidArgument, "range and part_number invalid")); } - // let metadata = extract_metadata(&req.headers); - let opts: ObjectOptions = get_opts(&bucket, &key, version_id, part_number, &req.headers) .await .map_err(to_s3_error)?; @@ -516,16 +498,49 @@ impl S3 for FS { #[tracing::instrument(level = "debug", skip(self, req))] async fn head_object(&self, req: S3Request) -> S3Result> { // mc get 2 - let HeadObjectInput { bucket, key, .. } = req.input; + let HeadObjectInput { + bucket, + key, + version_id, + part_number, + range, + .. + } = req.input; + + let part_number = part_number.map(|v| v as usize); + + if let Some(part_num) = part_number { + if part_num == 0 { + return Err(s3_error!(InvalidArgument, "part_numer invalid")); + } + } + + let rs = range.map(|v| match v { + Range::Int { first, last } => HTTPRangeSpec { + is_suffix_length: false, + start: first as usize, + end: last.map(|v| v as usize), + }, + Range::Suffix { length } => HTTPRangeSpec { + is_suffix_length: true, + start: length as usize, + end: None, + }, + }); + + if rs.is_some() && part_number.is_some() { + return Err(s3_error!(InvalidArgument, "range and part_number invalid")); + } + + let opts: ObjectOptions = get_opts(&bucket, &key, version_id, part_number, &req.headers) + .await + .map_err(to_s3_error)?; let Some(store) = new_object_layer_fn() else { return Err(S3Error::with_message(S3ErrorCode::InternalError, "Not init".to_string())); }; - let info = store - .get_object_info(&bucket, &key, &ObjectOptions::default()) - .await - .map_err(to_s3_error)?; + let info = store.get_object_info(&bucket, &key, &opts).await.map_err(to_s3_error)?; // warn!("head_object info {:?}", &info); From 9baede4bc40d6be2b4c2c2689aa194c5e1b2b9db Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 14:27:55 +0800 Subject: [PATCH 089/103] Update obs.example.toml --- config/obs.example.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/obs.example.toml b/config/obs.example.toml index 0ba434ada..b69ba3386 100644 --- a/config/obs.example.toml +++ b/config/obs.example.toml @@ -6,7 +6,7 @@ meter_interval = 30 service_name = "rustfs" service_version = "0.1.0" environment = "develop" -looger_level = "info" +logger_level = "info" [sinks] [sinks.kafka] # Kafka sink is disabled by default @@ -30,4 +30,4 @@ batch_size = 100 batch_timeout_ms = 1000 # Default is 8192 bytes if not specified [logger] -queue_capacity = 10000 \ No newline at end of file +queue_capacity = 10000 From 1b24fbdb009b1a3c7c793f7dc3fa48a874f58a5a Mon Sep 17 00:00:00 2001 From: Nugine Date: Fri, 11 Apr 2025 16:01:46 +0800 Subject: [PATCH 090/103] fix: upgrade s3s --- Cargo.lock | 75 ++++++++++++++++++++++++++------------ Cargo.toml | 6 +-- rustfs/src/admin/router.rs | 6 ++- rustfs/src/main.rs | 5 +-- rustfs/src/storage/ecfs.rs | 6 +-- 5 files changed, 62 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60bd0acbd..ed330cd55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,7 +388,7 @@ dependencies = [ "arrow-schema", "chrono", "half", - "indexmap 2.8.0", + "indexmap 2.9.0", "lexical-core", "memchr", "num", @@ -1626,6 +1626,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32c" version = "0.6.8" @@ -1644,6 +1659,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crc64fast-nvme" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4955638f00a809894c947f85a024020a20815b65a5eea633798ea7924edab2b3" +dependencies = [ + "crc", +] + [[package]] name = "crossbeam-channel" version = "0.5.14" @@ -1933,7 +1957,7 @@ dependencies = [ "base64 0.22.1", "half", "hashbrown 0.14.5", - "indexmap 2.8.0", + "indexmap 2.9.0", "libc", "log", "object_store", @@ -2028,7 +2052,7 @@ dependencies = [ "datafusion-functions-aggregate-common", "datafusion-functions-window-common", "datafusion-physical-expr-common", - "indexmap 2.8.0", + "indexmap 2.9.0", "paste", "recursive", "serde_json", @@ -2043,7 +2067,7 @@ checksum = "18f0a851a436c5a2139189eb4617a54e6a9ccb9edc96c4b3c83b3bb7c58b950e" dependencies = [ "arrow", "datafusion-common", - "indexmap 2.8.0", + "indexmap 2.9.0", "itertools 0.14.0", "paste", ] @@ -2197,7 +2221,7 @@ dependencies = [ "datafusion-common", "datafusion-expr", "datafusion-physical-expr", - "indexmap 2.8.0", + "indexmap 2.9.0", "itertools 0.14.0", "log", "recursive", @@ -2220,7 +2244,7 @@ dependencies = [ "datafusion-physical-expr-common", "half", "hashbrown 0.14.5", - "indexmap 2.8.0", + "indexmap 2.9.0", "itertools 0.14.0", "log", "paste", @@ -2282,7 +2306,7 @@ dependencies = [ "futures", "half", "hashbrown 0.14.5", - "indexmap 2.8.0", + "indexmap 2.9.0", "itertools 0.14.0", "log", "parking_lot 0.12.3", @@ -2300,7 +2324,7 @@ dependencies = [ "bigdecimal", "datafusion-common", "datafusion-expr", - "indexmap 2.8.0", + "indexmap 2.9.0", "log", "recursive", "regex", @@ -3816,7 +3840,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.8.0", + "indexmap 2.9.0", "slab", "tokio", "tokio-util", @@ -4301,9 +4325,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -6000,7 +6024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset", - "indexmap 2.8.0", + "indexmap 2.9.0", ] [[package]] @@ -7338,8 +7362,8 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "s3s" -version = "0.11.0-dev" -source = "git+https://github.com/Nugine/s3s.git?rev=ab139f72fe768fb9d8cecfe36269451da1ca9779#ab139f72fe768fb9d8cecfe36269451da1ca9779" +version = "0.12.0-dev" +source = "git+https://github.com/Nugine/s3s.git?rev=3ad13ace7af703c3c8afc99cf19f4c18c82603a3#3ad13ace7af703c3c8afc99cf19f4c18c82603a3" dependencies = [ "arrayvec", "async-trait", @@ -7348,17 +7372,20 @@ dependencies = [ "bytes", "bytestring", "chrono", + "const-str", "crc32c", "crc32fast", - "digest 0.11.0-pre.10", + "crc64fast-nvme", "futures", "hex-simd", "hmac 0.13.0-pre.5", + "http", "http-body", "http-body-util", "httparse", "hyper", "itoa 1.0.15", + "md-5", "memchr", "mime", "nom", @@ -7385,10 +7412,10 @@ dependencies = [ [[package]] name = "s3s-policy" -version = "0.11.0-dev" -source = "git+https://github.com/Nugine/s3s.git?rev=ab139f72fe768fb9d8cecfe36269451da1ca9779#ab139f72fe768fb9d8cecfe36269451da1ca9779" +version = "0.12.0-dev" +source = "git+https://github.com/Nugine/s3s.git?rev=3ad13ace7af703c3c8afc99cf19f4c18c82603a3#3ad13ace7af703c3c8afc99cf19f4c18c82603a3" dependencies = [ - "indexmap 2.8.0", + "indexmap 2.9.0", "serde", "serde_json", "thiserror 2.0.12", @@ -7839,9 +7866,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "snafu" @@ -8455,7 +8482,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.8.0", + "indexmap 2.9.0", "toml_datetime", "winnow 0.5.40", ] @@ -8466,7 +8493,7 @@ version = "0.20.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" dependencies = [ - "indexmap 2.8.0", + "indexmap 2.9.0", "toml_datetime", "winnow 0.5.40", ] @@ -8477,7 +8504,7 @@ version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ - "indexmap 2.8.0", + "indexmap 2.9.0", "serde", "serde_spanned", "toml_datetime", @@ -8596,7 +8623,7 @@ checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", - "indexmap 2.8.0", + "indexmap 2.9.0", "pin-project-lite", "slab", "sync_wrapper", diff --git a/Cargo.toml b/Cargo.toml index 9f1b721ce..780477d2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,10 +101,8 @@ rust-embed = "8.6.0" rustls = { version = "0.23" } rustls-pki-types = "1.11.0" rustls-pemfile = "2.2.0" -s3s = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779", default-features = true, features = [ - "tower", -] } -s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779" } +s3s = { git = "https://github.com/Nugine/s3s.git", rev = "3ad13ace7af703c3c8afc99cf19f4c18c82603a3" } +s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "3ad13ace7af703c3c8afc99cf19f4c18c82603a3" } shadow-rs = { version = "0.38.0", default-features = false } serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.138" diff --git a/rustfs/src/admin/router.rs b/rustfs/src/admin/router.rs index 4fb605d69..d19d4da2c 100644 --- a/rustfs/src/admin/router.rs +++ b/rustfs/src/admin/router.rs @@ -67,14 +67,16 @@ where uri.path().starts_with(ADMIN_PREFIX) || uri.path().starts_with(RPC_PREFIX) } - async fn call(&self, req: S3Request) -> S3Result> { + async fn call(&self, req: S3Request) -> S3Result> { let uri = format!("{}|{}", &req.method, req.uri.path()); // warn!("get uri {}", &uri); if let Ok(mat) = self.router.at(&uri) { let op: &T = mat.value; - return op.call(req, mat.params).await; + let mut resp = op.call(req, mat.params).await?; + resp.status = Some(resp.output.0); + return Ok(resp.map_output(|x| x.1)); } return Err(s3_error!(NotImplemented)); diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index cd1c72d1c..f2b69999e 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -226,7 +226,7 @@ async fn run(opt: config::Opt) -> Result<()> { // Setup S3 service // 本项目使用 s3s 库来实现 s3 服务 - let service = { + let s3_service = { let store = storage::ecfs::FS::new(); // let mut b = S3ServiceBuilder::new(storage::ecfs::FS::new(server_address.clone(), endpoint_pools).await?); let mut b = S3ServiceBuilder::new(store.clone()); @@ -308,11 +308,10 @@ async fn run(opt: config::Opt) -> Result<()> { let mut sigterm_inner = sigterm_inner; let mut sigint_inner = sigint_inner; - let hyper_service = service.into_shared(); let hybrid_service = TowerToHyperService::new( tower::ServiceBuilder::new() .layer(CorsLayer::permissive()) - .service(hybrid(hyper_service, rpc_service)), + .service(hybrid(s3_service, rpc_service)), ); let http_server = ConnBuilder::new(TokioExecutor::new()); diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index a235542b8..f1f53b9fb 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -1069,11 +1069,11 @@ impl S3 for FS { #[tracing::instrument(level = "debug", skip(self))] async fn get_bucket_tagging(&self, req: S3Request) -> S3Result> { - let GetBucketTaggingInput { bucket, .. } = req.input; + let bucket = req.input.bucket.clone(); // check bucket exists. let _bucket = self - .head_bucket(S3Request::new(HeadBucketInput { - bucket: bucket.clone(), + .head_bucket(req.map_input(|input| HeadBucketInput { + bucket: input.bucket, expected_bucket_owner: None, })) .await?; From ab8b19eb5d7f0635c4fb91f0e711c7e53ecc93a6 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 16:48:07 +0800 Subject: [PATCH 091/103] improve signal watch --- Cargo.lock | 16 ++- Cargo.toml | 3 +- crates/obs/src/config.rs | 126 ++++++++++++++++----- crates/obs/src/logger.rs | 2 +- crates/obs/src/sink.rs | 115 +++++++++++++------- crates/obs/src/telemetry.rs | 5 +- deploy/config/.example.env | 27 +++++ deploy/config/obs.example.toml | 4 +- rustfs/Cargo.toml | 3 +- rustfs/src/main.rs | 169 ++++++++--------------------- rustfs/src/server/mod.rs | 6 + rustfs/src/server/service_state.rs | 152 ++++++++++++++++++++++++++ scripts/run.sh | 23 +++- 13 files changed, 449 insertions(+), 202 deletions(-) create mode 100644 deploy/config/.example.env create mode 100644 rustfs/src/server/mod.rs create mode 100644 rustfs/src/server/service_state.rs diff --git a/Cargo.lock b/Cargo.lock index 68b1892ce..d3ddf94e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -669,6 +669,17 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atomic_enum" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e1aca718ea7b89985790c94aad72d77533063fe00bc497bb79a7c2dae6a661" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -7133,6 +7144,7 @@ dependencies = [ "appauth", "async-trait", "atoi", + "atomic_enum", "axum", "axum-extra", "axum-server", @@ -7279,9 +7291,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.25" +version = "0.23.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" +checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" dependencies = [ "aws-lc-rs", "log", diff --git a/Cargo.toml b/Cargo.toml index 9f1b721ce..70c8e39db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ madmin = { path = "./madmin" } atoi = "2.0.0" async-recursion = "1.0.5" async-trait = "0.1.87" +atomic_enum = "0.3.0" axum = "0.8.3" axum-extra = "0.10.1" axum-server = { version = "0.7.2", features = ["tls-rustls"] } @@ -98,7 +99,7 @@ rmp = "0.8.14" rmp-serde = "1.3.0" rustfs-obs = { path = "crates/obs", version = "0.0.1" } rust-embed = "8.6.0" -rustls = { version = "0.23" } +rustls = { version = "0.23.26" } rustls-pki-types = "1.11.0" rustls-pemfile = "2.2.0" s3s = { git = "https://github.com/Nugine/s3s.git", rev = "ab139f72fe768fb9d8cecfe36269451da1ca9779", default-features = true, features = [ diff --git a/crates/obs/src/config.rs b/crates/obs/src/config.rs index 4106834e3..c7d3ff7d5 100644 --- a/crates/obs/src/config.rs +++ b/crates/obs/src/config.rs @@ -1,5 +1,5 @@ -use crate::global::{ENVIRONMENT, LOGGER_LEVEL, METER_INTERVAL, SAMPLE_RATIO, SERVICE_NAME, SERVICE_VERSION}; -use config::{Config, File, FileFormat}; +use crate::global::{ENVIRONMENT, LOGGER_LEVEL, METER_INTERVAL, SAMPLE_RATIO, SERVICE_NAME, SERVICE_VERSION, USE_STDOUT}; +use config::{Config, Environment, File, FileFormat}; use serde::Deserialize; use std::env; @@ -22,18 +22,44 @@ pub struct OtelConfig { pub logger_level: Option, } +// 辅助函数:从环境变量中提取可观测性配置 +fn extract_otel_config_from_env() -> OtelConfig { + OtelConfig { + endpoint: env::var("RUSTFS_OBSERVABILITY_ENDPOINT").unwrap_or_else(|_| "".to_string()), + use_stdout: env::var("RUSTFS_OBSERVABILITY_USE_STDOUT") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(USE_STDOUT)), + sample_ratio: env::var("RUSTFS_OBSERVABILITY_SAMPLE_RATIO") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(SAMPLE_RATIO)), + meter_interval: env::var("RUSTFS_OBSERVABILITY_METER_INTERVAL") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(METER_INTERVAL)), + service_name: env::var("RUSTFS_OBSERVABILITY_SERVICE_NAME") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(SERVICE_NAME.to_string())), + service_version: env::var("RUSTFS_OBSERVABILITY_SERVICE_VERSION") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(SERVICE_VERSION.to_string())), + environment: env::var("RUSTFS_OBSERVABILITY_ENVIRONMENT") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(ENVIRONMENT.to_string())), + logger_level: env::var("RUSTFS_OBSERVABILITY_LOGGER_LEVEL") + .ok() + .and_then(|v| v.parse().ok()) + .or(Some(LOGGER_LEVEL.to_string())), + } +} + impl Default for OtelConfig { fn default() -> Self { - OtelConfig { - endpoint: "".to_string(), - use_stdout: Some(true), - sample_ratio: Some(SAMPLE_RATIO), - meter_interval: Some(METER_INTERVAL), - service_name: Some(SERVICE_NAME.to_string()), - service_version: Some(SERVICE_VERSION.to_string()), - environment: Some(ENVIRONMENT.to_string()), - logger_level: Some(LOGGER_LEVEL.to_string()), - } + extract_otel_config_from_env() } } @@ -69,14 +95,18 @@ pub struct FileSinkConfig { impl FileSinkConfig { pub fn get_default_log_path() -> String { - let temp_dir = env::temp_dir().join("rustfs").join("logs"); + let temp_dir = env::temp_dir().join("rustfs"); if let Err(e) = std::fs::create_dir_all(&temp_dir) { eprintln!("Failed to create log directory: {}", e); - return "logs/app.log".to_string(); + return "rustfs/rustfs.log".to_string(); } - temp_dir.join("app.log").to_str().unwrap_or("logs/app.log").to_string() + temp_dir + .join("rustfs.log") + .to_str() + .unwrap_or("rustfs/rustfs.log") + .to_string() } } @@ -84,7 +114,10 @@ impl Default for FileSinkConfig { fn default() -> Self { FileSinkConfig { enabled: true, - path: Self::get_default_log_path(), + path: env::var("RUSTFS_SINKS_FILE_PATH") + .ok() + .filter(|s| !s.trim().is_empty()) + .unwrap_or_else(|| Self::get_default_log_path()), buffer_size: Some(8192), flush_interval_ms: Some(1000), flush_threshold: Some(100), @@ -93,11 +126,21 @@ impl Default for FileSinkConfig { } /// Sink configuration collection -#[derive(Debug, Deserialize, Clone, Default)] +#[derive(Debug, Deserialize, Clone)] pub struct SinkConfig { - pub kafka: KafkaSinkConfig, - pub webhook: WebhookSinkConfig, - pub file: FileSinkConfig, + pub kafka: Option, + pub webhook: Option, + pub file: Option, +} + +impl Default for SinkConfig { + fn default() -> Self { + SinkConfig { + kafka: None, + webhook: None, + file: Some(FileSinkConfig::default()), + } + } } ///Logger Configuration @@ -109,7 +152,7 @@ pub struct LoggerConfig { impl Default for LoggerConfig { fn default() -> Self { LoggerConfig { - queue_capacity: Some(1000), + queue_capacity: Some(10000), } } } @@ -128,11 +171,28 @@ impl Default for LoggerConfig { /// /// let config = load_config(None); /// ``` -#[derive(Debug, Deserialize, Clone, Default)] +#[derive(Debug, Deserialize, Clone)] pub struct AppConfig { pub observability: OtelConfig, pub sinks: SinkConfig, - pub logger: LoggerConfig, + pub logger: Option, +} + +// 为 AppConfig 实现 Default +impl AppConfig { + pub fn new() -> Self { + Self { + observability: OtelConfig::default(), + sinks: SinkConfig::default(), + logger: Some(LoggerConfig::default()), + } + } +} + +impl Default for AppConfig { + fn default() -> Self { + Self::new() + } } const DEFAULT_CONFIG_FILE: &str = "obs"; @@ -187,9 +247,25 @@ pub fn load_config(config_dir: Option) -> AppConfig { let config = Config::builder() .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Toml).required(false)) .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Yaml).required(false)) - .add_source(config::Environment::with_prefix("")) + .add_source( + Environment::default() + .prefix("RUSTFS") + .prefix_separator("__") + .separator("__") + .with_list_parse_key("volumes") + .try_parsing(true), + ) .build() .unwrap_or_default(); - config.try_deserialize().unwrap_or_default() + match config.try_deserialize::() { + Ok(app_config) => { + println!("Parsed AppConfig: {:?}", app_config); + app_config + } + Err(e) => { + println!("Failed to deserialize config: {}", e); + AppConfig::default() + } + } } diff --git a/crates/obs/src/logger.rs b/crates/obs/src/logger.rs index 55f4bd0e3..1e62712cb 100644 --- a/crates/obs/src/logger.rs +++ b/crates/obs/src/logger.rs @@ -21,7 +21,7 @@ impl Logger { /// Returns Logger and corresponding Receiver pub fn new(config: &AppConfig) -> (Self, Receiver) { // Get queue capacity from configuration, or use default values 10000 - let queue_capacity = config.logger.queue_capacity.unwrap_or(10000); + let queue_capacity = config.logger.as_ref().and_then(|l| l.queue_capacity).unwrap_or(10000); let (sender, receiver) = mpsc::channel(queue_capacity); (Logger { sender, queue_capacity }, receiver) } diff --git a/crates/obs/src/sink.rs b/crates/obs/src/sink.rs index 1f1c481f8..a92a980a7 100644 --- a/crates/obs/src/sink.rs +++ b/crates/obs/src/sink.rs @@ -4,7 +4,6 @@ use std::sync::Arc; use tokio::fs::OpenOptions; use tokio::io; use tokio::io::AsyncWriteExt; -use tracing::debug; /// Sink Trait definition, asynchronously write logs #[async_trait] @@ -274,15 +273,15 @@ impl FileSink { // if the file not exists, create it if !file_exists { tokio::fs::create_dir_all(std::path::Path::new(&path).parent().unwrap()).await?; - debug!("the file not exists,create if. path: {:?}", path) + tracing::debug!("the file not exists,create if. path: {:?}", path) } let file = if file_exists { // If the file exists, open it in append mode - debug!("FileSink: File exists, opening in append mode."); + tracing::debug!("FileSink: File exists, opening in append mode."); OpenOptions::new().append(true).create(true).open(&path).await? } else { // If the file does not exist, create it - debug!("FileSink: File does not exist, creating a new file."); + tracing::debug!("FileSink: File does not exist, creating a new file."); // Create the file and write a header or initial content if needed OpenOptions::new().create(true).truncate(true).write(true).open(&path).await? }; @@ -414,52 +413,84 @@ pub async fn create_sinks(config: &AppConfig) -> Vec> { let mut sinks: Vec> = Vec::new(); #[cfg(feature = "kafka")] - if config.sinks.kafka.enabled { - match rdkafka::config::ClientConfig::new() - .set("bootstrap.servers", &config.sinks.kafka.bootstrap_servers) - .set("message.timeout.ms", "5000") - .create() - { - Ok(producer) => { - sinks.push(Arc::new(KafkaSink::new( - producer, - config.sinks.kafka.topic.clone(), - config.sinks.kafka.batch_size.unwrap_or(100), - config.sinks.kafka.batch_timeout_ms.unwrap_or(1000), - ))); + { + match &config.sinks.kafka { + Some(sink_kafka) => { + if sink_kafka.enabled { + match rdkafka::config::ClientConfig::new() + .set("bootstrap.servers", &sink_kafka.bootstrap_servers) + .set("message.timeout.ms", "5000") + .create() + { + Ok(producer) => { + sinks.push(Arc::new(KafkaSink::new( + producer, + sink_kafka.topic.clone(), + sink_kafka.batch_size.unwrap_or(100), + sink_kafka.batch_timeout_ms.unwrap_or(1000), + ))); + } + Err(e) => { + tracing::error!("Failed to create Kafka producer: {}", e); + } + } + } else { + tracing::info!("Kafka sink is disabled in the configuration"); + } + } + _ => { + tracing::info!("Kafka sink is not configured or disabled"); } - Err(e) => eprintln!("Failed to create Kafka producer: {}", e), } } - #[cfg(feature = "webhook")] - if config.sinks.webhook.enabled { - sinks.push(Arc::new(WebhookSink::new( - config.sinks.webhook.endpoint.clone(), - config.sinks.webhook.auth_token.clone(), - config.sinks.webhook.max_retries.unwrap_or(3), - config.sinks.webhook.retry_delay_ms.unwrap_or(100), - ))); + { + match &config.sinks.webhook { + Some(sink_webhook) => { + if sink_webhook.enabled { + sinks.push(Arc::new(WebhookSink::new( + sink_webhook.endpoint.clone(), + sink_webhook.auth_token.clone(), + sink_webhook.max_retries.unwrap_or(3), + sink_webhook.retry_delay_ms.unwrap_or(100), + ))); + } else { + tracing::info!("Webhook sink is disabled in the configuration"); + } + } + _ => { + tracing::info!("Webhook sink is not configured or disabled"); + } + } } #[cfg(feature = "file")] { - let path = if config.sinks.file.enabled { - config.sinks.file.path.clone() - } else { - "default.log".to_string() - }; - debug!("FileSink: Using path: {}", path); - sinks.push(Arc::new( - FileSink::new( - path.clone(), - config.sinks.file.buffer_size.unwrap_or(8192), - config.sinks.file.flush_interval_ms.unwrap_or(1000), - config.sinks.file.flush_threshold.unwrap_or(100), - ) - .await - .unwrap(), - )); + // let config = config.clone(); + match &config.sinks.file { + Some(sink_file) => { + tracing::info!("File sink is enabled in the configuration"); + let path = if sink_file.enabled { + sink_file.path.clone() + } else { + "rustfs.log".to_string() + }; + tracing::debug!("FileSink: Using path: {}", path); + sinks.push(Arc::new( + FileSink::new( + path.clone(), + sink_file.buffer_size.unwrap_or(8192), + sink_file.flush_interval_ms.unwrap_or(1000), + sink_file.flush_threshold.unwrap_or(100), + ) + .await + .unwrap(), + )); + } + _ => { + tracing::info!("File sink is not configured or disabled"); + } + } } sinks diff --git a/crates/obs/src/telemetry.rs b/crates/obs/src/telemetry.rs index 415e427fc..82c93de73 100644 --- a/crates/obs/src/telemetry.rs +++ b/crates/obs/src/telemetry.rs @@ -293,7 +293,10 @@ pub fn init_telemetry(config: &OtelConfig) -> OtelGuard { registry.with(ErrorLayer::default()).with(fmt_layer).init(); if !config.endpoint.is_empty() { - info!("OpenTelemetry telemetry initialized with OTLP endpoint: {}", config.endpoint); + info!( + "OpenTelemetry telemetry initialized with OTLP endpoint: {}, logger_level: {}", + config.endpoint, logger_level + ); } OtelGuard { diff --git a/deploy/config/.example.env b/deploy/config/.example.env new file mode 100644 index 000000000..9db2f211f --- /dev/null +++ b/deploy/config/.example.env @@ -0,0 +1,27 @@ +OBSERVABILITY__ENDPOINT=http://localhost:4317 +OBSERVABILITY__USE_STDOUT=true +OBSERVABILITY__SAMPLE_RATIO=2.0 +OBSERVABILITY__METER_INTERVAL=30 +OBSERVABILITY__SERVICE_NAME=rustfs +OBSERVABILITY__SERVICE_VERSION=0.1.0 +OBSERVABILITY__ENVIRONMENT=develop +OBSERVABILITY__LOGGER_LEVEL=debug + +SINKS__KAFKA__ENABLED=false +SINKS__KAFKA__BOOTSTRAP_SERVERS=localhost:9092 +SINKS__KAFKA__TOPIC=logs +SINKS__KAFKA__BATCH_SIZE=100 +SINKS__KAFKA__BATCH_TIMEOUT_MS=1000 + +SINKS__WEBHOOK__ENABLED=false +SINKS__WEBHOOK__ENDPOINT=http://localhost:8080/webhook +SINKS__WEBHOOK__AUTH_TOKEN= +SINKS__WEBHOOK__BATCH_SIZE=100 +SINKS__WEBHOOK__BATCH_TIMEOUT_MS=1000 + +SINKS__FILE__ENABLED=true +SINKS__FILE__PATH=./deploy/logs/app.log +SINKS__FILE__BATCH_SIZE=10 +SINKS__FILE__BATCH_TIMEOUT_MS=1000 + +LOGGER__QUEUE_CAPACITY=10 \ No newline at end of file diff --git a/deploy/config/obs.example.toml b/deploy/config/obs.example.toml index 0ba434ada..dc74a85f4 100644 --- a/deploy/config/obs.example.toml +++ b/deploy/config/obs.example.toml @@ -6,7 +6,7 @@ meter_interval = 30 service_name = "rustfs" service_version = "0.1.0" environment = "develop" -looger_level = "info" +logger_level = "info" [sinks] [sinks.kafka] # Kafka sink is disabled by default @@ -25,7 +25,7 @@ batch_timeout_ms = 1000 # Default is 100ms if not specified [sinks.file] enabled = true -path = "logs/app.log" +path = "./deploy/logs/app.log" batch_size = 100 batch_timeout_ms = 1000 # Default is 8192 bytes if not specified diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 00c10bebd..96e9700b2 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -19,6 +19,7 @@ madmin.workspace = true api = { path = "../s3select/api" } appauth = { version = "0.0.1", path = "../appauth" } atoi = { workspace = true } +atomic_enum = { workspace = true } axum.workspace = true axum-extra = { workspace = true } axum-server = { workspace = true } @@ -87,7 +88,7 @@ url.workspace = true uuid = "1.15.1" [target.'cfg(target_os = "linux")'.dependencies] -libsystemd = "0.7" +libsystemd.workspace = true [build-dependencies] prost-build.workspace = true diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index cd1c72d1c..8c34b3494 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -5,14 +5,15 @@ mod console; mod grpc; pub mod license; mod logging; +mod server; mod service; mod storage; mod utils; - use crate::auth::IAMAuth; use crate::console::{init_console_cfg, CONSOLE_CONFIG}; -use crate::utils::error; // Ensure the correct path for parse_license is imported +use crate::server::{wait_for_shutdown, ServiceState, ServiceStateManager, ShutdownSignal, SHUTDOWN_TIMEOUT}; +use crate::utils::error; use chrono::Datelike; use clap::Parser; use common::{ @@ -31,6 +32,7 @@ use ecstore::{ }; use ecstore::{global::set_global_rustfs_port, notification_sys::new_global_notification_sys}; use grpc::make_server; +use hyper_util::server::graceful::GracefulShutdown; use hyper_util::{ rt::{TokioExecutor, TokioIo}, server::conn::auto::Builder as ConnBuilder, @@ -44,41 +46,18 @@ use rustls::ServerConfig; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; use std::sync::Arc; +use std::time::Duration; use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; use tokio::signal::unix::{signal, SignalKind}; use tokio_rustls::TlsAcceptor; use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; -use tracing::{debug, error, info, info_span, warn}; +use tracing::log::warn; +use tracing::{debug, error, info, info_span}; use tracing_error::ErrorLayer; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; -#[cfg(target_os = "linux")] -fn notify_systemd(state: &str) { - use libsystemd::daemon::{notify, NotifyState}; - let notify_state = match state { - "ready" => NotifyState::Ready, - "stopping" => NotifyState::Stopping, - _ => { - warn!("Unsupported state passed to notify_systemd: {}", state); - return; - } - }; - - if let Err(e) = notify(false, &[notify_state]) { - error!("Failed to notify systemd: {}", e); - } else { - debug!("Successfully notified systemd: {}", state); - } - info!("Systemd notifications are enabled on linux (state: {})", state); -} - -#[cfg(not(target_os = "linux"))] -fn notify_systemd(state: &str) { - info!("Systemd notifications are not available on this platform not linux (state: {})", state); -} - #[allow(dead_code)] fn setup_tracing() { use tracing_subscriber::EnvFilter; @@ -286,8 +265,14 @@ async fn run(opt: config::Opt) -> Result<()> { None }; - // Create an oneshot channel to wait for the service to start - let (tx, rx) = tokio::sync::oneshot::channel(); + let state_manager = ServiceStateManager::new(); + let worker_state_manager = state_manager.clone(); + // 更新服务状态为启动中 + state_manager.update(ServiceState::Starting); + + // Create shutdown channel + let (shutdown_tx, mut shutdown_rx) = tokio::sync::broadcast::channel(1); + let shutdown_tx_clone = shutdown_tx.clone(); tokio::spawn(async move { // 错误处理改进 @@ -317,11 +302,11 @@ async fn run(opt: config::Opt) -> Result<()> { let http_server = ConnBuilder::new(TokioExecutor::new()); let mut ctrl_c = std::pin::pin!(tokio::signal::ctrl_c()); - let graceful = hyper_util::server::graceful::GracefulShutdown::new(); + let graceful = GracefulShutdown::new(); debug!("graceful initiated"); - // Send a message to the main thread to indicate that the server has started - let _ = tx.send(()); + // 服务准备就绪 + worker_state_manager.update(ServiceState::Ready); loop { debug!("waiting for SIGINT or SIGTERM has_tls_certs: {}", has_tls_certs); @@ -337,17 +322,23 @@ async fn run(opt: config::Opt) -> Result<()> { } } _ = ctrl_c.as_mut() => { - drop(listener); - eprintln!("Ctrl-C received, starting shutdown"); + info!("Ctrl-C received in worker thread"); + let _ = shutdown_tx_clone.send(()); break; } _ = sigint_inner.recv() => { info!("SIGINT received in worker thread"); + let _ = shutdown_tx_clone.send(()); break; } _ = sigterm_inner.recv() => { info!("SIGTERM received in worker thread"); + let _ = shutdown_tx_clone.send(()); + break; + } + _ = shutdown_rx.recv() => { + info!("Shutdown signal received in worker thread"); break; } }; @@ -391,7 +382,7 @@ async fn run(opt: config::Opt) -> Result<()> { debug!("Http handshake success"); } } - + worker_state_manager.update(ServiceState::Stopping); tokio::select! { () = graceful.shutdown() => { debug!("Gracefully shutdown!"); @@ -400,6 +391,7 @@ async fn run(opt: config::Opt) -> Result<()> { debug!("Waited 10 seconds for graceful shutdown, aborting..."); } } + worker_state_manager.update(ServiceState::Stopped); }); // init store @@ -449,97 +441,24 @@ async fn run(opt: config::Opt) -> Result<()> { }); } - // 执行休眠 1 秒钟 - tokio::time::sleep(std::time::Duration::from_secs(1)).await; - // Wait for the HTTP service to finish starting - if rx.await.is_ok() { - notify_systemd("ready"); - } else { - info!("Failed to start the server"); - } - - // 主线程中监听信号 - let mut sigterm = signal(SignalKind::terminate())?; - let mut sigint = signal(SignalKind::interrupt())?; - tokio::select! { - _ = tokio::signal::ctrl_c() => { - eprintln!("Ctrl-C received, starting shutdown"); - notify_systemd("stopping"); - } - - _ = sigint.recv() => { - info!("SIGINT received, starting shutdown"); - notify_systemd("stopping"); - } - _ = sigterm.recv() => { - info!("SIGTERM received, starting shutdown"); - notify_systemd("stopping"); + // Perform hibernation for 1 second + tokio::time::sleep(SHUTDOWN_TIMEOUT).await; + // listen to the shutdown signal + match wait_for_shutdown().await { + ShutdownSignal::CtrlC | ShutdownSignal::Sigint | ShutdownSignal::Sigterm => { + info!("Shutdown signal received in main thread"); + // update the status to stopping first + state_manager.update(ServiceState::Stopping); + info!("Server is stopping..."); + let _ = shutdown_tx.send(()); + // Wait for the worker thread to complete the cleaning work + tokio::time::sleep(SHUTDOWN_TIMEOUT).await; + // the last updated status is stopped + state_manager.update(ServiceState::Stopped); + info!("Server stopped current "); } } - info!("server is stopped"); + info!("server is stopped state: {:?}", state_manager.current_state()); Ok(()) } - -// #[allow(dead_code)] -// #[derive(Debug)] -// enum ShutdownSignal { -// CtrlC, -// Sigterm, -// Sigint, -// } -// #[allow(dead_code)] -// async fn wait_for_shutdown() -> ShutdownSignal { -// let mut sigterm = signal(SignalKind::terminate()).unwrap(); -// let mut sigint = signal(SignalKind::interrupt()).unwrap(); -// -// tokio::select! { -// _ = tokio::signal::ctrl_c() => { -// info!("Received Ctrl-C signal"); -// ShutdownSignal::CtrlC -// } -// _ = sigint.recv() => { -// info!("Received SIGINT signal"); -// ShutdownSignal::Sigint -// } -// _ = sigterm.recv() => { -// info!("Received SIGTERM signal"); -// ShutdownSignal::Sigterm -// } -// } -// } -// #[allow(dead_code)] -// #[derive(Debug)] -// enum ServiceState { -// Starting, -// Ready, -// Stopping, -// Stopped, -// } -// #[allow(dead_code)] -// fn notify_service_state(state: ServiceState) { -// match state { -// ServiceState::Starting => { -// info!("Service is starting..."); -// #[cfg(target_os = "linux")] -// if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...")]) { -// error!("Failed to notify systemd of starting state: {}", e); -// } -// } -// ServiceState::Ready => { -// info!("Service is ready"); -// notify_systemd("ready"); -// } -// ServiceState::Stopping => { -// info!("Service is stopping..."); -// notify_systemd("stopping"); -// } -// ServiceState::Stopped => { -// info!("Service has stopped"); -// #[cfg(target_os = "linux")] -// if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped")]) { -// error!("Failed to notify systemd of stopped state: {}", e); -// } -// } -// } -// } diff --git a/rustfs/src/server/mod.rs b/rustfs/src/server/mod.rs new file mode 100644 index 000000000..b1c764a18 --- /dev/null +++ b/rustfs/src/server/mod.rs @@ -0,0 +1,6 @@ +mod service_state; +pub(crate) use service_state::wait_for_shutdown; +pub(crate) use service_state::ServiceState; +pub(crate) use service_state::ServiceStateManager; +pub(crate) use service_state::ShutdownSignal; +pub(crate) use service_state::SHUTDOWN_TIMEOUT; diff --git a/rustfs/src/server/service_state.rs b/rustfs/src/server/service_state.rs new file mode 100644 index 000000000..e1d03c8a4 --- /dev/null +++ b/rustfs/src/server/service_state.rs @@ -0,0 +1,152 @@ +use atomic_enum::atomic_enum; +use std::sync::atomic::Ordering; +use std::sync::Arc; +use std::time::Duration; +use tokio::signal::unix::{signal, SignalKind}; +use tracing::info; + +// a configurable shutdown timeout +pub(crate) const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(1); + +#[cfg(target_os = "linux")] +fn notify_systemd(state: &str) { + use libsystemd::daemon::{notify, NotifyState}; + use tracing::{debug, error}; + let notify_state = match state { + "ready" => NotifyState::Ready, + "stopping" => NotifyState::Stopping, + _ => { + info!("Unsupported state passed to notify_systemd: {}", state); + return; + } + }; + + if let Err(e) = notify(false, &[notify_state]) { + error!("Failed to notify systemd: {}", e); + } else { + debug!("Successfully notified systemd: {}", state); + } + info!("Systemd notifications are enabled on linux (state: {})", state); +} + +#[cfg(not(target_os = "linux"))] +fn notify_systemd(state: &str) { + info!("Systemd notifications are not available on this platform not linux (state: {})", state); +} + +#[derive(Debug)] +pub enum ShutdownSignal { + CtrlC, + Sigterm, + Sigint, +} + +#[atomic_enum] +#[derive(PartialEq)] +pub(crate) enum ServiceState { + Starting, + Ready, + Stopping, + Stopped, +} + +pub(crate) async fn wait_for_shutdown() -> ShutdownSignal { + let mut sigterm = signal(SignalKind::terminate()).expect("failed to create SIGTERM signal handler"); + let mut sigint = signal(SignalKind::interrupt()).expect("failed to create SIGINT signal handler"); + + tokio::select! { + _ = tokio::signal::ctrl_c() => { + info!("Received Ctrl-C signal"); + ShutdownSignal::CtrlC + } + _ = sigint.recv() => { + info!("Received SIGINT signal"); + ShutdownSignal::Sigint + } + _ = sigterm.recv() => { + info!("Received SIGTERM signal"); + ShutdownSignal::Sigterm + } + } +} + +#[derive(Clone)] +pub(crate) struct ServiceStateManager { + state: Arc, +} + +impl ServiceStateManager { + pub fn new() -> Self { + Self { + state: Arc::new(AtomicServiceState::new(ServiceState::Starting)), + } + } + + pub fn update(&self, new_state: ServiceState) { + self.state.store(new_state, Ordering::SeqCst); + self.notify_systemd(&new_state); + } + + pub fn current_state(&self) -> ServiceState { + self.state.load(Ordering::SeqCst) + } + + fn notify_systemd(&self, state: &ServiceState) { + match state { + ServiceState::Starting => { + info!("Service is starting..."); + #[cfg(target_os = "linux")] + if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...")]) { + tracing::error!("Failed to notify systemd of starting state: {}", e); + } + } + ServiceState::Ready => { + info!("Service is ready"); + notify_systemd("ready"); + } + ServiceState::Stopping => { + info!("Service is stopping..."); + notify_systemd("stopping"); + } + ServiceState::Stopped => { + info!("Service has stopped"); + #[cfg(target_os = "linux")] + if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped")]) { + tracing::error!("Failed to notify systemd of stopped state: {}", e); + } + } + } + } +} + +impl Default for ServiceStateManager { + fn default() -> Self { + Self::new() + } +} + +// 使用示例 +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_service_state_manager() { + let manager = ServiceStateManager::new(); + + // 初始状态应该是 Starting + assert_eq!(manager.current_state(), ServiceState::Starting); + + // 更新状态到 Ready + manager.update(ServiceState::Ready); + assert_eq!(manager.current_state(), ServiceState::Ready); + + // 更新状态到 Stopping + manager.update(ServiceState::Stopping); + assert_eq!(manager.current_state(), ServiceState::Stopping); + + // 更新状态到 Stopped + manager.update(ServiceState::Stopped); + assert_eq!(manager.current_state(), ServiceState::Stopped); + } +} diff --git a/scripts/run.sh b/scripts/run.sh index 37e703f96..538c8652a 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -33,8 +33,27 @@ export RUSTFS_CONSOLE_ENABLE=true export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" # export RUSTFS_SERVER_DOMAINS="localhost:9000" -# 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 -export RUSTFS_OBS_CONFIG="./config/obs.example.toml" +# 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 其中`RUSTFS_OBS_CONFIG` 和下面变量二选一 +export RUSTFS_OBS_CONFIG="./deploy/config/obs.example.toml" + +# 如下变量需要必须参数都有值才可以,以及会覆盖配置文件中的值 +export RUSTFS__OBSERVABILITY__ENDPOINT=http://localhost:43178 +export RUSTFS__OBSERVABILITY__USE_STDOUT=true +export RUSTFS__OBSERVABILITY__SAMPLE_RATIO=2.0 +export RUSTFS__OBSERVABILITY__METER_INTERVAL=30 +export RUSTFS__OBSERVABILITY__SERVICE_NAME=rustfs +export RUSTFS__OBSERVABILITY__SERVICE_VERSION=0.1.0 +export RUSTFS__OBSERVABILITY__ENVIRONMENT=develop +export RUSTFS__OBSERVABILITY__LOGGER_LEVEL=info +export RUSTFS__SINKS__FILE__ENABLED=true +export RUSTFS__SINKS__FILE__PATH="./deploy/logs/app.log" +export RUSTFS__SINKS__WEBHOOK__ENABLED=false +export RUSTFS__SINKS__WEBHOOK__ENDPOINT="" +export RUSTFS__SINKS__WEBHOOK__AUTH_TOKEN="" +export RUSTFS__SINKS__KAFKA__ENABLED=false +export RUSTFS__SINKS__KAFKA__BOOTSTRAP_SERVERS="" +export RUSTFS__SINKS__KAFKA__TOPIC="" +export RUSTFS__LOGGER__QUEUE_CAPACITY=10 if [ -n "$1" ]; then export RUSTFS_VOLUMES="$1" From 24d6c555f74120bd77b65074943f65fee193f14f Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 17:38:44 +0800 Subject: [PATCH 092/103] Remove unused `crate` --- Cargo.lock | 24 ------------------------ Cargo.toml | 2 -- crates/obs/src/config.rs | 6 +++--- rustfs/Cargo.toml | 15 --------------- rustfs/src/main.rs | 27 ++------------------------- 5 files changed, 5 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c086a05e..70715fbce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7179,7 +7179,6 @@ dependencies = [ "common", "const-str", "crypto", - "csv", "datafusion", "ecstore", "flatbuffers", @@ -7190,7 +7189,6 @@ dependencies = [ "hyper", "hyper-util", "iam", - "jsonwebtoken", "lazy_static", "libsystemd", "local-ip-address", @@ -7200,13 +7198,9 @@ dependencies = [ "mime", "mime_guess", "netif", - "once_cell", "pin-project-lite", "policy", - "prost", "prost-build", - "prost-types", - "protobuf 3.7.2", "protos", "query", "rmp-serde", @@ -7227,15 +7221,10 @@ dependencies = [ "tokio-util", "tonic 0.13.0", "tonic-build", - "tonic-reflection", "tower 0.5.2", "tower-http", "tracing", - "tracing-core", - "tracing-error", - "tracing-subscriber", "transform-stream", - "url", "uuid", ] @@ -8594,19 +8583,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "tonic-reflection" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88fa815be858816dad226a49439ee90b7bcf81ab55bee72fdb217f1e6778c3ca" -dependencies = [ - "prost", - "prost-types", - "tokio", - "tokio-stream", - "tonic 0.13.0", -] - [[package]] name = "tower" version = "0.4.13" diff --git a/Cargo.toml b/Cargo.toml index b48e74cad..622157666 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,6 @@ matchit = "0.8.4" md-5 = "0.10.6" mime = "0.3.17" netif = "0.1.6" -once_cell = "1.21.1" opentelemetry = { version = "0.29.1" } opentelemetry-appender-tracing = { version = "0.29.1", features = ["experimental_use_tracing_span_context", "experimental_metadata_attributes"] } opentelemetry_sdk = { version = "0.29" } @@ -123,7 +122,6 @@ time = { version = "0.3.41", features = [ tokio = { version = "1.44.2", features = ["fs", "rt-multi-thread"] } tonic = { version = "0.13.0", features = ["gzip"] } tonic-build = "0.13.0" -tonic-reflection = "0.13.0" tokio-rustls = { version = "0.26", default-features = false } tokio-stream = "0.1.17" tokio-util = { version = "0.7.13", features = ["io", "compat"] } diff --git a/crates/obs/src/config.rs b/crates/obs/src/config.rs index c7d3ff7d5..a9e620161 100644 --- a/crates/obs/src/config.rs +++ b/crates/obs/src/config.rs @@ -117,7 +117,7 @@ impl Default for FileSinkConfig { path: env::var("RUSTFS_SINKS_FILE_PATH") .ok() .filter(|s| !s.trim().is_empty()) - .unwrap_or_else(|| Self::get_default_log_path()), + .unwrap_or_else(Self::get_default_log_path), buffer_size: Some(8192), flush_interval_ms: Some(1000), flush_threshold: Some(100), @@ -244,7 +244,7 @@ pub fn load_config(config_dir: Option) -> AppConfig { // Log using proper logging instead of println when possible println!("Using config file base: {}", config_dir); - let config = Config::builder() + let app_config = Config::builder() .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Toml).required(false)) .add_source(File::with_name(config_dir.as_str()).format(FileFormat::Yaml).required(false)) .add_source( @@ -258,7 +258,7 @@ pub fn load_config(config_dir: Option) -> AppConfig { .build() .unwrap_or_default(); - match config.try_deserialize::() { + match app_config.try_deserialize::() { Ok(app_config) => { println!("Parsed AppConfig: {:?}", app_config); app_config diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 63e8b7a4d..127798d45 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -27,7 +27,6 @@ async-trait.workspace = true bytes.workspace = true chrono = { workspace = true } clap.workspace = true -csv = "1.3.1" crypto = { path = "../crypto" } datafusion = { workspace = true } common.workspace = true @@ -37,26 +36,18 @@ policy.workspace = true flatbuffers.workspace = true futures.workspace = true futures-util.workspace = true -#h2 = "0.4.7" hyper.workspace = true hyper-util.workspace = true http.workspace = true http-body.workspace = true iam = { path = "../iam" } -jsonwebtoken = "9.3.0" - lock.workspace = true local-ip-address = { workspace = true } matchit = { workspace = true } mime.workspace = true mime_guess = "2.0.5" -netif.workspace = true -once_cell.workspace = true pin-project-lite.workspace = true -prost.workspace = true -prost-types.workspace = true protos.workspace = true -protobuf.workspace = true query = { path = "../s3select/query" } rmp-serde.workspace = true rustfs-obs = { workspace = true } @@ -82,14 +73,9 @@ tokio-rustls.workspace = true lazy_static.workspace = true tokio-stream.workspace = true tonic = { workspace = true } -tonic-reflection.workspace = true tower.workspace = true -tracing-core = { workspace = true } -tracing-error.workspace = true -tracing-subscriber.workspace = true transform-stream.workspace = true tower-http.workspace = true -url.workspace = true uuid = "1.15.1" [target.'cfg(target_os = "linux")'.dependencies] @@ -106,7 +92,6 @@ futures-util.workspace = true ecstore = { path = "../ecstore" } s3s.workspace = true clap = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter", "time"] } hyper-util = { workspace = true, features = [ "tokio", "server-auto", diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 943809904..c0ca34995 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -45,37 +45,14 @@ use rustfs_obs::{init_obs, load_config, set_global_guard, InitLogStatus}; use rustls::ServerConfig; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; use service::hybrid; +use std::net::SocketAddr; use std::sync::Arc; -use std::time::Duration; -use std::{io::IsTerminal, net::SocketAddr}; use tokio::net::TcpListener; use tokio::signal::unix::{signal, SignalKind}; use tokio_rustls::TlsAcceptor; use tonic::{metadata::MetadataValue, Request, Status}; use tower_http::cors::CorsLayer; -use tracing::log::warn; -use tracing::{debug, error, info, info_span}; -use tracing_error::ErrorLayer; -use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; - -#[allow(dead_code)] -fn setup_tracing() { - use tracing_subscriber::EnvFilter; - - let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")); - let enable_color = std::io::stdout().is_terminal(); - - let subscriber = tracing_subscriber::fmt::fmt() - .pretty() - .with_env_filter(env_filter) - .with_ansi(enable_color) - .with_file(true) - .with_line_number(true) - .finish() - .with(ErrorLayer::default()); - - subscriber.try_init().expect("failed to set global default subscriber"); -} +use tracing::{debug, error, info, info_span, warn}; fn check_auth(req: Request<()>) -> Result, Status> { let token: MetadataValue<_> = "rustfs rpc".parse().unwrap(); From c3a17caa80dd6ee6e009ecdda1c8af4266c54d9a Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 17:45:59 +0800 Subject: [PATCH 093/103] Update crates/obs/src/sink.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- crates/obs/src/sink.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/obs/src/sink.rs b/crates/obs/src/sink.rs index a92a980a7..4df212b31 100644 --- a/crates/obs/src/sink.rs +++ b/crates/obs/src/sink.rs @@ -273,7 +273,7 @@ impl FileSink { // if the file not exists, create it if !file_exists { tokio::fs::create_dir_all(std::path::Path::new(&path).parent().unwrap()).await?; - tracing::debug!("the file not exists,create if. path: {:?}", path) + tracing::debug!("File does not exist, creating it. Path: {:?}", path) } let file = if file_exists { // If the file exists, open it in append mode From 33a0b9669c6e74941121fa030968cbfdf03243a6 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 20:02:51 +0800 Subject: [PATCH 094/103] fix systemd notice --- rustfs/src/server/service_state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rustfs/src/server/service_state.rs b/rustfs/src/server/service_state.rs index e1d03c8a4..d27296e35 100644 --- a/rustfs/src/server/service_state.rs +++ b/rustfs/src/server/service_state.rs @@ -96,7 +96,7 @@ impl ServiceStateManager { ServiceState::Starting => { info!("Service is starting..."); #[cfg(target_os = "linux")] - if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...")]) { + if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Starting...".to_string())]) { tracing::error!("Failed to notify systemd of starting state: {}", e); } } @@ -111,7 +111,7 @@ impl ServiceStateManager { ServiceState::Stopped => { info!("Service has stopped"); #[cfg(target_os = "linux")] - if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped")]) { + if let Err(e) = libsystemd::daemon::notify(false, &[libsystemd::daemon::NotifyState::Status("Stopped".to_string())]) { tracing::error!("Failed to notify systemd of stopped state: {}", e); } } From 37109fc6184e0b399294262b5304deff7bf1c319 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 20:53:51 +0800 Subject: [PATCH 095/103] upgrade crate version --- Cargo.lock | 103 ++++++++++++++++++-------------------- Cargo.toml | 45 +++++++++-------- crypto/Cargo.toml | 2 +- ecstore/Cargo.toml | 4 +- iam/Cargo.toml | 2 +- policy/Cargo.toml | 2 +- rustfs/Cargo.toml | 2 +- s3select/query/Cargo.toml | 4 +- 8 files changed, 79 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70715fbce..2d5492c48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "backon" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970d91570c01a8a5959b36ad7dd1c30642df24b6b3068710066f6809f7033bb7" +checksum = "fd0b50b1b78dbadd44ab18b3c794e496f3a139abb9fbc27d9c94c4eebbb96496" dependencies = [ "fastrand", "gloo-timers", @@ -923,9 +923,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34a796731680be7931955498a16a10b2270c7762963d5d570fdbfe02dcbf314f" +checksum = "389a099b34312839e16420d499a9cad9650541715937ffbdd40d36f49e77eeb3" dependencies = [ "arrayref", "arrayvec", @@ -1089,9 +1089,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.17" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" dependencies = [ "jobserver", "libc", @@ -1426,7 +1426,7 @@ dependencies = [ "serde", "serde_json", "toml", - "winnow 0.7.4", + "winnow 0.7.6", "yaml-rust2", ] @@ -1448,9 +1448,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const-oid" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cb3c4a0d3776f7535c32793be81d6d5fec0d48ac70955d9834e643aa249a52f" +checksum = "0dabb6555f92fb9ee4140454eb5dcd14c7960e1225c6d1a6cc361f032947713e" [[package]] name = "const-random" @@ -1681,9 +1681,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ "crossbeam-utils", ] @@ -2379,9 +2379,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", "serde", @@ -2450,7 +2450,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c478574b20020306f98d61c8ca3322d762e1ff08117422ac6106438605ea516" dependencies = [ "block-buffer 0.11.0-rc.4", - "const-oid 0.10.0", + "const-oid 0.10.1", "crypto-common 0.2.0-rc.2", "subtle", ] @@ -3180,9 +3180,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys 0.59.0", @@ -3860,9 +3860,9 @@ dependencies = [ [[package]] name = "half" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7db2ff139bba50379da6aa0766b52fdcb62cb5b263009b09ed58ba604e14bbd1" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" dependencies = [ "cfg-if", "crunchy", @@ -4790,9 +4790,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "litemap" @@ -5033,9 +5033,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", "simd-adler32", @@ -5668,15 +5668,14 @@ dependencies = [ [[package]] name = "opentelemetry-prometheus" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ac8c4fc7bd450bcb5b1cbc7325755e86d9f82f1fd80ad8b3441887b715f6a2d" +checksum = "098a71a4430bb712be6130ed777335d2e5b19bc8566de5f2edddfce906def6ab" dependencies = [ "once_cell", "opentelemetry", "opentelemetry_sdk", "prometheus", - "protobuf 2.28.0", "tracing", ] @@ -5851,7 +5850,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.10", + "redox_syscall 0.5.11", "smallvec", "windows-targets 0.52.6", ] @@ -6351,9 +6350,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" dependencies = [ "proc-macro2", "syn 2.0.100", @@ -6440,17 +6439,17 @@ dependencies = [ [[package]] name = "prometheus" -version = "0.13.4" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d33c28a30771f7f96db69893f78b857f7450d7e0237e9c8fc6427a81bae7ed1" +checksum = "3ca5326d8d0b950a9acd87e6a3f94745394f62e4dae1b1ee22b2bc0c394af43a" dependencies = [ "cfg-if", "fnv", "lazy_static", "memchr", "parking_lot 0.12.3", - "protobuf 2.28.0", - "thiserror 1.0.69", + "protobuf", + "thiserror 2.0.12", ] [[package]] @@ -6505,12 +6504,6 @@ dependencies = [ "prost", ] -[[package]] -name = "protobuf" -version = "2.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" - [[package]] name = "protobuf" version = "3.7.2" @@ -6539,7 +6532,7 @@ dependencies = [ "flatbuffers", "prost", "prost-build", - "protobuf 3.7.2", + "protobuf", "tokio", "tonic 0.13.0", "tonic-build", @@ -6835,9 +6828,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags 2.9.0", ] @@ -7090,9 +7083,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "8.6.0" +version = "8.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b3aba5104622db5c9fc61098de54708feb732e7763d7faa2fa625899f00bf6f" +checksum = "e5fbc0ee50fcb99af7cebb442e5df7b5b45e9460ffa3f8f549cd26b862bec49d" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -7101,9 +7094,9 @@ dependencies = [ [[package]] name = "rust-embed-impl" -version = "8.6.0" +version = "8.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f198c73be048d2c5aa8e12f7960ad08443e56fd39cc26336719fdb4ea0ebaae" +checksum = "6bf418c9a2e3f6663ca38b8a7134cc2c2167c9d69688860e8961e3faa731702e" dependencies = [ "proc-macro2", "quote", @@ -7115,9 +7108,9 @@ dependencies = [ [[package]] name = "rust-embed-utils" -version = "8.6.0" +version = "8.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a2fcdc9f40c8dc2922842ca9add611ad19f332227fc651d015881ad1552bd9a" +checksum = "08d55b95147fe01265d06b3955db798bdaed52e60e2211c41137701b3aba8e21" dependencies = [ "sha2 0.10.8", "walkdir", @@ -7299,7 +7292,7 @@ dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.9.3", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] @@ -8509,7 +8502,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.7.4", + "winnow 0.7.6", ] [[package]] @@ -9767,9 +9760,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10" dependencies = [ "memchr", ] @@ -9981,7 +9974,7 @@ dependencies = [ "tracing", "uds_windows", "windows-sys 0.59.0", - "winnow 0.7.4", + "winnow 0.7.6", "xdg-home", "zbus_macros 5.5.0", "zbus_names 4.2.0", @@ -10035,7 +10028,7 @@ checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" dependencies = [ "serde", "static_assertions", - "winnow 0.7.4", + "winnow 0.7.6", "zvariant 5.4.0", ] @@ -10181,7 +10174,7 @@ dependencies = [ "serde", "static_assertions", "url", - "winnow 0.7.4", + "winnow 0.7.6", "zvariant_derive 5.4.0", "zvariant_utils 3.2.0", ] @@ -10234,5 +10227,5 @@ dependencies = [ "serde", "static_assertions", "syn 2.0.100", - "winnow 0.7.4", + "winnow 0.7.6", ] diff --git a/Cargo.toml b/Cargo.toml index 622157666..0dc72ad96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,18 +34,18 @@ all = "warn" [workspace.dependencies] madmin = { path = "./madmin" } atoi = "2.0.0" -async-recursion = "1.0.5" -async-trait = "0.1.87" +async-recursion = "1.1.1" +async-trait = "0.1.88" atomic_enum = "0.3.0" axum = "0.8.3" axum-extra = "0.10.1" axum-server = { version = "0.7.2", features = ["tls-rustls"] } -backon = "1.3.0" -bytes = "1.9.0" -bytesize = "1.3.0" +backon = "1.5.0" +bytes = "1.10.1" +bytesize = "1.3.3" chrono = { version = "0.4.40", features = ["serde"] } clap = { version = "4.5.35", features = ["derive", "env"] } -config = "0.15.9" +config = "0.15.11" datafusion = "46.0.0" derive_builder = "0.20.2" dioxus = { version = "0.6.3", features = ["router"] } @@ -63,10 +63,11 @@ hyper-util = { version = "0.1.11", features = [ "server-auto", "server-graceful", ] } -http = "1.2.0" +http = "1.3.1" http-body = "1.0.1" -humantime = "2.1.0" -keyring = { version = "3.6.1", features = ["apple-native", "windows-native", "sync-secret-service"] } +humantime = "2.2.0" +jsonwebtoken = "9.3.1" +keyring = { version = "3.6.2", features = ["apple-native", "windows-native", "sync-secret-service"] } lock = { path = "./common/lock" } lazy_static = "1.5.0" libsystemd = { version = "0.7" } @@ -80,36 +81,36 @@ opentelemetry-appender-tracing = { version = "0.29.1", features = ["experimental opentelemetry_sdk = { version = "0.29" } opentelemetry-stdout = { version = "0.29.0" } opentelemetry-otlp = { version = "0.29" } -opentelemetry-prometheus = { version = "0.29" } +opentelemetry-prometheus = { version = "0.29.1" } opentelemetry-semantic-conventions = { version = "0.29.0", features = ["semconv_experimental"] } pin-project-lite = "0.2" -prometheus = "0.13.4" +prometheus = "0.14.0" # pin-utils = "0.1.0" -prost = "0.13.4" -prost-build = "0.13.4" -prost-types = "0.13.4" +prost = "0.13.5" +prost-build = "0.13.5" +prost-types = "0.13.5" protobuf = "3.7" protos = { path = "./common/protos" } rand = "0.8.5" rdkafka = { version = "0.37", features = ["tokio"] } reqwest = { version = "0.12.15", default-features = false, features = ["rustls-tls", "charset", "http2", "macos-system-configuration", "stream", "json", "blocking"] } -rfd = { version = "0.15.2", default-features = false, features = ["xdg-portal", "tokio"] } +rfd = { version = "0.15.3", default-features = false, features = ["xdg-portal", "tokio"] } rmp = "0.8.14" rmp-serde = "1.3.0" rustfs-obs = { path = "crates/obs", version = "0.0.1" } -rust-embed = "8.6.0" +rust-embed = "8.7.0" rustls = { version = "0.23.26" } rustls-pki-types = "1.11.0" rustls-pemfile = "2.2.0" s3s = { git = "https://github.com/Nugine/s3s.git", rev = "3ad13ace7af703c3c8afc99cf19f4c18c82603a3" } s3s-policy = { git = "https://github.com/Nugine/s3s.git", rev = "3ad13ace7af703c3c8afc99cf19f4c18c82603a3" } -shadow-rs = { version = "0.38.0", default-features = false } -serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.138" +shadow-rs = { version = "0.38.1", default-features = false } +serde = { version = "1.0.219", features = ["derive"] } +serde_json = "1.0.140" serde_urlencoded = "0.7.1" sha2 = "0.10.8" snafu = "0.8.5" -tempfile = "3.16.0" +tempfile = "3.19.1" test-case = "3.3.1" thiserror = "2.0.12" time = { version = "0.3.41", features = [ @@ -124,7 +125,7 @@ tonic = { version = "0.13.0", features = ["gzip"] } tonic-build = "0.13.0" tokio-rustls = { version = "0.26", default-features = false } tokio-stream = "0.1.17" -tokio-util = { version = "0.7.13", features = ["io", "compat"] } +tokio-util = { version = "0.7.14", features = ["io", "compat"] } tower = { version = "0.5.2", features = ["timeout"] } tower-http = { version = "0.6.2", features = ["cors"] } tracing = "0.1.41" @@ -135,7 +136,7 @@ tracing-appender = "0.2.3" tracing-opentelemetry = "0.30" transform-stream = "0.3.1" url = "2.5.4" -uuid = { version = "1.15.1", features = [ +uuid = { version = "1.16.0", features = [ "v4", "fast-rng", "macro-diagnostics", diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index c28bf7006..5b0f58969 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -14,7 +14,7 @@ aes-gcm = { version = "0.10.3", features = ["std"], optional = true } argon2 = { version = "0.5.3", features = ["std"], optional = true } cfg-if = "1.0.0" chacha20poly1305 = { version = "0.10.1", optional = true } -jsonwebtoken = "9.3.0" +jsonwebtoken = { workspace = true } pbkdf2 = { version = "0.12.2", optional = true } rand = { workspace = true, optional = true } sha2 = { version = "0.10.8", optional = true } diff --git a/ecstore/Cargo.toml b/ecstore/Cargo.toml index 4f822c038..a57bdcd50 100644 --- a/ecstore/Cargo.toml +++ b/ecstore/Cargo.toml @@ -32,7 +32,7 @@ s3s.workspace = true http.workspace = true highway = "1.3.0" url.workspace = true -uuid = { version = "1.15.1", features = ["v4", "fast-rng", "serde"] } +uuid = { workspace = true, features = ["v4", "fast-rng", "serde"] } reed-solomon-erasure = { version = "6.0.0", features = ["simd-accel"] } transform-stream = "0.3.1" lazy_static.workspace = true @@ -44,7 +44,7 @@ path-absolutize = "3.1.1" protos.workspace = true rmp.workspace = true rmp-serde.workspace = true -tokio-util = { version = "0.7.13", features = ["io", "compat"] } +tokio-util = { workspace = true, features = ["io", "compat"] } crc32fast = "1.4.2" siphasher = "1.0.1" base64-simd = "0.8.0" diff --git a/iam/Cargo.toml b/iam/Cargo.toml index fce678b66..982df57e1 100644 --- a/iam/Cargo.toml +++ b/iam/Cargo.toml @@ -26,7 +26,7 @@ itertools = "0.14.0" futures.workspace = true rand.workspace = true base64-simd = "0.8.0" -jsonwebtoken = "9.3.0" +jsonwebtoken = { workspace = true } tracing.workspace = true madmin.workspace = true lazy_static.workspace = true diff --git a/policy/Cargo.toml b/policy/Cargo.toml index 56e33d725..87f11b2ce 100644 --- a/policy/Cargo.toml +++ b/policy/Cargo.toml @@ -24,7 +24,7 @@ itertools = "0.14.0" futures.workspace = true rand.workspace = true base64-simd = "0.8.0" -jsonwebtoken = "9.3.0" +jsonwebtoken = { workspace = true } tracing.workspace = true madmin.workspace = true lazy_static.workspace = true diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 127798d45..cf59da3e4 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -76,7 +76,7 @@ tonic = { workspace = true } tower.workspace = true transform-stream.workspace = true tower-http.workspace = true -uuid = "1.15.1" +uuid = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] libsystemd.workspace = true diff --git a/s3select/query/Cargo.toml b/s3select/query/Cargo.toml index 61b0b07b9..8d9b159c2 100644 --- a/s3select/query/Cargo.toml +++ b/s3select/query/Cargo.toml @@ -10,8 +10,8 @@ async-trait.workspace = true datafusion = { workspace = true } derive_builder = { workspace = true } futures = { workspace = true } -parking_lot = { version = "0.12.1" } +parking_lot = { version = "0.12.3" } s3s.workspace = true snafu = { workspace = true, features = ["backtrace"] } tokio = { workspace = true } -tracing = { workspace = true } \ No newline at end of file +tracing = { workspace = true } From e90bae35b94079710e5a820946fa97a2ef0815b7 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 21:44:23 +0800 Subject: [PATCH 096/103] upgrade protobuf download link and improve code for readme.md --- .docker/Dockerfile.devenv | 8 +++--- .docker/Dockerfile.rockylinux9.3 | 8 +++--- .docker/Dockerfile.ubuntu22.04 | 8 +++--- README.md | 46 ++++++++++++++++++++++--------- deploy/build/rustfs-zh.service | 1 + deploy/build/rustfs.service | 1 + deploy/config/.example.env | 2 +- deploy/config/obs-zh.example.toml | 2 +- deploy/config/obs.example.toml | 2 +- scripts/run.ps1 | 2 +- scripts/run.sh | 4 +-- 11 files changed, 53 insertions(+), 31 deletions(-) diff --git a/.docker/Dockerfile.devenv b/.docker/Dockerfile.devenv index de2fcb499..1e3916af8 100644 --- a/.docker/Dockerfile.devenv +++ b/.docker/Dockerfile.devenv @@ -7,12 +7,12 @@ RUN sed -i s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g /etc/apt/ RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev -y # install protoc -RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip \ - && unzip protoc-27.0-linux-x86_64.zip -d protoc3 \ - && mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-27.0-linux-x86_64.zip protoc3 +RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip \ + && unzip protoc-30.2-linux-x86_64.zip -d protoc3 \ + && mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-30.2-linux-x86_64.zip protoc3 # install flatc -RUN wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip \ +RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \ && unzip Linux.flatc.binary.g++-13.zip \ && mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip diff --git a/.docker/Dockerfile.rockylinux9.3 b/.docker/Dockerfile.rockylinux9.3 index 340b84191..eb3a25d72 100644 --- a/.docker/Dockerfile.rockylinux9.3 +++ b/.docker/Dockerfile.rockylinux9.3 @@ -13,13 +13,13 @@ RUN dnf makecache RUN yum install wget git unzip gcc openssl-devel pkgconf-pkg-config -y # install protoc -RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip \ - && unzip protoc-27.0-linux-x86_64.zip -d protoc3 \ +RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip \ + && unzip protoc-30.2-linux-x86_64.zip -d protoc3 \ && mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc \ - && rm -rf protoc-27.0-linux-x86_64.zip protoc3 + && rm -rf protoc-30.2-linux-x86_64.zip protoc3 # install flatc -RUN wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip \ +RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \ && unzip Linux.flatc.binary.g++-13.zip \ && mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc \ && rm -rf Linux.flatc.binary.g++-13.zip diff --git a/.docker/Dockerfile.ubuntu22.04 b/.docker/Dockerfile.ubuntu22.04 index b955de8e8..e8f715209 100644 --- a/.docker/Dockerfile.ubuntu22.04 +++ b/.docker/Dockerfile.ubuntu22.04 @@ -7,12 +7,12 @@ RUN sed -i s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g /etc/apt/ RUN apt-get clean && apt-get update && apt-get install wget git curl unzip gcc pkg-config libssl-dev lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev -y # install protoc -RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip \ - && unzip protoc-27.0-linux-x86_64.zip -d protoc3 \ - && mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-27.0-linux-x86_64.zip protoc3 +RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip \ + && unzip protoc-30.2-linux-x86_64.zip -d protoc3 \ + && mv protoc3/bin/* /usr/local/bin/ && chmod +x /usr/local/bin/protoc && mv protoc3/include/* /usr/local/include/ && rm -rf protoc-30.2-linux-x86_64.zip protoc3 # install flatc -RUN wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip \ +RUN wget https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip \ && unzip Linux.flatc.binary.g++-13.zip \ && mv flatc /usr/local/bin/ && chmod +x /usr/local/bin/flatc && rm -rf Linux.flatc.binary.g++-13.zip diff --git a/README.md b/README.md index 9882ae927..a93f91055 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # How to compile RustFS -| Must package | Version | -|--------------|---------| -| Rust | 1.8.5 | -| protoc | 27.0 | -| flatc | 24.0+ | +| Must package | Version | download link | +|--------------|---------|----------------------------------------------------------------------------------------------------------------------------------| +| Rust | 1.8.5 | https://www.rust-lang.org/tools/install | +| protoc | 30.2 | [protoc-30.2-linux-x86_64.zip](https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip) | +| flatc | 24.0+ | [Linux.flatc.binary.g++-13.zip](https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip) | Download Links: -https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip +https://github.com/google/flatbuffers/releases/download/v25.2.10/Linux.flatc.binary.g++-13.zip -https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip +https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2-linux-x86_64.zip Or use Docker: @@ -24,8 +24,7 @@ Or use Docker: # How to add Console web -1. -wget [http://dl.rustfs.com/console/console.latest.tar.gz](https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip) +1. `wget https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip` 2. mkdir in this repos folder `./rustfs/static` @@ -36,12 +35,31 @@ wget [http://dl.rustfs.com/console/console.latest.tar.gz](https://dl.rustfs.com/ Add Env infomation: ``` -export RUST_LOG="rustfs=debug,ecstore=debug,s3s=debug,iam=debug" export RUSTFS_VOLUMES="./target/volume/test" export RUSTFS_ADDRESS="0.0.0.0:9000" export RUSTFS_CONSOLE_ENABLE=true export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9001" -export RUSTFS_OBS_CONFIG="config/obs.toml" +# 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 其中`RUSTFS_OBS_CONFIG` 和下面变量二选一 +export RUSTFS_OBS_CONFIG="./deploy/config/obs.example.toml" + +# 如下变量需要必须参数都有值才可以,以及会覆盖配置文件`obs.example.toml`中的值 +export RUSTFS__OBSERVABILITY__ENDPOINT=http://localhost:4317 +export RUSTFS__OBSERVABILITY__USE_STDOUT=true +export RUSTFS__OBSERVABILITY__SAMPLE_RATIO=2.0 +export RUSTFS__OBSERVABILITY__METER_INTERVAL=30 +export RUSTFS__OBSERVABILITY__SERVICE_NAME=rustfs +export RUSTFS__OBSERVABILITY__SERVICE_VERSION=0.1.0 +export RUSTFS__OBSERVABILITY__ENVIRONMENT=develop +export RUSTFS__OBSERVABILITY__LOGGER_LEVEL=info +export RUSTFS__SINKS__FILE__ENABLED=true +export RUSTFS__SINKS__FILE__PATH="./deploy/logs/rustfs.log" +export RUSTFS__SINKS__WEBHOOK__ENABLED=false +export RUSTFS__SINKS__WEBHOOK__ENDPOINT="" +export RUSTFS__SINKS__WEBHOOK__AUTH_TOKEN="" +export RUSTFS__SINKS__KAFKA__ENABLED=false +export RUSTFS__SINKS__KAFKA__BOOTSTRAP_SERVERS="" +export RUSTFS__SINKS__KAFKA__TOPIC="" +export RUSTFS__LOGGER__QUEUE_CAPACITY=10 ``` You need replace your real data folder: @@ -72,7 +90,7 @@ docker-compose -f docker-compose.yml up -d ## Create a new Observability configuration file -#### 1. Enter the `config` directory, +#### 1. Enter the `deploy/config` directory, #### 2. Copy `obs.toml.example` to `obs.toml` @@ -84,7 +102,7 @@ docker-compose -f docker-compose.yml up -d ##### 3.3. Modify the `service_version` value to the version of the service -##### 3.4. Modify the `deployment_environment` value to the environment of the service +##### 3.4. Modify the `environment` value to the environment of the service ##### 3.5. Modify the `meter_interval` value to export interval @@ -92,4 +110,6 @@ docker-compose -f docker-compose.yml up -d ##### 3.7. Modify the `use_stdout` value to export to stdout +##### 3.8. Modify the `logger_level` value to the logger level + diff --git a/deploy/build/rustfs-zh.service b/deploy/build/rustfs-zh.service index a2bc1a41d..a1cd0df05 100644 --- a/deploy/build/rustfs-zh.service +++ b/deploy/build/rustfs-zh.service @@ -47,6 +47,7 @@ ExecStart=/usr/local/bin/rustfs \ # --console-address 0.0.0.0:9002:控制台监听所有接口的 9002 端口。 # 定义环境变量配置,用于传递给服务程序,推荐使用且简洁 +# rustfs 示例文件 详见: `../config/rustfs-zh.env` EnvironmentFile=-/etc/default/rustfs ExecStart=/usr/local/bin/rustfs $RUSTFS_VOLUMES $RUSTFS_OPTS diff --git a/deploy/build/rustfs.service b/deploy/build/rustfs.service index e8c82de4c..df6e4067b 100644 --- a/deploy/build/rustfs.service +++ b/deploy/build/rustfs.service @@ -27,6 +27,7 @@ ExecStart=/usr/local/bin/rustfs \ --console-address 0.0.0.0:9002 # environment variable configuration (Option 2: Use environment variables) +# rustfs example file see: `../config/rustfs.env` EnvironmentFile=-/etc/default/rustfs ExecStart=/usr/local/bin/rustfs $RUSTFS_VOLUMES $RUSTFS_OPTS diff --git a/deploy/config/.example.env b/deploy/config/.example.env index 9db2f211f..a1ea67b4f 100644 --- a/deploy/config/.example.env +++ b/deploy/config/.example.env @@ -20,7 +20,7 @@ SINKS__WEBHOOK__BATCH_SIZE=100 SINKS__WEBHOOK__BATCH_TIMEOUT_MS=1000 SINKS__FILE__ENABLED=true -SINKS__FILE__PATH=./deploy/logs/app.log +SINKS__FILE__PATH=./deploy/logs/rustfs.log SINKS__FILE__BATCH_SIZE=10 SINKS__FILE__BATCH_TIMEOUT_MS=1000 diff --git a/deploy/config/obs-zh.example.toml b/deploy/config/obs-zh.example.toml index c3cbe8f60..2bf4260f8 100644 --- a/deploy/config/obs-zh.example.toml +++ b/deploy/config/obs-zh.example.toml @@ -25,7 +25,7 @@ batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 [sinks.file] # 文件接收器配置 enabled = true # 是否启用文件接收器 -path = "/Users/qun/Documents/rust/rustfs/s3-rustfs/logs/app.log" # 日志文件路径 +path = "./deploy/logs/rustfs.log" # 日志文件路径 batch_size = 10 # 批处理大小 batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 diff --git a/deploy/config/obs.example.toml b/deploy/config/obs.example.toml index e74c01c66..a3c3d0966 100644 --- a/deploy/config/obs.example.toml +++ b/deploy/config/obs.example.toml @@ -25,7 +25,7 @@ batch_timeout_ms = 1000 # Default is 100ms if not specified [sinks.file] enabled = true -path = "./deploy/logs/app.log" +path = "./deploy/logs/rustfs.log" batch_size = 100 batch_timeout_ms = 1000 # Default is 8192 bytes if not specified diff --git a/scripts/run.ps1 b/scripts/run.ps1 index a6ab92fb5..845ed020c 100644 --- a/scripts/run.ps1 +++ b/scripts/run.ps1 @@ -40,7 +40,7 @@ $env:RUSTFS_CONSOLE_ENABLE = "true" $env:RUSTFS_CONSOLE_ADDRESS = "127.0.0.1:9002" # $env:RUSTFS_SERVER_DOMAINS = "localhost:9000" # Change to the actual configuration file path, obs.example.toml is for reference only -$env:RUSTFS_OBS_CONFIG = ".\config\obs.example.toml" +$env:RUSTFS_OBS_CONFIG = ".\deploy\config\obs.example.toml" # Check command line arguments if ($args.Count -gt 0) { diff --git a/scripts/run.sh b/scripts/run.sh index 538c8652a..b2cb5c80c 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -37,7 +37,7 @@ export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" export RUSTFS_OBS_CONFIG="./deploy/config/obs.example.toml" # 如下变量需要必须参数都有值才可以,以及会覆盖配置文件中的值 -export RUSTFS__OBSERVABILITY__ENDPOINT=http://localhost:43178 +export RUSTFS__OBSERVABILITY__ENDPOINT=http://localhost:4317 export RUSTFS__OBSERVABILITY__USE_STDOUT=true export RUSTFS__OBSERVABILITY__SAMPLE_RATIO=2.0 export RUSTFS__OBSERVABILITY__METER_INTERVAL=30 @@ -46,7 +46,7 @@ export RUSTFS__OBSERVABILITY__SERVICE_VERSION=0.1.0 export RUSTFS__OBSERVABILITY__ENVIRONMENT=develop export RUSTFS__OBSERVABILITY__LOGGER_LEVEL=info export RUSTFS__SINKS__FILE__ENABLED=true -export RUSTFS__SINKS__FILE__PATH="./deploy/logs/app.log" +export RUSTFS__SINKS__FILE__PATH="./deploy/logs/rustfs.log" export RUSTFS__SINKS__WEBHOOK__ENABLED=false export RUSTFS__SINKS__WEBHOOK__ENDPOINT="" export RUSTFS__SINKS__WEBHOOK__AUTH_TOKEN="" From b3ee5c8d4fdb998310d70fc57bbff26f45aa4511 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 21:48:44 +0800 Subject: [PATCH 097/103] improve README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a93f91055..768b5eb23 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,15 @@ https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2- Or use Docker: +```yml - uses: arduino/setup-protoc@v3 with: - version: "27.0" + version: "30.2" - uses: Nugine/setup-flatc@v1 with: - version: "24.3.25" + version: "25.2.10" +``` # How to add Console web @@ -32,7 +34,7 @@ Or use Docker: # Star RustFS -Add Env infomation: +Add Env information: ``` export RUSTFS_VOLUMES="./target/volume/test" From 26f128df02a9dd1f49a2dd6023a6d7dd7fdbefbb Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 22:32:06 +0800 Subject: [PATCH 098/103] Revert "improve README.md" This reverts commit b3ee5c8d4fdb998310d70fc57bbff26f45aa4511. --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 768b5eb23..a93f91055 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,13 @@ https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2- Or use Docker: -```yml - uses: arduino/setup-protoc@v3 with: - version: "30.2" + version: "27.0" - uses: Nugine/setup-flatc@v1 with: - version: "25.2.10" -``` + version: "24.3.25" # How to add Console web @@ -34,7 +32,7 @@ Or use Docker: # Star RustFS -Add Env information: +Add Env infomation: ``` export RUSTFS_VOLUMES="./target/volume/test" From eb58ca0d8dce879b794089ad8d61eece4bf9f512 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 11 Apr 2025 22:37:52 +0800 Subject: [PATCH 099/103] fix typo --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a93f91055..3e1de2cb0 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,15 @@ https://github.com/protocolbuffers/protobuf/releases/download/v30.2/protoc-30.2- Or use Docker: +```yml - uses: arduino/setup-protoc@v3 with: - version: "27.0" + version: "30.2" - uses: Nugine/setup-flatc@v1 with: - version: "24.3.25" + version: "25.2.10" +``` # How to add Console web @@ -32,7 +34,7 @@ Or use Docker: # Star RustFS -Add Env infomation: +Add Env Information: ``` export RUSTFS_VOLUMES="./target/volume/test" From c651bea903c89673682959a2d89ebdf3c9a3d30c Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 13 Apr 2025 12:55:56 +0800 Subject: [PATCH 100/103] Fix/fix domain server (#319) * fix: server_domain and improve code for tls * add log * add tracing * test * improve config and tls * Update rustfs/src/console.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- deploy/certs/README.md | 10 +---- rustfs/src/config/mod.rs | 24 +++++------ rustfs/src/console.rs | 92 +++++++++++++++++++++++++--------------- rustfs/src/main.rs | 1 + scripts/run.sh | 2 + 5 files changed, 74 insertions(+), 55 deletions(-) diff --git a/deploy/certs/README.md b/deploy/certs/README.md index ce3dbe759..84b733e79 100644 --- a/deploy/certs/README.md +++ b/deploy/certs/README.md @@ -32,13 +32,7 @@ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -node ### TLS File ```text + rustfs_public.crt #api cert.pem - rustfs_tls_cert.pem api cert.pem - - rustfs_tls_key.pem api key.pem - - rustfs_console_tls_cert.pem console cert.pem - - rustfs_console_tls_key.pem console key.pem - + rustfs_private.key #api key.pem ``` \ No newline at end of file diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index 54dbc8d03..f53bc0958 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -29,11 +29,11 @@ pub const DEFAULT_OBS_CONFIG: &str = "config/obs.toml"; /// Default TLS key for rustfs /// This is the default key for TLS. -pub(crate) const RUSTFS_TLS_KEY: &str = "rustfs_tls_key.pem"; +pub(crate) const RUSTFS_TLS_KEY: &str = "rustfs_private.key"; /// Default TLS cert for rustfs /// This is the default cert for TLS. -pub(crate) const RUSTFS_TLS_CERT: &str = "rustfs_tls_cert.pem"; +pub(crate) const RUSTFS_TLS_CERT: &str = "rustfs_public.crt"; #[allow(clippy::const_is_empty)] const SHORT_VERSION: &str = { @@ -47,16 +47,16 @@ const SHORT_VERSION: &str = { }; const LONG_VERSION: &str = concat!( - concat!(SHORT_VERSION, "\n"), - concat!("build time : ", build::BUILD_TIME, "\n"), - concat!("build profile: ", build::BUILD_RUST_CHANNEL, "\n"), - concat!("build os : ", build::BUILD_OS, "\n"), - concat!("rust version : ", build::RUST_VERSION, "\n"), - concat!("rust channel : ", build::RUST_CHANNEL, "\n"), - concat!("git branch : ", build::BRANCH, "\n"), - concat!("git commit : ", build::COMMIT_HASH, "\n"), - concat!("git tag : ", build::TAG, "\n"), - concat!("git status :\n", build::GIT_STATUS_FILE), +concat!(SHORT_VERSION, "\n"), +concat!("build time : ", build::BUILD_TIME, "\n"), +concat!("build profile: ", build::BUILD_RUST_CHANNEL, "\n"), +concat!("build os : ", build::BUILD_OS, "\n"), +concat!("rust version : ", build::RUST_VERSION, "\n"), +concat!("rust channel : ", build::RUST_CHANNEL, "\n"), +concat!("git branch : ", build::BRANCH, "\n"), +concat!("git commit : ", build::COMMIT_HASH, "\n"), +concat!("git tag : ", build::TAG, "\n"), +concat!("git status :\n", build::GIT_STATUS_FILE), ); #[derive(Debug, Parser, Clone)] diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index 1eff0e906..8ed25f573 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -1,3 +1,4 @@ +use crate::config::{RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; use crate::license::get_license; use axum::{ body::Body, @@ -16,15 +17,12 @@ use std::net::{Ipv4Addr, SocketAddr, ToSocketAddrs}; use std::sync::OnceLock; use std::time::Duration; use tokio::signal; -use tracing::{debug, error, info}; +use tracing::{debug, error, info, instrument}; shadow!(build); const RUSTFS_ADMIN_PREFIX: &str = "/rustfs/admin/v3"; -const RUSTFS_CONSOLE_TLS_KEY: &str = "rustfs_console_tls_key.pem"; -const RUSTFS_CONSOLE_TLS_CERT: &str = "rustfs_console_tls_cert.pem"; - #[derive(RustEmbed)] #[folder = "$CARGO_MANIFEST_DIR/static"] struct StaticFiles; @@ -169,32 +167,56 @@ async fn license_handler() -> impl IntoResponse { .unwrap() } +fn is_private_ip(ip: std::net::IpAddr) -> bool { + match ip { + std::net::IpAddr::V4(ip) => { + let octets = ip.octets(); + // 10.0.0.0/8 + octets[0] == 10 || + // 172.16.0.0/12 + (octets[0] == 172 && (octets[1] >= 16 && octets[1] <= 31)) || + // 192.168.0.0/16 + (octets[0] == 192 && octets[1] == 168) + } + std::net::IpAddr::V6(_) => false, + } +} + #[allow(clippy::const_is_empty)] +#[instrument(fields(host))] async fn config_handler(Host(host): Host) -> impl IntoResponse { - let host_with_port = if host.contains(':') { host } else { format!("{}:80", host) }; - - let is_addr = host_with_port - .to_socket_addrs() - .map(|addrs| { - addrs.into_iter().find(|v| { - if let SocketAddr::V4(ipv4) = v { - !ipv4.ip().is_private() && !ipv4.ip().is_loopback() && !ipv4.ip().is_unspecified() - } else { - false - } - }) - }) - .unwrap_or_default(); - - let mut cfg = CONSOLE_CONFIG.get().unwrap().clone(); - - let url = if let Some(addr) = is_addr { - format!("http://{}:{}", addr.ip(), cfg.port) + let host_with_port = if host.contains(':') { + host.clone() } else { - let (host, _) = host_with_port.split_once(':').unwrap_or_default(); - format!("http://{}:{}", host, cfg.port) + format!("{}:80", host) }; + // 将当前配置复制一份 + let mut cfg = CONSOLE_CONFIG.get().unwrap().clone(); + + // 尝试解析为 socket address,但不强制要求一定要是 IP 地址 + let socket_addr = host_with_port.to_socket_addrs().ok().and_then(|mut addrs| addrs.next()); + debug!("axum Using host with port: {}, Socket address: {:?}", host_with_port, socket_addr); + let url = match socket_addr { + Some(addr) if addr.ip().is_ipv4() => { + let ipv4 = addr.ip().to_string(); + // 如果是私有 IP、环回地址或未指定地址,保留原始域名 + if is_private_ip(addr.ip()) || addr.ip().is_loopback() || addr.ip().is_unspecified() { + let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); + debug!("axum Using private IPv4 address: {}", host); + format!("http://{}:{}", host, cfg.port) + } else { + debug!("axum Using public IPv4 address"); + format!("http://{}:{}", ipv4, cfg.port) + } + } + _ => { + // 如果不是有效的 IPv4 地址,保留原始域名 + let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); + debug!("axum Using domain address: {}", host); + format!("http://{}:{}", host, cfg.port) + } + }; cfg.api.base_url = format!("{}{}", url, RUSTFS_ADMIN_PREFIX); cfg.s3.endpoint = url; @@ -222,21 +244,21 @@ pub async fn start_static_file_server( info!(" RootUser: {}", access_key); info!(" RootPass: {}", secret_key); - let tls_path = tls_path.unwrap_or_default(); - let key_path = format!("{}/{}", tls_path, RUSTFS_CONSOLE_TLS_KEY); - let cert_path = format!("{}/{}", tls_path, RUSTFS_CONSOLE_TLS_CERT); // Check and start the HTTPS/HTTP server - match start_server(addrs, local_addr, &key_path, &cert_path, app.clone()).await { + match start_server(addrs, local_addr, tls_path, app.clone()).await { Ok(_) => info!("Server shutdown gracefully"), Err(e) => error!("Server error: {}", e), } } -async fn start_server(addrs: &str, local_addr: SocketAddr, key_path: &str, cert_path: &str, app: Router) -> std::io::Result<()> { - let has_tls_certs = tokio::try_join!(tokio::fs::metadata(key_path), tokio::fs::metadata(cert_path)).is_ok(); - +async fn start_server(addrs: &str, local_addr: SocketAddr, tls_path: Option, app: Router) -> std::io::Result<()> { + let tls_path = tls_path.unwrap_or_default(); + let key_path = format!("{}/{}", tls_path, RUSTFS_TLS_KEY); + let cert_path = format!("{}/{}", tls_path, RUSTFS_TLS_CERT); + let has_tls_certs = tokio::try_join!(tokio::fs::metadata(&key_path), tokio::fs::metadata(&cert_path)).is_ok(); + debug!("Console TLS certs: {:?}", has_tls_certs); if has_tls_certs { debug!("Found TLS certificates, starting with HTTPS"); - match tokio::try_join!(tokio::fs::read(key_path), tokio::fs::read(cert_path)) { + match tokio::try_join!(tokio::fs::read(&key_path), tokio::fs::read(&cert_path)) { Ok((key_data, cert_data)) => { match RustlsConfig::from_pem(cert_data, key_data).await { Ok(config) => { @@ -247,7 +269,7 @@ async fn start_server(addrs: &str, local_addr: SocketAddr, key_path: &str, cert_ shutdown_signal().await; handle_clone.graceful_shutdown(Some(Duration::from_secs(10))); }); - debug!("Starting HTTPS server..."); + info!("Starting HTTPS server..."); axum_server::bind_rustls(local_addr, config) .handle(handle.clone()) .serve(app.into_make_service()) @@ -275,7 +297,7 @@ async fn start_server(addrs: &str, local_addr: SocketAddr, key_path: &str, cert_ async fn start_http_server(addrs: &str, app: Router) -> std::io::Result<()> { debug!("Starting HTTP server..."); - let listener = tokio::net::TcpListener::bind(addrs).await.unwrap(); + let listener = tokio::net::TcpListener::bind(addrs).await?; axum::serve(listener, app) .with_graceful_shutdown(shutdown_signal()) .await diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index c0ca34995..d3f899944 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -226,6 +226,7 @@ async fn run(opt: config::Opt) -> Result<()> { let key_path = format!("{}/{}", tls_path, RUSTFS_TLS_KEY); let cert_path = format!("{}/{}", tls_path, RUSTFS_TLS_CERT); let has_tls_certs = tokio::try_join!(tokio::fs::metadata(key_path.clone()), tokio::fs::metadata(cert_path.clone())).is_ok(); + debug!("Main TLS certs: {:?}", has_tls_certs); let tls_acceptor = if has_tls_certs { debug!("Found TLS certificates, starting with HTTPS"); let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); diff --git a/scripts/run.sh b/scripts/run.sh index b2cb5c80c..61f82aa82 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -32,6 +32,8 @@ export RUSTFS_ADDRESS="0.0.0.0:9000" export RUSTFS_CONSOLE_ENABLE=true export RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" # export RUSTFS_SERVER_DOMAINS="localhost:9000" +# HTTPS 证书目录 +# export RUSTFS_TLS_PATH="./deploy/certs" # 具体路径修改为配置文件真实路径,obs.example.toml 仅供参考 其中`RUSTFS_OBS_CONFIG` 和下面变量二选一 export RUSTFS_OBS_CONFIG="./deploy/config/obs.example.toml" From 3940ae2d691eaaead780c2c15bd10809663c77df Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sun, 13 Apr 2025 19:53:29 +0800 Subject: [PATCH 101/103] fix tls configs error --- rustfs/src/config/mod.rs | 50 ++++++++++++++++++----------------- rustfs/src/console.rs | 57 ++++++++++++++++++++++------------------ 2 files changed, 58 insertions(+), 49 deletions(-) diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index f53bc0958..eb7a00ba2 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -2,6 +2,7 @@ use clap::Parser; use const_str::concat; use ecstore::global::DEFAULT_PORT; use std::string::ToString; +use std::sync::OnceLock; shadow_rs::shadow!(build); /// Default Access Key @@ -47,16 +48,16 @@ const SHORT_VERSION: &str = { }; const LONG_VERSION: &str = concat!( -concat!(SHORT_VERSION, "\n"), -concat!("build time : ", build::BUILD_TIME, "\n"), -concat!("build profile: ", build::BUILD_RUST_CHANNEL, "\n"), -concat!("build os : ", build::BUILD_OS, "\n"), -concat!("rust version : ", build::RUST_VERSION, "\n"), -concat!("rust channel : ", build::RUST_CHANNEL, "\n"), -concat!("git branch : ", build::BRANCH, "\n"), -concat!("git commit : ", build::COMMIT_HASH, "\n"), -concat!("git tag : ", build::TAG, "\n"), -concat!("git status :\n", build::GIT_STATUS_FILE), + concat!(SHORT_VERSION, "\n"), + concat!("build time : ", build::BUILD_TIME, "\n"), + concat!("build profile: ", build::BUILD_RUST_CHANNEL, "\n"), + concat!("build os : ", build::BUILD_OS, "\n"), + concat!("rust version : ", build::RUST_VERSION, "\n"), + concat!("rust channel : ", build::RUST_CHANNEL, "\n"), + concat!("git branch : ", build::BRANCH, "\n"), + concat!("git commit : ", build::COMMIT_HASH, "\n"), + concat!("git tag : ", build::TAG, "\n"), + concat!("git status :\n", build::GIT_STATUS_FILE), ); #[derive(Debug, Parser, Clone)] @@ -70,6 +71,7 @@ pub struct Opt { #[arg(long, default_value_t = format!("0.0.0.0:{}", DEFAULT_PORT), env = "RUSTFS_ADDRESS")] pub address: String, + /// Domain name used for virtual-hosted-style requests. #[arg(long, env = "RUSTFS_SERVER_DOMAINS")] pub server_domains: Vec, @@ -81,16 +83,16 @@ pub struct Opt { #[arg(long, default_value_t = DEFAULT_SECRET_KEY.to_string(), env = "RUSTFS_SECRET_KEY")] pub secret_key: String, - /// Domain name used for virtual-hosted-style requests. - #[arg(long, env = "RUSTFS_DOMAIN_NAME")] - pub domain_name: Option, - #[arg(long, default_value_t = false, env = "RUSTFS_CONSOLE_ENABLE")] pub console_enable: bool, #[arg(long, default_value_t = format!("127.0.0.1:{}", 9002), env = "RUSTFS_CONSOLE_ADDRESS")] pub console_address: String, + /// rustfs endpoint for console + #[arg(long, env = "RUSTFS_CONSOLE_FS_ENDPOINT")] + pub console_fs_endpoint: Option, + /// Observability configuration file /// Default value: config/obs.toml #[arg(long, default_value_t = DEFAULT_OBS_CONFIG.to_string(), env = "RUSTFS_OBS_CONFIG")] @@ -104,15 +106,15 @@ pub struct Opt { pub license: Option, } -// lazy_static::lazy_static! { -// pub static ref OPT: OnceLock = OnceLock::new(); -// } +lazy_static::lazy_static! { + pub(crate) static ref OPT: OnceLock = OnceLock::new(); +} -// pub fn init_config() { -// let opt = Opt::parse(); -// OPT.set(opt).expect("Failed to set global config"); -// } +pub fn init_config(opt: Opt) { + OPT.set(opt).expect("Failed to set global config"); +} + +pub fn get_config() -> &'static Opt { + OPT.get().expect("Global config not initialized") +} -// pub fn get_config() -> &'static Opt { -// OPT.get().expect("Global config not initialized") -// } diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index 8ed25f573..c21da20d6 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -1,4 +1,4 @@ -use crate::config::{RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; +use crate::config::{self, RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; use crate::license::get_license; use axum::{ body::Body, @@ -185,38 +185,44 @@ fn is_private_ip(ip: std::net::IpAddr) -> bool { #[allow(clippy::const_is_empty)] #[instrument(fields(host))] async fn config_handler(Host(host): Host) -> impl IntoResponse { - let host_with_port = if host.contains(':') { - host.clone() - } else { - format!("{}:80", host) - }; - // 将当前配置复制一份 let mut cfg = CONSOLE_CONFIG.get().unwrap().clone(); - // 尝试解析为 socket address,但不强制要求一定要是 IP 地址 - let socket_addr = host_with_port.to_socket_addrs().ok().and_then(|mut addrs| addrs.next()); - debug!("axum Using host with port: {}, Socket address: {:?}", host_with_port, socket_addr); - let url = match socket_addr { - Some(addr) if addr.ip().is_ipv4() => { - let ipv4 = addr.ip().to_string(); - // 如果是私有 IP、环回地址或未指定地址,保留原始域名 - if is_private_ip(addr.ip()) || addr.ip().is_loopback() || addr.ip().is_unspecified() { + // 如果指定入口, 直接使用 + let url = if let Some(endpoint) = &config::get_config().console_fs_endpoint { + debug!("axum Using rustfs endpoint address: {}", endpoint); + endpoint.clone() + } else { + let host_with_port = if host.contains(':') { + host.clone() + } else { + format!("{}:80", host) + }; + // 尝试解析为 socket address,但不强制要求一定要是 IP 地址 + let socket_addr = host_with_port.to_socket_addrs().ok().and_then(|mut addrs| addrs.next()); + debug!("axum Using host with port: {}, Socket address: {:?}", host_with_port, socket_addr); + match socket_addr { + Some(addr) if addr.ip().is_ipv4() => { + let ipv4 = addr.ip().to_string(); + // 如果是私有 IP、环回地址或未指定地址,保留原始域名 + if is_private_ip(addr.ip()) || addr.ip().is_loopback() || addr.ip().is_unspecified() { + let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); + debug!("axum Using private IPv4 address: {}", host); + format!("http://{}:{}", host, cfg.port) + } else { + debug!("axum Using public IPv4 address"); + format!("http://{}:{}", ipv4, cfg.port) + } + } + _ => { + // 如果不是有效的 IPv4 地址,保留原始域名 let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); - debug!("axum Using private IPv4 address: {}", host); + debug!("axum Using domain address: {}", host); format!("http://{}:{}", host, cfg.port) - } else { - debug!("axum Using public IPv4 address"); - format!("http://{}:{}", ipv4, cfg.port) } } - _ => { - // 如果不是有效的 IPv4 地址,保留原始域名 - let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); - debug!("axum Using domain address: {}", host); - format!("http://{}:{}", host, cfg.port) - } }; + cfg.api.base_url = format!("{}{}", url, RUSTFS_ADMIN_PREFIX); cfg.s3.endpoint = url; @@ -329,3 +335,4 @@ async fn shutdown_signal() { }, } } + From c40099a63688f008e13aa0005b6ccea71e3a1d0d Mon Sep 17 00:00:00 2001 From: weisd Date: Sun, 13 Apr 2025 22:11:56 +0800 Subject: [PATCH 102/103] fix config_handler --- rustfs/src/config/mod.rs | 20 ++++----- rustfs/src/console.rs | 93 +++++++++++++++++++++++----------------- rustfs/src/main.rs | 4 +- 3 files changed, 65 insertions(+), 52 deletions(-) diff --git a/rustfs/src/config/mod.rs b/rustfs/src/config/mod.rs index eb7a00ba2..1efac71f7 100644 --- a/rustfs/src/config/mod.rs +++ b/rustfs/src/config/mod.rs @@ -2,7 +2,6 @@ use clap::Parser; use const_str::concat; use ecstore::global::DEFAULT_PORT; use std::string::ToString; -use std::sync::OnceLock; shadow_rs::shadow!(build); /// Default Access Key @@ -106,15 +105,14 @@ pub struct Opt { pub license: Option, } -lazy_static::lazy_static! { - pub(crate) static ref OPT: OnceLock = OnceLock::new(); -} +// lazy_static::lazy_static! { +// pub(crate) static ref OPT: OnceLock = OnceLock::new(); +// } -pub fn init_config(opt: Opt) { - OPT.set(opt).expect("Failed to set global config"); -} - -pub fn get_config() -> &'static Opt { - OPT.get().expect("Global config not initialized") -} +// pub fn init_config(opt: Opt) { +// OPT.set(opt).expect("Failed to set global config"); +// } +// pub fn get_config() -> &'static Opt { +// OPT.get().expect("Global config not initialized") +// } diff --git a/rustfs/src/console.rs b/rustfs/src/console.rs index c21da20d6..df6ffaee8 100644 --- a/rustfs/src/console.rs +++ b/rustfs/src/console.rs @@ -1,4 +1,4 @@ -use crate::config::{self, RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; +use crate::config::{RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; use crate::license::get_license; use axum::{ body::Body, @@ -8,12 +8,14 @@ use axum::{ Router, }; use axum_extra::extract::Host; + use axum_server::tls_rustls::RustlsConfig; +use http::Uri; use mime_guess::from_path; use rust_embed::RustEmbed; use serde::Serialize; use shadow_rs::shadow; -use std::net::{Ipv4Addr, SocketAddr, ToSocketAddrs}; +use std::net::{Ipv4Addr, SocketAddr}; use std::sync::OnceLock; use std::time::Duration; use tokio::signal; @@ -167,7 +169,7 @@ async fn license_handler() -> impl IntoResponse { .unwrap() } -fn is_private_ip(ip: std::net::IpAddr) -> bool { +fn _is_private_ip(ip: std::net::IpAddr) -> bool { match ip { std::net::IpAddr::V4(ip) => { let octets = ip.octets(); @@ -184,44 +186,58 @@ fn is_private_ip(ip: std::net::IpAddr) -> bool { #[allow(clippy::const_is_empty)] #[instrument(fields(host))] -async fn config_handler(Host(host): Host) -> impl IntoResponse { +async fn config_handler(uri: Uri, Host(host): Host) -> impl IntoResponse { + let scheme = uri.scheme().map(|s| s.as_str()).unwrap_or("http"); + + // 从 uri 中获取 host,如果没有则使用 Host extractor 的值 + let host = uri.host().unwrap_or(host.as_str()); + + let host = if host.contains(':') { + let (host, _) = host.split_once(':').unwrap_or((host, "80")); + host + } else { + host + }; + // 将当前配置复制一份 let mut cfg = CONSOLE_CONFIG.get().unwrap().clone(); - // 如果指定入口, 直接使用 - let url = if let Some(endpoint) = &config::get_config().console_fs_endpoint { - debug!("axum Using rustfs endpoint address: {}", endpoint); - endpoint.clone() - } else { - let host_with_port = if host.contains(':') { - host.clone() - } else { - format!("{}:80", host) - }; - // 尝试解析为 socket address,但不强制要求一定要是 IP 地址 - let socket_addr = host_with_port.to_socket_addrs().ok().and_then(|mut addrs| addrs.next()); - debug!("axum Using host with port: {}, Socket address: {:?}", host_with_port, socket_addr); - match socket_addr { - Some(addr) if addr.ip().is_ipv4() => { - let ipv4 = addr.ip().to_string(); - // 如果是私有 IP、环回地址或未指定地址,保留原始域名 - if is_private_ip(addr.ip()) || addr.ip().is_loopback() || addr.ip().is_unspecified() { - let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); - debug!("axum Using private IPv4 address: {}", host); - format!("http://{}:{}", host, cfg.port) - } else { - debug!("axum Using public IPv4 address"); - format!("http://{}:{}", ipv4, cfg.port) - } - } - _ => { - // 如果不是有效的 IPv4 地址,保留原始域名 - let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); - debug!("axum Using domain address: {}", host); - format!("http://{}:{}", host, cfg.port) - } - } - }; + let url = format!("{}://{}:{}", scheme, host, cfg.port); + + // // 如果指定入口, 直接使用 + // let url = if let Some(endpoint) = &config::get_config().console_fs_endpoint { + // debug!("axum Using rustfs endpoint address: {}", endpoint); + // endpoint.clone() + // } else { + // let host_with_port = if host.contains(':') { + // host.clone() + // } else { + // format!("{}:80", host) + // }; + // // 尝试解析为 socket address,但不强制要求一定要是 IP 地址 + // let socket_addr = host_with_port.to_socket_addrs().ok().and_then(|mut addrs| addrs.next()); + // debug!("axum Using host with port: {}, Socket address: {:?}", host_with_port, socket_addr); + // match socket_addr { + // Some(addr) if addr.ip().is_ipv4() => { + // let ipv4 = addr.ip().to_string(); + // // 如果是私有 IP、环回地址或未指定地址,保留原始域名 + // if is_private_ip(addr.ip()) || addr.ip().is_loopback() || addr.ip().is_unspecified() { + // let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); + // debug!("axum Using private IPv4 address: {}", host); + // format!("http://{}:{}", host, cfg.port) + // } else { + // debug!("axum Using public IPv4 address"); + // format!("http://{}:{}", ipv4, cfg.port) + // } + // } + // _ => { + // // 如果不是有效的 IPv4 地址,保留原始域名 + // let (host, _) = host_with_port.split_once(':').unwrap_or((&host, "80")); + // debug!("axum Using domain address: {}", host); + // format!("http://{}:{}", host, cfg.port) + // } + // } + // }; cfg.api.base_url = format!("{}{}", url, RUSTFS_ADMIN_PREFIX); cfg.s3.endpoint = url; @@ -335,4 +351,3 @@ async fn shutdown_signal() { }, } } - diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index d3f899944..d7ea61d1b 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -77,11 +77,11 @@ fn print_server_info() { #[tokio::main] async fn main() -> Result<()> { - // config::init_config(); - // Parse the obtained parameters let opt = config::Opt::parse(); + // config::init_config(opt.clone()); + init_license(opt.license.clone()); // Load the configuration file From cefdf4d6f9399438942c45e6aefcc1aeb1d09080 Mon Sep 17 00:00:00 2001 From: junxiang Mu <1948535941@qq.com> Date: Fri, 11 Apr 2025 04:08:20 +0000 Subject: [PATCH 103/103] fix datascanner Signed-off-by: junxiang Mu <1948535941@qq.com> --- ecstore/src/disk/local.rs | 33 +++++- ecstore/src/heal/data_scanner.rs | 152 ++++++++++++++++++++++----- ecstore/src/heal/data_usage_cache.rs | 5 +- ecstore/src/set_disk.rs | 6 +- ecstore/src/store.rs | 5 +- 5 files changed, 161 insertions(+), 40 deletions(-) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 93681d91f..24e5782fe 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -11,6 +11,8 @@ use super::{ }; use crate::bitrot::bitrot_verify; use crate::bucket::metadata_sys::{self}; +use crate::bucket::versioning::VersioningApi; +use crate::bucket::versioning_sys::BucketVersioningSys; use crate::cache_value::cache::{Cache, Opts, UpdateFn}; use crate::disk::error::{ convert_access_error, is_err_os_not_exist, is_sys_err_handle_invalid, is_sys_err_invalid_arg, is_sys_err_is_dir, @@ -20,7 +22,9 @@ use crate::disk::os::{check_path_length, is_empty_dir}; use crate::disk::STORAGE_FORMAT_FILE; use crate::file_meta::{get_file_info, read_xl_meta_no_data, FileInfoOpts}; use crate::global::{GLOBAL_IsErasureSD, GLOBAL_RootDiskThreshold}; -use crate::heal::data_scanner::{has_active_rules, scan_data_folder, ScannerItem, ShouldSleepFn, SizeSummary}; +use crate::heal::data_scanner::{ + lc_has_active_rules, rep_has_active_rules, scan_data_folder, ScannerItem, ShouldSleepFn, SizeSummary, +}; use crate::heal::data_scanner_metric::{ScannerMetric, ScannerMetrics}; use crate::heal::data_usage_cache::{DataUsageCache, DataUsageEntry}; use crate::heal::error::{ERR_IGNORE_FILE_CONTRIB, ERR_SKIP_FILE}; @@ -2295,6 +2299,7 @@ impl DiskAPI for LocalDisk { Ok(info) } + #[tracing::instrument(level = "info", skip_all)] async fn ns_scanner( &self, cache: &DataUsageCache, @@ -2308,18 +2313,30 @@ impl DiskAPI for LocalDisk { // must befor metadata_sys let Some(store) = new_object_layer_fn() else { return Err(Error::msg("errServerNotInitialized")) }; + let mut cache = cache.clone(); + // Check if the current bucket has a configured lifecycle policy + if let Ok((lc, _)) = metadata_sys::get_lifecycle_config(&cache.info.name).await { + if lc_has_active_rules(&lc, "") { + cache.info.life_cycle = Some(lc); + } + } + // Check if the current bucket has replication configuration if let Ok((rcfg, _)) = metadata_sys::get_replication_config(&cache.info.name).await { - if has_active_rules(&rcfg, "", true) { + if rep_has_active_rules(&rcfg, "", true) { // TODO: globalBucketTargetSys } } + let vcfg = match BucketVersioningSys::get(&cache.info.name).await { + Ok(vcfg) => Some(vcfg), + Err(_) => None, + }; + let loc = self.get_disk_location(); let disks = store.get_disks(loc.pool_idx.unwrap(), loc.disk_idx.unwrap()).await?; let disk = Arc::new(LocalDisk::new(&self.endpoint(), false).await?); let disk_clone = disk.clone(); - let mut cache = cache.clone(); cache.info.updates = Some(updates.clone()); let mut data_usage_info = scan_data_folder( &disks, @@ -2328,8 +2345,9 @@ impl DiskAPI for LocalDisk { Box::new(move |item: &ScannerItem| { let mut item = item.clone(); let disk = disk_clone.clone(); + let vcfg = vcfg.clone(); Box::pin(async move { - if item.path.ends_with(&format!("{}{}", SLASH_SEPARATOR, STORAGE_FORMAT_FILE)) { + if !item.path.ends_with(&format!("{}{}", SLASH_SEPARATOR, STORAGE_FORMAT_FILE)) { return Err(Error::from_string(ERR_SKIP_FILE)); } let stop_fn = ScannerMetrics::log(ScannerMetric::ScanObject); @@ -2370,7 +2388,12 @@ impl DiskAPI for LocalDisk { } }; - let versioned = false; + let versioned = if let Some(vcfg) = vcfg.as_ref() { + vcfg.versioned(item.object_path().to_str().unwrap_or_default()) + } else { + false + }; + let mut obj_deleted = false; for info in obj_infos.iter() { let done = ScannerMetrics::time(ScannerMetric::ApplyVersion); diff --git a/ecstore/src/heal/data_scanner.rs b/ecstore/src/heal/data_scanner.rs index 6701f7ba8..315b21fef 100644 --- a/ecstore/src/heal/data_scanner.rs +++ b/ecstore/src/heal/data_scanner.rs @@ -18,7 +18,10 @@ use super::{ data_usage_cache::{DataUsageCache, DataUsageEntry, DataUsageHash}, heal_commands::{HealScanMode, HEAL_DEEP_SCAN, HEAL_NORMAL_SCAN}, }; -use crate::heal::data_usage::DATA_USAGE_ROOT; +use crate::{ + bucket::{versioning::VersioningApi, versioning_sys::BucketVersioningSys}, + heal::data_usage::DATA_USAGE_ROOT, +}; use crate::{ cache_value::metacache_set::{list_path_raw, ListPathRawOptions}, config::{ @@ -49,7 +52,7 @@ use common::error::{Error, Result}; use lazy_static::lazy_static; use rand::Rng; use rmp_serde::{Deserializer, Serializer}; -use s3s::dto::{ReplicationConfiguration, ReplicationRuleStatus}; +use s3s::dto::{BucketLifecycleConfiguration, ExpirationStatus, LifecycleRule, ReplicationConfiguration, ReplicationRuleStatus}; use serde::{Deserialize, Serialize}; use tokio::{ sync::{ @@ -412,7 +415,7 @@ pub struct ScannerItem { pub prefix: String, pub object_name: String, pub replication: Option, - // todo: lifecycle + pub lifecycle: Option, // typ: fs::Permissions, pub heal: Heal, pub debug: bool, @@ -435,7 +438,7 @@ impl ScannerItem { pub async fn apply_versions_actions(&self, fivs: &[FileInfo]) -> Result> { let obj_infos = self.apply_newer_noncurrent_version_limit(fivs).await?; - if obj_infos.len() >= >::try_into(SCANNER_EXCESS_OBJECT_VERSIONS.load(Ordering::SeqCst)).unwrap() { + if obj_infos.len() >= SCANNER_EXCESS_OBJECT_VERSIONS.load(Ordering::SeqCst) as usize { // todo } @@ -444,9 +447,7 @@ impl ScannerItem { cumulative_size += obj_info.size; } - if cumulative_size - >= >::try_into(SCANNER_EXCESS_OBJECT_VERSIONS_TOTAL_SIZE.load(Ordering::SeqCst)).unwrap() - { + if cumulative_size >= SCANNER_EXCESS_OBJECT_VERSIONS_TOTAL_SIZE.load(Ordering::SeqCst) as usize { //todo } @@ -454,22 +455,31 @@ impl ScannerItem { } pub async fn apply_newer_noncurrent_version_limit(&self, fivs: &[FileInfo]) -> Result> { - let done = ScannerMetrics::time(ScannerMetric::ApplyNonCurrent); - let mut object_infos = Vec::new(); - for info in fivs.iter() { - object_infos.push(info.to_object_info(&self.bucket, &self.object_path().to_string_lossy(), false)); + // let done = ScannerMetrics::time(ScannerMetric::ApplyNonCurrent); + let versioned = match BucketVersioningSys::get(&self.bucket).await { + Ok(vcfg) => vcfg.versioned(self.object_path().to_str().unwrap_or_default()), + Err(_) => false, + }; + let mut object_infos = Vec::with_capacity(fivs.len()); + + if self.lifecycle.is_none() { + for info in fivs.iter() { + object_infos.push(info.to_object_info(&self.bucket, &self.object_path().to_string_lossy(), versioned)); + } + return Ok(object_infos); } - done().await; + + // done().await; Ok(object_infos) } - pub async fn apply_actions(&self, _oi: &ObjectInfo, _size_s: &SizeSummary) -> (bool, usize) { + pub async fn apply_actions(&self, oi: &ObjectInfo, _size_s: &SizeSummary) -> (bool, usize) { let done = ScannerMetrics::time(ScannerMetric::Ilm); //todo: lifecycle done().await; - (false, 0) + (false, oi.size) } } @@ -548,6 +558,7 @@ impl FolderScanner { true } + #[tracing::instrument(level = "info", skip_all)] async fn scan_folder(&mut self, folder: &CachedFolder, into: &mut DataUsageEntry) -> Result<()> { let this_hash = hash_path(&folder.name); let was_compacted = into.compacted; @@ -561,8 +572,18 @@ impl FolderScanner { let (_, prefix) = path_to_bucket_object_with_base_path(&self.root, &folder.name); // Todo: lifeCycle + let active_life_cycle = if let Some(lc) = self.old_cache.info.life_cycle.as_ref() { + if lc_has_active_rules(lc, &prefix) { + self.old_cache.info.life_cycle.clone() + } else { + None + } + } else { + None + }; + let replication_cfg = if self.old_cache.info.replication.is_some() - && has_active_rules(self.old_cache.info.replication.as_ref().unwrap(), &prefix, true) + && rep_has_active_rules(self.old_cache.info.replication.as_ref().unwrap(), &prefix, true) { self.old_cache.info.replication.clone() } else { @@ -593,7 +614,7 @@ impl FolderScanner { continue; } - if !sub_path.is_dir() { + if sub_path.is_dir() { let h = hash_path(ent_name.to_str().unwrap()); if h == this_hash { continue; @@ -638,6 +659,7 @@ impl FolderScanner { .unwrap_or_default(), debug: self.data_usage_scanner_debug, replication: replication_cfg.clone(), + lifecycle: active_life_cycle.clone(), heal: Heal::default(), }; @@ -681,13 +703,11 @@ impl FolderScanner { } let should_compact = self.new_cache.info.name != folder.name - && existing_folders.len() + new_folders.len() - >= >::try_into(DATA_SCANNER_COMPACT_AT_FOLDERS).unwrap() - || existing_folders.len() + new_folders.len() - >= >::try_into(DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS).unwrap(); + && (existing_folders.len() + new_folders.len() >= DATA_SCANNER_COMPACT_AT_FOLDERS as usize + || existing_folders.len() + new_folders.len() >= DATA_SCANNER_FORCE_COMPACT_AT_FOLDERS as usize); let total_folders = existing_folders.len() + new_folders.len(); - if total_folders > >::try_into(SCANNER_EXCESS_FOLDERS.load(Ordering::SeqCst)).unwrap() { + if total_folders > SCANNER_EXCESS_FOLDERS.load(Ordering::SeqCst) as usize { let _prefix_name = format!("{}/", folder.name.trim_end_matches('/')); // todo: notification } @@ -935,7 +955,7 @@ impl FolderScanner { let _ = list_path_raw(rx, lopts).await; if *found_objs.read().await { - let this = CachedFolder { + let this: CachedFolder = CachedFolder { name: k.clone(), parent: this_hash.clone(), object_heal_prob_div: 1, @@ -951,7 +971,7 @@ impl FolderScanner { if !into.compacted && self.new_cache.info.name != folder.name { let mut flat = self.new_cache.size_recursive(&this_hash.key()).unwrap_or_default(); flat.compacted = true; - let compact = if flat.objects < >::try_into(DATA_SCANNER_COMPACT_LEAST_OBJECT).unwrap() { + let compact = if flat.objects < DATA_SCANNER_COMPACT_LEAST_OBJECT as usize { true } else { // Compact if we only have objects as children... @@ -996,6 +1016,7 @@ impl FolderScanner { Ok(()) } + #[tracing::instrument(level = "info", skip_all)] async fn send_update(&mut self) { if SystemTime::now().duration_since(self.last_update).unwrap() < Duration::from_secs(60) { return; @@ -1007,8 +1028,9 @@ impl FolderScanner { } } +#[tracing::instrument(level = "info", skip(into, folder_scanner))] async fn scan(folder: &CachedFolder, into: &mut DataUsageEntry, folder_scanner: &mut FolderScanner) { - let mut dst = if !into.compacted { + let mut dst = if into.compacted { DataUsageEntry::default() } else { into.clone() @@ -1028,7 +1050,74 @@ async fn scan(folder: &CachedFolder, into: &mut DataUsageEntry, folder_scanner: } } -pub fn has_active_rules(config: &ReplicationConfiguration, prefix: &str, recursive: bool) -> bool { +fn lc_get_prefix(rule: &LifecycleRule) -> String { + if let Some(p) = &rule.prefix { + return p.to_string(); + } else if let Some(filter) = &rule.filter { + if let Some(p) = &filter.prefix { + return p.to_string(); + } else if let Some(and) = &filter.and { + if let Some(p) = &and.prefix { + return p.to_string(); + } + } + } + + "".into() +} + +pub fn lc_has_active_rules(config: &BucketLifecycleConfiguration, prefix: &str) -> bool { + if config.rules.is_empty() { + return false; + } + + for rule in config.rules.iter() { + if rule.status == ExpirationStatus::from_static(ExpirationStatus::DISABLED) { + continue; + } + let rule_prefix = lc_get_prefix(rule); + if !prefix.is_empty() && !rule_prefix.is_empty() { + if !prefix.starts_with(&rule_prefix) && !rule_prefix.starts_with(prefix) { + continue; + } + } + + if let Some(e) = &rule.noncurrent_version_expiration { + if let Some(true) = e.noncurrent_days.map(|d| d > 0) { + return true; + } + if let Some(true) = e.newer_noncurrent_versions.map(|d| d > 0) { + return true; + } + } + + if rule.noncurrent_version_transitions.is_some() { + return true; + } + if let Some(true) = rule.expiration.as_ref().map(|e| e.date.is_some()) { + return true; + } + + if let Some(true) = rule.expiration.as_ref().map(|e| e.days.is_some()) { + return true; + } + + if let Some(Some(true)) = rule.expiration.as_ref().map(|e| e.expired_object_delete_marker.map(|m| m)) { + return true; + } + + if let Some(true) = rule.transitions.as_ref().map(|t| !t.is_empty()) { + return true; + } + + if rule.transitions.is_some() { + return true; + } + } + false +} + +pub fn rep_has_active_rules(config: &ReplicationConfiguration, prefix: &str, recursive: bool) -> bool { if config.rules.is_empty() { return false; } @@ -1086,8 +1175,14 @@ pub async fn scan_data_folder( root: base_path, get_size: get_size_fn, old_cache: cache.clone(), - new_cache: DataUsageCache::default(), - update_cache: DataUsageCache::default(), + new_cache: DataUsageCache { + info: cache.info.clone(), + ..Default::default() + }, + update_cache: DataUsageCache { + info: cache.info.clone(), + ..Default::default() + }, data_usage_scanner_debug: false, heal_object_select: 0, scan_mode: heal_scan_mode, @@ -1115,8 +1210,7 @@ pub async fn scan_data_folder( if s.scan_folder(&folder, &mut root).await.is_err() { close_disk().await; } - s.new_cache - .force_compact(DATA_SCANNER_COMPACT_AT_CHILDREN.try_into().unwrap()); + s.new_cache.force_compact(DATA_SCANNER_COMPACT_AT_CHILDREN as usize); s.new_cache.info.last_update = Some(SystemTime::now()); s.new_cache.info.next_cycle = cache.info.next_cycle; close_disk().await; diff --git a/ecstore/src/heal/data_usage_cache.rs b/ecstore/src/heal/data_usage_cache.rs index cca9d79f3..de5b73734 100644 --- a/ecstore/src/heal/data_usage_cache.rs +++ b/ecstore/src/heal/data_usage_cache.rs @@ -10,7 +10,7 @@ use http::HeaderMap; use path_clean::PathClean; use rand::Rng; use rmp_serde::Serializer; -use s3s::dto::ReplicationConfiguration; +use s3s::dto::{BucketLifecycleConfiguration, ReplicationConfiguration}; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::hash::{DefaultHasher, Hash, Hasher}; @@ -347,7 +347,8 @@ pub struct DataUsageCacheInfo { pub next_cycle: u32, pub last_update: Option, pub skip_healing: bool, - // todo: life_cycle + #[serde(skip)] + pub life_cycle: Option, // pub life_cycle: #[serde(skip)] pub updates: Option>, diff --git a/ecstore/src/set_disk.rs b/ecstore/src/set_disk.rs index 04b3254a4..63ad26d89 100644 --- a/ecstore/src/set_disk.rs +++ b/ecstore/src/set_disk.rs @@ -3015,7 +3015,7 @@ impl SetDisks { }); // Calc usage let before = cache.info.last_update; - let cache = match disk.clone().ns_scanner(&cache, tx, heal_scan_mode, None).await { + let mut cache = match disk.clone().ns_scanner(&cache, tx, heal_scan_mode, None).await { Ok(cache) => cache, Err(_) => { if cache.info.last_update > before { @@ -3025,6 +3025,9 @@ impl SetDisks { continue; } }; + + cache.info.updates = None; + let _ = task.await; let mut root = DataUsageEntry::default(); if let Some(r) = cache.root() { root = cache.flatten(&r); @@ -3041,7 +3044,6 @@ impl SetDisks { entry: root, }) .await; - let _ = task.await; let _ = cache.save(&cache_name.to_string_lossy()).await; } } diff --git a/ecstore/src/store.rs b/ecstore/src/store.rs index 1f57b704c..793e31a26 100644 --- a/ecstore/src/store.rs +++ b/ecstore/src/store.rs @@ -740,7 +740,7 @@ impl ECStore { let cancel_clone = cancel.clone(); let all_buckets_clone = all_buckets.clone(); futures.push(async move { - let (tx, mut rx) = mpsc::channel(100); + let (tx, mut rx) = mpsc::channel(1); let task = tokio::spawn(async move { loop { match rx.recv().await { @@ -951,6 +951,7 @@ impl ECStore { } } +#[tracing::instrument(level = "info", skip(all_buckets, updates))] async fn update_scan( all_merged: Arc>, results: Arc>>, @@ -972,7 +973,7 @@ async fn update_scan( } w.merge(info); } - if w.info.last_update > *last_update && w.root().is_none() { + if (last_update.is_none() || w.info.last_update > *last_update) && w.root().is_some() { let _ = updates.send(w.dui(&w.info.name, &all_buckets)).await; *last_update = w.info.last_update; }