yats.git

commit ed845cee69a30ab261c3f6a76ae4787dae359f64

Author: Paolo Lulli <paolo@lulli.net>

Refactor conf names

 server/config/config.go | 20 ++++++++++----------
 server/db/connection.go | 6 +++---
 server/maintenance.go | 8 ++++----
 server/service-rest.go | 2 +-
 server/yats.go | 10 +++++-----


diff --git a/server/config/config.go b/server/config/config.go
index c65008264d5cd2ff0757dede18dde3c8a84b7b8b..2864005276045c5cbed4eceb7bd29f990621cbdb 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -36,18 +36,18 @@ 	fmt.Println(interval) //print the enum value
 }
 
 type Configuration struct {
-	DB_USERNAME string `json:"databaseUsername"`
-	DB_PASSWORD string `json:"databasePassword"`
-	DB_PORT     string `json:"databasePort"`
-	DB_HOST     string `json:"databaseHost"`
-	DB_NAME     string `json:"databaseSchema"`
+	DbUsername string `json:"databaseUsername"`
+	DbPassword string `json:"databasePassword"`
+	DbPort     string `json:"databasePort"`
+	DbHost     string `json:"databaseHost"`
+	DbName     string `json:"databaseSchema"`
 
-	REST_ADDRESS string `json:"restAddress"`
-	GRPC_ADDRESS string `json:"grpcAddress"`
+	RestAddress string `json:"restAddress"`
+	GrpcAddress string `json:"grpcAddress"`
 
-	ARCHIVE_FREQUENCY string `json:"archiveFrequency"`
-	ARCHIVE_DIRECTORY string `json:"archiveDirectory"`
-	IS_ARCHIVE_NODE   string `json:"archiveNode"`
+	ArchiveFrequency string `json:"archiveFrequency"`
+	ArchiveDirectory string `json:"archiveDirectory"`
+	IsArchiveNode    string `json:"archiveNode"`
 }
 
 func GetConfig(fileName string) Configuration {




diff --git a/server/db/connection.go b/server/db/connection.go
index 175a5ea109281f300077b097bcd972b3bb0b14d2..c9455a74a635b5d8b17fabaf0050dd26934b7f5b 100644
--- a/server/db/connection.go
+++ b/server/db/connection.go
@@ -18,9 +18,9 @@
 var Session *gocql.Session
 
 func InitializeDb(configuration config.Configuration) *gocql.Session {
-	cluster := gocql.NewCluster(configuration.DB_HOST)
-	cluster.Authenticator = gocql.PasswordAuthenticator{Username: configuration.DB_USERNAME, Password: configuration.DB_PASSWORD}
-	cluster.Keyspace = configuration.DB_NAME
+	cluster := gocql.NewCluster(configuration.DbHost)
+	cluster.Authenticator = gocql.PasswordAuthenticator{Username: configuration.DbUsername, Password: configuration.DbPassword}
+	cluster.Keyspace = configuration.DbName
 
 	Session, _ := cluster.CreateSession()
 




diff --git a/server/maintenance.go b/server/maintenance.go
index 593adc1299fb85033fe15b27ba68f59339bbba33..1fe1148178fe4ebcc3c64cb55a95451c884a5752 100644
--- a/server/maintenance.go
+++ b/server/maintenance.go
@@ -21,7 +21,7 @@ 	"yats-server/model"
 )
 
 func calculateParquetDirName(cfg config.Configuration, t time.Time, id_client string, item string) string {
-	baseParquetDir := cfg.ARCHIVE_DIRECTORY
+	baseParquetDir := cfg.ArchiveDirectory
 	previousMonth := dates.CalculatePreviousMonth(t)
 	parquetDirName := fmt.Sprintf("%s/%s/%s/%s", baseParquetDir, id_client, item, previousMonth)
 	return parquetDirName
@@ -32,15 +32,15 @@ 	fmt.Println("Called createParquetDir")
 	parquetDir := calculateParquetDirName(cfg, t, id_client, item)
 
 	/*
-		if cfg.ARCHIVE_FREQUENCY == "daily" {
+		if cfg.ArchiveFrequency == "daily" {
 			parquetDir = fmt.Sprintf("%s/%s/%s/%s", baseParquetDir, id_client, item, dates.YYYYMMDD(t))
 		}
 
-		if cfg.ARCHIVE_FREQUENCY == "weekly" {
+		if cfg.ArchiveFrequency == "weekly" {
 			parquetDir = fmt.Sprintf("%s/%s/%s/%s", baseParquetDir, id_client, item, dates.YYYYWW(t))
 		}
 
-		if cfg.ARCHIVE_FREQUENCY == "monthly" {
+		if cfg.ArchiveFrequency == "monthly" {
 			parquetDir = fmt.Sprintf("%s/%s/%s/%s", baseParquetDir, id_client, item, dates.YYYYMM(t))
 		}
 	*/




diff --git a/server/service-rest.go b/server/service-rest.go
index 7830d593602b833e7250e865e1d3ae1daf2152ee..c39d57638b636f1a094d377001efec7ede058be7 100644
--- a/server/service-rest.go
+++ b/server/service-rest.go
@@ -20,7 +20,7 @@
 func RestService(c config.Configuration) {
 
 	//	session = DB
-	address := c.REST_ADDRESS
+	address := c.RestAddress
 
 	router := gin.Default()
 	router.Use(CorsHeaders())




diff --git a/server/yats.go b/server/yats.go
index 827bed380be92e6b4f0774cad21430cd63dc1628..9d363f858e10bb76b3cfcb417b8b0c0fefbbe7a5 100644
--- a/server/yats.go
+++ b/server/yats.go
@@ -34,16 +34,16 @@ 	}
 
 	db.Session = db.InitializeDb(configuration)
 
-	if configuration.IS_ARCHIVE_NODE == "true" {
+	if configuration.IsArchiveNode == "true" {
 		fmt.Println("Starting Archive Node")
 		go MaintenanceThread(configuration)
 	}
 
-	if configuration.GRPC_ADDRESS != "" {
-		fmt.Printf("Starting GRPC Server on address: %s\n", configuration.GRPC_ADDRESS)
-		go grpc.RunYatsGrpcServer(configuration.GRPC_ADDRESS)
+	if configuration.GrpcAddress != "" {
+		fmt.Printf("Starting GRPC Server on address: %s\n", configuration.GrpcAddress)
+		go grpc.RunYatsGrpcServer(configuration.GrpcAddress)
 	}
 
-	fmt.Printf("Starting REST Server on address: %s\n", configuration.REST_ADDRESS)
+	fmt.Printf("Starting REST Server on address: %s\n", configuration.RestAddress)
 	RestService(configuration)
 }