config

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ConfigKeyPort is the configuration key for port.
	ConfigKeyPort string = "port"
	// ConfigKeyDebugEnabled is the configuration key for debug mode.
	ConfigKeyDebugEnabled string = "debug_enabled"
	// ConfigKeyDefaultDatabase is the configuration key for default database.
	ConfigKeyDefaultDatabase string = "default_db"
	// ConfigKeyLogFileEnabled is the configuration key for enabling log file.
	ConfigKeyLogFileEnabled string = "logfile_enabled"
	// ConfigKeyTlsEnabled is the configuration key for enabling TLS.
	ConfigKeyTLSEnabled string = "tls_enabled"
	// ConfigKeyTLSClientCertAuthEnabled is the configuration key for enabling mTLS.
	ConfigKeyTLSClientCertAuthEnabled string = "tls_client_cert_auth_enabled"
	// ConfigKeyTlsCertPath is the configuration key for TLS certificate file path.
	ConfigKeyTLSCertPath string = "tls_cert_path"
	// ConfigKeyTlsPrivKeyPath is the configuration key for TLS private key file path.
	ConfigKeyTLSPrivKeyPath string = "tls_private_key_path"
	// ConfigKeyTLSCACertPath is the configuration key for TLS CA certificate file path.
	ConfigKeyTLSCACertPath string = "tls_ca_cert_path"
	// ConfigKeyMaxClientConnections is the configuration key for maximum client connections.
	ConfigKeyMaxClientConnections string = "max_client_connections"
	// ConfigKeyLogLevel is the configuration key for log level.
	ConfigKeyLogLevel string = "log_level"
	// VerboseLogsEnabled is the configuration key for enabling verbose logs.
	ConfigKeyVerboseLogsEnabled string = "verbose_logs_enabled"
	// ConfigKeyAuthEnabled is the configuration key for enabling authentication.
	ConfigKeyAuthEnabled string = "auth_enabled"
	// ConfigKeyAuthTokenSecretKey is the configuration key for setting the secret key used to sign JWT tokens.
	ConfigKeyAuthTokenSecretKey string = "auth_token_secret_key"
	// ConfigKeyAuthTokenTTL is the configuration key for setting the JWT token time to live in seconds.
	ConfigKeyAuthTokenTTL string = "auth_token_ttl"
	// ConfigKeyPassword is the configuration key for server password.
	ConfigKeyPassword string = "password"

	// EnvPrefix is the prefix that environment variables use.
	EnvPrefix string = "HAKJ"
	// EnvVarPassword is the environment variable for server password.
	EnvVarPassword string = EnvPrefix + "_PASSWORD"

	DefaultLogFileEnabled           bool   = false
	DefaultTLSEnabled               bool   = false
	DefaultTLSClientCertAuthEnabled bool   = false
	DefaultDebugEnabled             bool   = false
	DefaultVerboseLogsEnabled       bool   = false
	DefaultAuthEnabled              bool   = false
	DefaultDatabase                 string = "default"
	DefaultPassword                 string = ""
	DefaultPort                     uint16 = common.ServerDefaultPort
	DefaultLogFilePath              string = ""
	DefaultMaxKeysPerDB             uint32 = common.DbMaxKeyCount
	DefaultMaxHashMapFields         uint32 = common.HashMapMaxFields
	DefaultMaxClientConnections     uint32 = common.DefaultMaxClientConnections
	DefaultTLSCertPath              string = ""
	DefaultTLSPrivKeyPath           string = ""
	DefaultTLSCACertPath            string = ""
	DefaultLogLevel                 string = hakjdb.DefaultLogLevelStr
	DefaultAuthTokenSecretKey       string = ""
	DefaultAuthTokenTTL             uint32 = 900
)

Variables

This section is empty.

Functions

func GetCfgRegistry added in v1.2.0

func GetCfgRegistry() *viper.Viper

func GetLogLevelStr added in v1.2.0

func GetLogLevelStr() string

func GetPassword added in v1.2.0

func GetPassword() (string, bool)

GetPassword returns the server password. The returned bool is true if it is set and false if not. Clears the password after reading it so it won't live in memory improving security.

func InitCfgRegistry added in v1.2.0

func InitCfgRegistry()

Types

type ServerConfig

type ServerConfig struct {
	LogFileEnabled           bool
	TLSEnabled               bool
	TLSClientCertAuthEnabled bool
	DebugEnabled             bool
	VerboseLogsEnabled       bool
	AuthEnabled              bool

	// The name of the default database that is created at server startup.
	DefaultDB string
	// File path to the log file if it is enabled.
	// ONLY SERVER CAN CONFIGURE.
	LogFilePath string
	// The maximum number of keys a database can hold.
	// ONLY SERVER CAN CONFIGURE.
	MaxKeysPerDB uint32
	// The maximum number of fields a HashMap can hold.
	// ONLY SERVER CAN CONFIGURE.
	MaxHashMapFields uint32
	// The TCP/IP port the server listens at.
	PortInUse uint16
	// The maximum number of active client connections allowed.
	MaxClientConnections uint32

	TLSCertPath    string
	TLSPrivKeyPath string
	TLSCACertPath  string

	// Secret key used to sign JWT tokens.
	AuthTokenSecretKey string
	// JWT token time to live in seconds.
	AuthTokenTTL uint32
}

ServerConfig holds the server's configuration.

func DefaultConfig

func DefaultConfig() ServerConfig

DefaultConfig returns the default configurations.

func LoadConfig

func LoadConfig(lg hakjdb.Logger) ServerConfig

LoadConfig loads server configurations.

func (*ServerConfig) Reload added in v1.2.0

func (cfg *ServerConfig) Reload(lg hakjdb.Logger)

Reload reloads configurations that can be changed at runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL