From c359db621539f0d4fcad9a397f3a02197191be62 Mon Sep 17 00:00:00 2001 From: Lukasz Antoniak Date: Tue, 2 Jul 2024 12:42:05 +0200 Subject: [PATCH] Apply review comments --- README.md | 2 +- RELEASE_PROCESS.md | 2 +- proxy/launch.go | 14 ++++++-------- proxy/main.go | 5 +---- proxy/main_profiling.go | 5 +---- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e1ae8bf..917a4c8 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ export ZDM_TARGET_PASSWORD=cassandra \ ./zdm-proxy-v2.0.0 # run the ZDM proxy executable ``` -If you prefer to use YAML configuration file, analogical setup would look like: +If you prefer to use YAML configuration file, an equivalent setup would look like: ```shell $ cat zdm-config.yml diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index 02e01b7..811053d 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -8,7 +8,7 @@ All published container images can be found at [https://hub.docker.com/r/datasta Before triggering the build and publish process for an official/stable release, three files need to be updated, the `RELEASE_NOTES`, `CHANGELOG` and `main.go`. -Please update the ZDM version displayed during component startup in `main.go`: +Please update the ZDM version displayed during component startup in `launch.go`: ```go const ZdmVersionString = "2.0.0" ``` diff --git a/proxy/launch.go b/proxy/launch.go index 36a0e09..1edcbfa 100644 --- a/proxy/launch.go +++ b/proxy/launch.go @@ -15,8 +15,8 @@ import ( // TODO: to be managed externally const ZdmVersionString = "2.2.0" -var displayVersionOpt = flag.Bool("version", false, "display the ZDM proxy version and exit") -var configFileOpt = flag.String("config", "", "specify path to ZDM configuration file") +var displayVersion = flag.Bool("version", false, "display the ZDM proxy version and exit") +var configFile = flag.String("config", "", "specify path to ZDM configuration file") func runSignalListener(cancelFunc context.CancelFunc) { sigCh := make(chan os.Signal, 1) @@ -31,18 +31,16 @@ func runSignalListener(cancelFunc context.CancelFunc) { }() } -func displayVersion() { - if *displayVersionOpt { +func launchProxy(profilingSupported bool) { + if *displayVersion { fmt.Printf("ZDM proxy version %v\n", ZdmVersionString) - os.Exit(0) + return } // Always record version information (very) early in the log log.Infof("Starting ZDM proxy version %v", ZdmVersionString) -} -func launchProxy(profilingSupported bool, configFile string) { - conf, err := config.New().LoadConfig(configFile) + conf, err := config.New().LoadConfig(*configFile) if err != nil { log.Errorf("Error loading configuration: %v. Aborting startup.", err) diff --git a/proxy/main.go b/proxy/main.go index c219c82..d9361b4 100644 --- a/proxy/main.go +++ b/proxy/main.go @@ -10,10 +10,7 @@ import ( ) func main() { - flag.Parse() - displayVersion() - - launchProxy(false, *configFileOpt) + launchProxy(false) } diff --git a/proxy/main_profiling.go b/proxy/main_profiling.go index bb019d7..9589607 100644 --- a/proxy/main_profiling.go +++ b/proxy/main_profiling.go @@ -17,11 +17,8 @@ var cpuProfile = flag.String("cpu_profile", "", "write cpu profile to the specif var memProfile = flag.String("mem_profile", "", "write memory profile to the specified file") func main() { - flag.Parse() - displayVersion() - // the cpu profiling is enabled at startup and is periodically collected while the proxy is running // if cpu profiling is requested, any error configuring or starting it will cause the proxy startup to fail if *cpuProfile != "" { @@ -63,5 +60,5 @@ func main() { }() } - launchProxy(true, configFileOpt) + launchProxy(true) }