Skip to content

Commit 08ded45

Browse files
authored
feat: add common_version customization (GreptimeTeam#7869)
* feat: add product name customization * chore: update tests
1 parent 1118fe2 commit 08ded45

15 files changed

Lines changed: 44 additions & 17 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ common-telemetry = { workspace = true, features = [
5454
common-time.workspace = true
5555
common-version.workspace = true
5656
common-wal.workspace = true
57+
const_format.workspace = true
5758
datafusion.workspace = true
5859
datafusion-common.workspace = true
5960
datafusion-physical-plan.workspace = true

src/cmd/src/bin/greptime.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use cmd::error::{InitTlsProviderSnafu, Result};
2020
use cmd::options::GlobalOptions;
2121
use cmd::{App, cli, datanode, flownode, frontend, metasrv, standalone};
2222
use common_base::Plugins;
23-
use common_version::{verbose_version, version};
23+
use common_version::{product_name, verbose_version, version};
2424
use servers::install_ring_crypto_provider;
2525

2626
#[derive(Parser)]
27-
#[command(name = "greptime", author, version, long_version = verbose_version(), about)]
27+
#[command(name = product_name(), author, version, long_version = verbose_version(), about)]
2828
#[command(propagate_version = true)]
2929
pub(crate) struct Command {
3030
#[clap(subcommand)]
@@ -52,11 +52,11 @@ enum SubCommand {
5252
#[clap(name = "metasrv")]
5353
Metasrv(metasrv::Command),
5454

55-
/// Run greptimedb as a standalone service.
55+
/// Start service in standalone mode.
5656
#[clap(name = "standalone")]
5757
Standalone(standalone::Command),
5858

59-
/// Execute the cli tools for greptimedb.
59+
/// Execute the cli tools.
6060
#[clap(name = "cli")]
6161
Cli(cli::Command),
6262
}
@@ -148,7 +148,7 @@ async fn start(cli: Command) -> Result<()> {
148148

149149
fn setup_human_panic() {
150150
human_panic::setup_panic!(
151-
human_panic::Metadata::new("GreptimeDB", version())
151+
human_panic::Metadata::new(product_name(), version())
152152
.homepage("https://github.com/GreptimeTeam/greptimedb/discussions")
153153
);
154154

src/cmd/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use tracing_appender::non_blocking::WorkerGuard;
2121

2222
use crate::options::GlobalOptions;
2323
use crate::{App, Result, error};
24-
pub const APP_NAME: &str = "greptime-cli";
24+
pub const APP_NAME: &str = const_format::concatcp!(common_version::product_name(), "-cli");
2525
use async_trait::async_trait;
2626

2727
pub struct Instance {

src/cmd/src/datanode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::error::{
4343
};
4444
use crate::options::{GlobalOptions, GreptimeOptions};
4545

46-
pub const APP_NAME: &str = "greptime-datanode";
46+
pub const APP_NAME: &str = const_format::concatcp!(common_version::product_name(), "-datanode");
4747

4848
type DatanodeOptions = GreptimeOptions<datanode::config::DatanodeOptions>;
4949

src/cmd/src/flownode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use common_stat::ResourceStatImpl;
3535
use common_telemetry::info;
3636
use common_telemetry::logging::{DEFAULT_LOGGING_DIR, TracingOptions};
3737
use common_version::{short_version, verbose_version};
38+
use const_format::concatcp;
3839
use flow::{
3940
FlownodeBuilder, FlownodeInstance, FlownodeServiceBuilder, FrontendClient, FrontendInvoker,
4041
get_flow_auth_options,
@@ -52,7 +53,7 @@ use crate::error::{
5253
use crate::options::{GlobalOptions, GreptimeOptions};
5354
use crate::{App, create_resource_limit_metrics, log_versions, maybe_activate_heap_profile};
5455

55-
pub const APP_NAME: &str = "greptime-flownode";
56+
pub const APP_NAME: &str = concatcp!(common_version::product_name(), "-flownode");
5657

5758
type FlownodeOptions = GreptimeOptions<flow::FlownodeOptions>;
5859

src/cmd/src/frontend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub struct Instance {
7272
_guard: Vec<WorkerGuard>,
7373
}
7474

75-
pub const APP_NAME: &str = "greptime-frontend";
75+
pub const APP_NAME: &str = const_format::concatcp!(common_version::product_name(), "-frontend");
7676

7777
impl Instance {
7878
pub fn new(frontend: Frontend, _guard: Vec<WorkerGuard>) -> Self {

src/cmd/src/metasrv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use common_meta::distributed_time_constants::init_distributed_time_constants;
2424
use common_telemetry::info;
2525
use common_telemetry::logging::{DEFAULT_LOGGING_DIR, TracingOptions};
2626
use common_version::{short_version, verbose_version};
27+
use const_format::concatcp;
2728
use meta_srv::bootstrap::{MetasrvInstance, metasrv_builder};
2829
use meta_srv::metasrv::BackendImpl;
2930
use snafu::ResultExt;
@@ -35,7 +36,7 @@ use crate::{App, create_resource_limit_metrics, log_versions, maybe_activate_hea
3536

3637
type MetasrvOptions = GreptimeOptions<meta_srv::metasrv::MetasrvOptions>;
3738

38-
pub const APP_NAME: &str = "greptime-metasrv";
39+
pub const APP_NAME: &str = concatcp!(common_version::product_name(), "-metasrv");
3940

4041
pub struct Instance {
4142
instance: MetasrvInstance,

src/cmd/src/standalone.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use common_telemetry::info;
4848
use common_telemetry::logging::{DEFAULT_LOGGING_DIR, TracingOptions};
4949
use common_time::timezone::set_default_timezone;
5050
use common_version::{short_version, verbose_version};
51+
use const_format::concatcp;
5152
use datanode::config::DatanodeOptions;
5253
use datanode::datanode::{Datanode, DatanodeBuilder};
5354
use datanode::region_server::RegionServer;
@@ -75,7 +76,7 @@ use crate::error::{OtherSnafu, Result, StartFlownodeSnafu};
7576
use crate::options::{GlobalOptions, GreptimeOptions};
7677
use crate::{App, create_resource_limit_metrics, error, log_versions, maybe_activate_heap_profile};
7778

78-
pub const APP_NAME: &str = "greptime-standalone";
79+
pub const APP_NAME: &str = concatcp!(common_version::product_name(), "-standalone");
7980

8081
#[derive(Parser)]
8182
pub struct Command {

src/common/function/src/system/version.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,19 @@ impl Function for VersionFunction {
4343
let version = match func_ctx.query_ctx.channel() {
4444
Channel::Mysql => {
4545
format!(
46-
"{}-greptimedb-{}",
46+
"{}-{}-{}",
4747
std::env::var("GREPTIMEDB_MYSQL_SERVER_VERSION")
4848
.unwrap_or_else(|_| "8.4.2".to_string()),
49+
common_version::product_name(),
4950
common_version::version()
5051
)
5152
}
5253
Channel::Postgres => {
53-
format!("PostgreSQL 16.3 GreptimeDB {}", common_version::version())
54+
format!(
55+
"PostgreSQL 16.3 {} {}",
56+
common_version::product_name(),
57+
common_version::version()
58+
)
5459
}
5560
_ => common_version::version().to_string(),
5661
};

0 commit comments

Comments
 (0)