Skip to content

Commit

Permalink
fix: revert by suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
poltao committed May 20, 2024
1 parent b5495a3 commit c607eee
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 37 deletions.
13 changes: 0 additions & 13 deletions src/cmd/src/datanode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use datanode::config::DatanodeOptions;
use datanode::datanode::{Datanode, DatanodeBuilder};
use datanode::service::DatanodeServiceBuilder;
use meta_client::MetaClientOptions;
use servers::tls::{TlsMode, TlsOption};
use servers::Mode;
use snafu::{OptionExt, ResultExt};

Expand Down Expand Up @@ -135,12 +134,6 @@ struct StartCommand {
http_timeout: Option<u64>,
#[clap(long, default_value = "GREPTIMEDB_DATANODE")]
env_prefix: String,
#[clap(long)]
tls_mode: Option<TlsMode>,
#[clap(long)]
tls_cert_path: Option<String>,
#[clap(long)]
tls_key_path: Option<String>,
}

impl StartCommand {
Expand Down Expand Up @@ -227,11 +220,6 @@ impl StartCommand {
opts.http.timeout = Duration::from_secs(http_timeout)
}

opts.tls = TlsOption::new(
self.tls_mode.clone(),
self.tls_cert_path.clone(),
self.tls_key_path.clone(),
);
// Disable dashboard in datanode.
opts.http.disable_dashboard = true;

Expand Down Expand Up @@ -278,7 +266,6 @@ impl StartCommand {

let services = DatanodeServiceBuilder::new(&opts)
.with_default_grpc_server(&datanode.region_server())
.context(StartDatanodeSnafu)?
.enable_http_service()
.build()
.await
Expand Down
3 changes: 0 additions & 3 deletions src/datanode/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use serde::{Deserialize, Serialize};
use servers::export_metrics::ExportMetricsOption;
use servers::heartbeat_options::HeartbeatOptions;
use servers::http::HttpOptions;
use servers::tls::TlsOption;
use servers::Mode;

pub const DEFAULT_OBJECT_STORE_CACHE_SIZE: ReadableSize = ReadableSize::mb(256);
Expand Down Expand Up @@ -237,7 +236,6 @@ pub struct DatanodeOptions {
pub enable_telemetry: bool,
pub export_metrics: ExportMetricsOption,
pub tracing: TracingOptions,
pub tls: TlsOption,
}

impl Default for DatanodeOptions {
Expand Down Expand Up @@ -265,7 +263,6 @@ impl Default for DatanodeOptions {
enable_telemetry: true,
export_metrics: ExportMetricsOption::default(),
tracing: TracingOptions::default(),
tls: TlsOption::default(),
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/datanode/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,6 @@ pub enum Error {
#[snafu(source(from(common_config::error::Error, Box::new)))]
source: Box<common_config::error::Error>,
},

#[snafu(display("Invalid tls config"))]
InvalidTlsConfig {
#[snafu(source)]
error: common_grpc::error::Error,
#[snafu(implicit)]
location: Location,
},
}

pub type Result<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -409,7 +401,6 @@ impl ErrorExt for Error {
| MissingWalDirConfig { .. }
| MissingKvBackend { .. }
| TomlFormat { .. } => StatusCode::InvalidArguments,
InvalidTlsConfig { .. } => StatusCode::InvalidArguments,

PayloadNotExist { .. } | Unexpected { .. } | WatchAsyncTaskChange { .. } => {
StatusCode::Unexpected
Expand Down
22 changes: 10 additions & 12 deletions src/datanode/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ use servers::grpc::{GrpcServer, GrpcServerConfig};
use servers::http::HttpServerBuilder;
use servers::metrics_handler::MetricsHandler;
use servers::server::{ServerHandler, ServerHandlers};
use servers::tls::TlsOption;
use snafu::ResultExt;

use crate::config::DatanodeOptions;
use crate::error::{InvalidTlsConfigSnafu, ParseAddrSnafu, Result, TomlFormatSnafu};
use crate::error::{ParseAddrSnafu, Result, TomlFormatSnafu};
use crate::region_server::RegionServer;

pub struct DatanodeServiceBuilder<'a> {
Expand All @@ -49,10 +50,10 @@ impl<'a> DatanodeServiceBuilder<'a> {
}
}

pub fn with_default_grpc_server(mut self, region_server: &RegionServer) -> Result<Self> {
let grpc_server_build = Self::grpc_server_builder(self.opts, region_server)?;
self.grpc_server = Some(grpc_server_build.build());
Ok(self)
pub fn with_default_grpc_server(mut self, region_server: &RegionServer) -> Self {
let grpc_serve = Self::grpc_server_builder(self.opts, region_server).build();
self.grpc_server = Some(grpc_serve);
self
}

pub fn enable_http_service(self) -> Self {
Expand Down Expand Up @@ -91,18 +92,15 @@ impl<'a> DatanodeServiceBuilder<'a> {
pub fn grpc_server_builder(
opts: &DatanodeOptions,
region_server: &RegionServer,
) -> Result<GrpcServerBuilder> {
) -> GrpcServerBuilder {
let config = GrpcServerConfig {
max_recv_message_size: opts.rpc_max_recv_message_size.as_bytes() as usize,
max_send_message_size: opts.rpc_max_send_message_size.as_bytes() as usize,
tls: opts.tls.clone(),
tls: TlsOption::default(),
};

let build = GrpcServerBuilder::new(config, region_server.runtime())
.with_tls_config(opts.tls.clone())
.context(InvalidTlsConfigSnafu)?
GrpcServerBuilder::new(config, region_server.runtime())
.flight_handler(Arc::new(region_server.clone()))
.region_server_handler(Arc::new(region_server.clone()));
Ok(build)
.region_server_handler(Arc::new(region_server.clone()))
}
}

0 comments on commit c607eee

Please sign in to comment.