commonConfig

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 28

README

commonConfig

commonConfig defines the application configuration model and accessors.

Configuration is loaded from a TOML file (common.toml) located under the application’s config directory (derived from paths).

Quick start

import "github.com/mt1976/frantic-core/commonConfig"

func loadConfig() *commonConfig.Settings {
    return commonConfig.Get()
}

Key points

  • Get() loads and unmarshals TOML into a Settings struct.
  • If the config file cannot be read or parsed, Get() will panic.
  • Settings includes sections for Application, Database, Server, Logging, Security, Translation, and more.

Configuration Sections

Section Key Accessors
Application GetApplication_Name(), GetApplication_Prefix(), GetApplication_HomePath(), GetApplication_Description(), GetApplication_Version(), GetApplication_Environment(), GetApplication_ReleaseDate(), GetApplication_Copyright(), GetApplication_Author(), GetApplication_License(), GetApplication_Locale(), GetApplication_Theme(), GetApplication_Timezone(), IsApplicationMode(MODE) bool
Database GetDatabase_Version(), GetDatabase_Type(), GetDatabase_Name(), GetDatabase_Path(), GetDatabase_Host(), GetDatabase_Port(), GetDatabase_User(), GetDatabase_Password(), GetDatabase_PoolSize(), GetDatabase_Timeout()
Server GetServer_Port(), GetServer_Protocol(), GetServer_Host(), GetServer_Environment(), GetServer_Compression()
Dates GetDateFormat_DateTime(), GetDateFormat_Date(), GetDateFormat_Time(), GetDateFormat_Human(), GetDateFormat_Internal(), GetDateFormat_DMY2(), GetDateFormat_YMD(), GetDateFormat_Backup(), GetDateFormat_BackupDirectory()
Logging Is{General,Timing,Service,Audit,Translation,Trace,Warning,Event,Security,Database,Api,Import,Export,Communications,Cache,Lock,Logging}Disabled(), GetLogging_MaxSize(), GetLogging_MaxBackups(), GetLogging_MaxAge(), IsLogCompressionEnabled()
Security GetSecuritySession_ExpiryPeriod(), GetSecuritySessionKey_Session(), GetServiceUser_Name(), GetServiceUser_UID(), GetServiceUser_UserCode()
Communications GetCommunicationsPushover_UserKey(), GetCommunicationsPushover_APIToken(), GetCommunicationsEmail_Host(), GetCommunicationsEmail_Port(), GetCommunicationsEmail_Sender(), GetCommunicationsEmail_AdminEmail()
Translation GetTranslationServer_Host(), GetTranslationServer_Port(), GetTranslation_Locale(), GetTranslation_PermittedOrigins(), GetTranslation_PermittedLocales(), IsPermittedTranslationLocale(string) bool, IsPermittedTranslationOrigin(string) bool
Assets GetAssets_LogoPath(), GetAssets_FaviconPath()
Backups GetBackup_RetainForDays()
Status GetStatusList(), GetStatus_Unknown(), GetStatus_Online(), GetStatus_Offline(), GetStatus_Error(), GetStatus_Warning()
Display GetDefault_Delimiter(), Delimiter()
General GetHistory_MaxHistoryEntries(), GetWorkerPoolSize()
Hosts GetValidHosts()

Application Modes

  • MODE_DEVELOPMENT
  • MODE_PRODUCTION
  • MODE_TEST

Debugging

  • (*Settings).Spew() prints a summary of the loaded config.

Documentation

Overview

Package commonConfig defines application configuration structures and accessors for dates, logging, servers, databases, assets, and security.

Index

Constants

This section is empty.

Variables

View Source
var FALSE = "false"
View Source
var TRUE = "true"

Functions

This section is empty.

Types

type MODE added in v1.2.46

type MODE struct {
	// contains filtered or unexported fields
}
var (
	MODE_DEVELOPMENT MODE = MODE{/* contains filtered or unexported fields */}
	MODE_PRODUCTION  MODE = MODE{/* contains filtered or unexported fields */}
	MODE_TEST        MODE = MODE{/* contains filtered or unexported fields */}
)

type Settings

type Settings struct {
	Application struct {
		Name        string `toml:"name"`
		Prefix      string `toml:"prefix"`
		Home        string `toml:"home"`
		Description string `toml:"description"`
		Version     string `toml:"version"`
		Environment string `toml:"environment"`
		ReleaseDate string `toml:"releaseDate"`
		Copyright   string `toml:"copyright"`
		Author      string `toml:"author"`
		License     string `toml:"license"`
		Locale      string `toml:"locale"`
		Theme       string `toml:"theme"`
		Timezone    string `toml:"timezone"`
	} `toml:"Application"`

	Database struct {
		Version  int    `toml:"version"`
		Type     string `toml:"type"`
		Host     string `toml:"host"`
		Port     int    `toml:"port"`
		Name     string `toml:"name"`
		User     string `toml:"user"`
		Pass     string `toml:"pass"`
		Path     string `toml:"path"`
		PoolSize int    `toml:"poolSize"`
		Timeout  int    `toml:"timeout"`
	} `toml:"Database"`

	Server struct {
		Host        string `toml:"host"`
		Port        int    `toml:"port"`
		Protocol    string `toml:"protocol"`
		Environment string `toml:"environment"`
		Compression bool   `toml:"compression"`
	} `toml:"Server"`

	Message struct {
		Keys struct {
			Type    string `toml:"type"`
			Title   string `toml:"title"`
			Content string `toml:"content"`
			Action  string `toml:"action"`
		} `toml:"Keys"`
	} `toml:"Message"`

	Translation struct {
		Host      string `toml:"host"`
		Port      int    `toml:"port"`
		Locale    string `toml:"locale"`
		Protocol  string `toml:"protocol"`
		Permitted struct {
			Origins []struct {
				Name string `toml:"name"`
			} `toml:"Origins"`
			Locales []struct {
				Key  string `toml:"key"`
				Name string `toml:"name"`
			} `toml:"Locales"`
		} `toml:"Permitted"`
	} `toml:"Translation"`

	Assets struct {
		Logo    string `toml:"logo"`
		Favicon string `toml:"favicon"`
	} `toml:"Assets"`

	Dates struct {
		Formats struct {
			DateTime     string `toml:"dateTime"`
			Date         string `toml:"date"`
			Time         string `toml:"time"`
			Backup       string `toml:"backup"`
			BackupFolder string `toml:"backupFolder"`
			Human        string `toml:"human"`
			DMY2         string `toml:"dmy2"`
			YMD          string `toml:"ymd"`
			Internal     string `toml:"internal"`
		} `toml:"Formats"`
	} `toml:"Dates"`

	History struct {
		MaxEntries int `toml:"maxEntries"`
	} `toml:"History"`
	Hosts []struct {
		Name string `toml:"name"`
		FQDN string `toml:"fqdn"`
		IP   string `toml:"ip"`
		Zone string `toml:"zone"`
	} `toml:"Hosts"`
	Security struct {
		Sessions struct {
			ExpiryPeriod int `toml:"expiryPeriod"`
			Keys         struct {
				Session      string `toml:"session"`
				UserKey      string `toml:"userKey"`
				UserCode     string `toml:"userCode"`
				Token        string `toml:"token"`
				ExpiryPeriod string `toml:"expiryPeriod"`
				Locale       string `toml:"locale"`
				Theme        string `toml:"theme"`
				Timezone     string `toml:"timezone"`
				Role         string `toml:"role"`
			} `toml:"Keys"`
		} `toml:"Sessions"`
		Service struct {
			UserUID  string `toml:"userUID"`
			UserName string `toml:"userName"`
		} `toml:"Service"`
	} `toml:"Security"`

	Display struct {
		Delimiter string `toml:"delim"`
	} `toml:"Display"`

	Status struct {
		UNKNOWN string `toml:"unknown"`
		ONLINE  string `toml:"online"`
		OFFLINE string `toml:"offline"`
		ERROR   string `toml:"error"`
		WARNING string `toml:"warning"`
	} `toml:"Status"`

	Communications struct {
		Pushover struct {
			UserKey  string `toml:"userKey"`
			APIToken string `toml:"apiToken"`
		} `toml:"Pushover"`
		Email struct {
			Host     string `toml:"host"`
			Port     int    `toml:"port"`
			User     string `toml:"user"`
			Password string `toml:"password"`
			From     string `toml:"from"`
			Footer   string `toml:"footer"`
			Admin    string `toml:"admin"`
		} `toml:"Email"`
	} `toml:"Communications"`
	Logging struct {
		Disable struct {
			General        string `toml:"general"`
			Timing         string `toml:"timing"`
			Service        string `toml:"service"`
			Audit          string `toml:"audit"`
			Translation    string `toml:"translation"`
			Trace          string `toml:"trace"`
			Warning        string `toml:"warning"`
			Event          string `toml:"event"`
			Security       string `toml:"security"`
			Database       string `toml:"database"`
			Api            string `toml:"api"`
			Import         string `toml:"import"`
			Export         string `toml:"export"`
			Communications string `toml:"comms"`
			Lock           string `toml:"lock"`
			Cache          string `toml:"cache"`
			Web            string `toml:"web"`
			All            string `toml:"all"`
		} `toml:"disable"`
		Defaults struct {
			MaxSize    string `toml:"maxSize"`
			MaxBackups string `toml:"maxBackups"`
			MaxAge     string `toml:"maxAge"`
			Compress   string `toml:"compress"`
		} `toml:"Defaults"`
	} `toml:"Logging"`

	Backups struct {
		RetainDays int `toml:"retainDays"`
	} `toml:"Backups"`

	WorkerPool struct {
		Size int `toml:"size"`
	} `toml:"WorkerPool"`
}

func Get

func Get() *Settings

func (*Settings) Delimiter

func (s *Settings) Delimiter() string

Delimiter returns the delimiter used to separate the display elements Deprecated: Use GetDefault_Delimiter instead

func (*Settings) GetApplication_Author added in v1.2.46

func (s *Settings) GetApplication_Author() string
func (s *Settings) GetApplication_Copyright() string

func (*Settings) GetApplication_Description added in v1.2.46

func (s *Settings) GetApplication_Description() string

func (*Settings) GetApplication_Environment added in v1.2.46

func (s *Settings) GetApplication_Environment() string

func (*Settings) GetApplication_HomePath added in v1.2.46

func (s *Settings) GetApplication_HomePath() string

func (*Settings) GetApplication_License added in v1.2.46

func (s *Settings) GetApplication_License() string

func (*Settings) GetApplication_Locale added in v1.2.46

func (s *Settings) GetApplication_Locale() string

func (*Settings) GetApplication_Name added in v1.2.46

func (s *Settings) GetApplication_Name() string

func (*Settings) GetApplication_Prefix added in v1.2.46

func (s *Settings) GetApplication_Prefix() string

func (*Settings) GetApplication_ReleaseDate added in v1.2.46

func (s *Settings) GetApplication_ReleaseDate() string

func (*Settings) GetApplication_Theme added in v1.2.67

func (s *Settings) GetApplication_Theme() string

func (*Settings) GetApplication_Timezone added in v1.2.67

func (s *Settings) GetApplication_Timezone() string

func (*Settings) GetApplication_Version added in v1.2.46

func (s *Settings) GetApplication_Version() string

func (*Settings) GetAssets_FaviconPath added in v1.2.46

func (s *Settings) GetAssets_FaviconPath() string

func (*Settings) GetAssets_LogoPath added in v1.2.46

func (s *Settings) GetAssets_LogoPath() string

func (*Settings) GetBackup_RetainForDays added in v1.2.60

func (s *Settings) GetBackup_RetainForDays() int

func (*Settings) GetCommunicationsEmail_AdminEmail added in v1.2.46

func (s *Settings) GetCommunicationsEmail_AdminEmail() string
func (s *Settings) GetCommunicationsEmail_Footer() string

func (*Settings) GetCommunicationsEmail_Host added in v1.2.46

func (s *Settings) GetCommunicationsEmail_Host() string

func (*Settings) GetCommunicationsEmail_Password added in v1.2.46

func (s *Settings) GetCommunicationsEmail_Password() string

func (*Settings) GetCommunicationsEmail_Port added in v1.2.46

func (s *Settings) GetCommunicationsEmail_Port() int

func (*Settings) GetCommunicationsEmail_PortString added in v1.2.46

func (s *Settings) GetCommunicationsEmail_PortString() string

func (*Settings) GetCommunicationsEmail_Sender added in v1.2.46

func (s *Settings) GetCommunicationsEmail_Sender() string

func (*Settings) GetCommunicationsEmail_User added in v1.2.46

func (s *Settings) GetCommunicationsEmail_User() string

func (*Settings) GetCommunicationsPushover_APIToken added in v1.2.46

func (s *Settings) GetCommunicationsPushover_APIToken() string

func (*Settings) GetCommunicationsPushover_UserKey added in v1.2.46

func (s *Settings) GetCommunicationsPushover_UserKey() string

func (*Settings) GetDatabase_Host added in v1.2.46

func (s *Settings) GetDatabase_Host() string

func (*Settings) GetDatabase_Name added in v1.2.46

func (s *Settings) GetDatabase_Name() string

func (*Settings) GetDatabase_Password added in v1.2.46

func (s *Settings) GetDatabase_Password() string

func (*Settings) GetDatabase_Path added in v1.2.46

func (s *Settings) GetDatabase_Path() string

func (*Settings) GetDatabase_PoolSize added in v1.2.46

func (s *Settings) GetDatabase_PoolSize() int

func (*Settings) GetDatabase_Port added in v1.2.46

func (s *Settings) GetDatabase_Port() int

func (*Settings) GetDatabase_PortString added in v1.2.46

func (s *Settings) GetDatabase_PortString() string

func (*Settings) GetDatabase_Timeout added in v1.2.46

func (s *Settings) GetDatabase_Timeout() int

func (*Settings) GetDatabase_Type added in v1.2.46

func (s *Settings) GetDatabase_Type() string

func (*Settings) GetDatabase_User added in v1.2.46

func (s *Settings) GetDatabase_User() string

func (*Settings) GetDatabase_Version added in v1.2.46

func (s *Settings) GetDatabase_Version() int

func (*Settings) GetDateFormat_Backup added in v1.2.46

func (s *Settings) GetDateFormat_Backup() string

func (*Settings) GetDateFormat_BackupDirectory added in v1.2.46

func (s *Settings) GetDateFormat_BackupDirectory() string

func (*Settings) GetDateFormat_DMY2 added in v1.2.46

func (s *Settings) GetDateFormat_DMY2() string

func (*Settings) GetDateFormat_Date added in v1.2.46

func (s *Settings) GetDateFormat_Date() string

func (*Settings) GetDateFormat_DateTime added in v1.2.46

func (s *Settings) GetDateFormat_DateTime() string

func (*Settings) GetDateFormat_Human added in v1.2.46

func (s *Settings) GetDateFormat_Human() string

func (*Settings) GetDateFormat_Internal added in v1.2.46

func (s *Settings) GetDateFormat_Internal() string

func (*Settings) GetDateFormat_Time added in v1.2.46

func (s *Settings) GetDateFormat_Time() string

func (*Settings) GetDateFormat_YMD added in v1.2.46

func (s *Settings) GetDateFormat_YMD() string

func (*Settings) GetDefault_Delimiter added in v1.2.46

func (s *Settings) GetDefault_Delimiter() string

GetDefault_Delimiter returns the delimiter used to separate the display elements

func (*Settings) GetDisplayDelimiter

func (s *Settings) GetDisplayDelimiter() string

GetDisplayDelimiter returns the delimiter used to separate the display elements Deprecated: Use GetDefault_Delimiter instead

func (*Settings) GetHistory_MaxHistoryEntries added in v1.2.46

func (s *Settings) GetHistory_MaxHistoryEntries() int

func (*Settings) GetLocaleName

func (s *Settings) GetLocaleName(in string) string

func (*Settings) GetLogging_MaxAge added in v1.2.46

func (s *Settings) GetLogging_MaxAge() int

func (*Settings) GetLogging_MaxBackups added in v1.2.46

func (s *Settings) GetLogging_MaxBackups() int

func (*Settings) GetLogging_MaxSize added in v1.2.46

func (s *Settings) GetLogging_MaxSize() int

func (*Settings) GetMessageKey_Action added in v1.2.46

func (s *Settings) GetMessageKey_Action() string

func (*Settings) GetMessageKey_Content added in v1.2.46

func (s *Settings) GetMessageKey_Content() string

func (*Settings) GetMessageKey_Title added in v1.2.46

func (s *Settings) GetMessageKey_Title() string

func (*Settings) GetMessageKey_Type added in v1.2.46

func (s *Settings) GetMessageKey_Type() string

func (*Settings) GetSecuritySessionKey_ExpiryPeriod added in v1.2.46

func (s *Settings) GetSecuritySessionKey_ExpiryPeriod() string

func (*Settings) GetSecuritySessionKey_Locale added in v1.2.66

func (s *Settings) GetSecuritySessionKey_Locale() string

func (*Settings) GetSecuritySessionKey_Session added in v1.2.46

func (s *Settings) GetSecuritySessionKey_Session() string

func (*Settings) GetSecuritySessionKey_Theme added in v1.2.66

func (s *Settings) GetSecuritySessionKey_Theme() string

func (*Settings) GetSecuritySessionKey_Timezone added in v1.2.66

func (s *Settings) GetSecuritySessionKey_Timezone() string

func (*Settings) GetSecuritySessionKey_Token added in v1.2.46

func (s *Settings) GetSecuritySessionKey_Token() string

func (*Settings) GetSecuritySessionKey_UserCode added in v1.2.46

func (s *Settings) GetSecuritySessionKey_UserCode() string

func (*Settings) GetSecuritySessionKey_UserKey added in v1.2.46

func (s *Settings) GetSecuritySessionKey_UserKey() string

func (*Settings) GetSecuritySessionKey_UserRole added in v1.2.68

func (s *Settings) GetSecuritySessionKey_UserRole() string

func (*Settings) GetSecuritySession_ExpiryPeriod added in v1.2.46

func (s *Settings) GetSecuritySession_ExpiryPeriod() int

/ SECURITY SESSION

func (*Settings) GetServer_Compression added in v1.2.72

func (s *Settings) GetServer_Compression() bool

func (*Settings) GetServer_CompressionString added in v1.2.72

func (s *Settings) GetServer_CompressionString() string

func (*Settings) GetServer_Environment added in v1.2.72

func (s *Settings) GetServer_Environment() string

func (*Settings) GetServer_Host added in v1.2.46

func (s *Settings) GetServer_Host() string

func (*Settings) GetServer_Port added in v1.2.46

func (s *Settings) GetServer_Port() int

func (*Settings) GetServer_PortString added in v1.2.46

func (s *Settings) GetServer_PortString() string

func (*Settings) GetServer_Protocol added in v1.2.46

func (s *Settings) GetServer_Protocol() string

func (*Settings) GetServiceUser_Name added in v1.2.46

func (s *Settings) GetServiceUser_Name() string

/ SECURITY SESSION SERVICE USER

func (*Settings) GetServiceUser_UID added in v1.2.46

func (s *Settings) GetServiceUser_UID() string

func (*Settings) GetServiceUser_UserCode added in v1.2.46

func (s *Settings) GetServiceUser_UserCode() string

func (*Settings) GetStatusList added in v1.2.46

func (s *Settings) GetStatusList() []string

/ STATUS

func (*Settings) GetStatus_Error

func (s *Settings) GetStatus_Error() string

func (*Settings) GetStatus_Offline

func (s *Settings) GetStatus_Offline() string

func (*Settings) GetStatus_Online

func (s *Settings) GetStatus_Online() string

func (*Settings) GetStatus_Unknown

func (s *Settings) GetStatus_Unknown() string

func (*Settings) GetStatus_Warning

func (s *Settings) GetStatus_Warning() string

func (*Settings) GetTranslationServer_Host added in v1.2.46

func (s *Settings) GetTranslationServer_Host() string

func (*Settings) GetTranslationServer_Port added in v1.2.46

func (s *Settings) GetTranslationServer_Port() int

func (*Settings) GetTranslationServer_PortString added in v1.2.46

func (s *Settings) GetTranslationServer_PortString() string

func (*Settings) GetTranslationServer_Protocol added in v1.2.46

func (s *Settings) GetTranslationServer_Protocol() string

func (*Settings) GetTranslation_Locale added in v1.2.46

func (s *Settings) GetTranslation_Locale() string

func (*Settings) GetTranslation_PermittedLocales added in v1.2.46

func (s *Settings) GetTranslation_PermittedLocales() []struct {
	Key  string "toml:\"key\""
	Name string "toml:\"name\""
}

func (*Settings) GetTranslation_PermittedOrigins added in v1.2.46

func (s *Settings) GetTranslation_PermittedOrigins() []string

func (*Settings) GetValidHosts

func (s *Settings) GetValidHosts() []struct {
	Name string "toml:\"name\""
	FQDN string "toml:\"fqdn\""
	IP   string "toml:\"ip\""
	Zone string "toml:\"zone\""
}

func (*Settings) GetWorkerPoolSize added in v1.20.0

func (s *Settings) GetWorkerPoolSize() int

func (*Settings) IsApiLoggingDisabled

func (s *Settings) IsApiLoggingDisabled() bool

func (*Settings) IsApplicationMode

func (s *Settings) IsApplicationMode(inMode MODE) bool

func (*Settings) IsAuditLoggingDisabled

func (s *Settings) IsAuditLoggingDisabled() bool

func (*Settings) IsCacheLoggingDisabled added in v1.5.0

func (s *Settings) IsCacheLoggingDisabled() bool

func (*Settings) IsCommunicationsLoggingDisabled added in v1.2.41

func (s *Settings) IsCommunicationsLoggingDisabled() bool

func (*Settings) IsDatabaseLoggingDisabled

func (s *Settings) IsDatabaseLoggingDisabled() bool

func (*Settings) IsEventLoggingDisabled

func (s *Settings) IsEventLoggingDisabled() bool

func (*Settings) IsExportLoggingDisabled added in v1.2.32

func (s *Settings) IsExportLoggingDisabled() bool

func (*Settings) IsGeneralLoggingDisabled

func (s *Settings) IsGeneralLoggingDisabled() bool

func (*Settings) IsImportLoggingDisabled added in v1.2.32

func (s *Settings) IsImportLoggingDisabled() bool

func (*Settings) IsLockLoggingDisabled added in v1.3.8

func (s *Settings) IsLockLoggingDisabled() bool

func (*Settings) IsLogCompressionEnabled

func (s *Settings) IsLogCompressionEnabled() bool

func (*Settings) IsLoggingDisabled added in v1.2.46

func (s *Settings) IsLoggingDisabled() bool

func (*Settings) IsPermittedTranslationLocale added in v1.2.46

func (s *Settings) IsPermittedTranslationLocale(in string) bool

func (*Settings) IsPermittedTranslationOrigin added in v1.2.46

func (s *Settings) IsPermittedTranslationOrigin(in string) bool

func (*Settings) IsSecurityLoggingDisabled

func (s *Settings) IsSecurityLoggingDisabled() bool

func (*Settings) IsServiceLoggingDisabled

func (s *Settings) IsServiceLoggingDisabled() bool

func (*Settings) IsTimingLoggingDisabled

func (s *Settings) IsTimingLoggingDisabled() bool

func (*Settings) IsTraceLoggingDisabled

func (s *Settings) IsTraceLoggingDisabled() bool

func (*Settings) IsTranslationLoggingDisabled

func (s *Settings) IsTranslationLoggingDisabled() bool

func (*Settings) IsWarningLoggingDisabled

func (s *Settings) IsWarningLoggingDisabled() bool

func (*Settings) IsWebLoggingDisabled added in v1.21.0

func (s *Settings) IsWebLoggingDisabled() bool

func (*Settings) SEP

func (s *Settings) SEP() string

SEP returns the delimiter used to separate the display elements Deprecated: Use Delimiter instead

func (*Settings) Spew

func (s *Settings) Spew()

Jump to

Keyboard shortcuts

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