yats.git

ref: dbf87a3a1c67949d89ef6fd35e66a13b839e0f3b

server/config/config.go


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
 * Yats - yats
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Paolo Lulli <kevwe.com>
 * @copyright Paolo Lulli 2024
 */

package config

import (
	"github.com/tkanos/gonfig"
)

type ArchiveFrequency int

const (
	Daily ArchiveFrequency = iota
	Weekly
	Monthly
)

var archFrequency = map[string]ArchiveFrequency{
	"daily":   Daily,
	"weekly":  Weekly,
	"monthly": Monthly,
}

type Configuration struct {
	DbUsername string `json:"databaseUsername"`
	DbPassword string `json:"databasePassword"`
	DbPort     string `json:"databasePort"`
	DbHost     string `json:"databaseHost"`
	DbName     string `json:"databaseSchema"`

	RestAddress string `json:"restAddress"`
	GrpcAddress string `json:"grpcAddress"`
	TcpAddress  string `json:"tcpAddress"`

	ArchiveFrequency string `json:"archiveFrequency"`
	ArchiveDirectory string `json:"archiveDirectory"`
	IsArchiveNode    string `json:"archiveNode"`

	TlsActive      string `json:"tlsActive"`
	TlsKeyFile     string `json:"tlsKeyFile"`
	TlsCertificate string `json:"tlsCertificate"`
	TlsCA          string `json:"tlsCA"`

	LogFile       string `json:"logFile"`
	GrafanaActive string `json:"grafanaActive"`

	FormatOutput string `json:"formatOutput"`
}

func GetConfig(fileName string) Configuration {
	configuration := Configuration{}
	gonfig.GetConf(fileName, &configuration)

	return configuration
}