env

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 16 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigAsJSON

func GetConfigAsJSON() string

func GetDefaultSystemConfig

func GetDefaultSystemConfig() config.SystemConfig

func GetModuleConfig

func GetModuleConfig(name string) *config.Config

GetModuleConfig return specify module's config

func GetPluginConfig

func GetPluginConfig(name string) *config.Config

GetPluginConfig return specify plugin's config

func GetStartTime

func GetStartTime() time.Time

func LoadConfigContents

func LoadConfigContents(path string) (contents string, err error)

LoadConfigContents reads contents from the given path, and renders template variables if necessary.

func ParseConfig

func ParseConfig(configKey string, configInstance interface{}) (exist bool, err error)

func ParseConfigSection

func ParseConfigSection(cfg *config.Config, configKey string, configInstance interface{}) (exist bool, err error)

Types

type Application

type Application struct {
	Name    string  `json:"name,omitempty" elastic_mapping:"name:{type:keyword,fields:{text: {type: text}}}"`
	Version Version `json:"version,omitempty" elastic_mapping:"version: { type: object }"`
	Tagline string  `json:"tagline,omitempty" elastic_mapping:"tagline: { type: keyword }"`
}

type Env

type Env struct {

	// static configs
	SystemConfig *config.SystemConfig

	IsDebug       bool
	IsDaemonMode  bool
	ISServiceMode bool

	LoggingLevel string

	IgnoreOnConfigMissing bool
	// contains filtered or unexported fields
}

Env is environment object of app

func EmptyEnv

func EmptyEnv() *Env

func NewEnv

func NewEnv(name, desc, ver, buildNumber, commit, buildDate, eolDate, terminalHeader, terminalFooter string) *Env

EmptyEnv return a empty env instance

func (*Env) CheckSetup

func (env *Env) CheckSetup()

func (*Env) EnableSetup

func (env *Env) EnableSetup(b bool)

func (*Env) GetAppCapitalName

func (env *Env) GetAppCapitalName() string

func (*Env) GetAppDesc

func (env *Env) GetAppDesc() string

func (*Env) GetAppLowercaseName

func (env *Env) GetAppLowercaseName() string

func (*Env) GetAppName

func (env *Env) GetAppName() string

func (*Env) GetApplicationInfo

func (env *Env) GetApplicationInfo() Application

func (*Env) GetBuildDate

func (env *Env) GetBuildDate() time.Time

GetBuildDate returns the build datetime of current package

func (*Env) GetBuildNumber

func (env *Env) GetBuildNumber() string

func (*Env) GetConfig

func (env *Env) GetConfig(key string, defaultV string) (string, bool)

lowercase, get configs from defaults>env>config

func (*Env) GetConfigDir

func (env *Env) GetConfigDir() string

func (*Env) GetConfigFile

func (env *Env) GetConfigFile() string

func (*Env) GetDataDir

func (env *Env) GetDataDir() string

GetDataDir returns root working dir of app instance

func (*Env) GetEOLDate

func (env *Env) GetEOLDate() time.Time

func (*Env) GetGoodbyeMessage

func (env *Env) GetGoodbyeMessage() string

func (*Env) GetHTTPClientConfig added in v1.1.0

func (env *Env) GetHTTPClientConfig(name, endpoint string) *config.HTTPClientConfig

func (*Env) GetLastCommitHash

func (env *Env) GetLastCommitHash() string

func (*Env) GetLastFrameworkCommitHash added in v1.1.0

func (env *Env) GetLastFrameworkCommitHash() string

func (*Env) GetLastFrameworkVendorCommitHash added in v1.1.0

func (env *Env) GetLastFrameworkVendorCommitHash() string

func (*Env) GetLogDir

func (env *Env) GetLogDir() string

func (*Env) GetOverallHealth

func (env *Env) GetOverallHealth() HealthType

func (*Env) GetPluginDir

func (env *Env) GetPluginDir() string

func (*Env) GetServicesHealth

func (env *Env) GetServicesHealth() map[string]string

func (*Env) GetState

func (env *Env) GetState() int32

func (*Env) GetVersion

func (env *Env) GetVersion() string

GetVersion returns the version of this build

func (*Env) GetVersionInfo

func (env *Env) GetVersionInfo() Version

func (*Env) GetWelcomeMessage

func (env *Env) GetWelcomeMessage() string

func (*Env) Init

func (env *Env) Init() *Env

Environment create a new env instance from a config

func (*Env) InitPaths

func (env *Env) InitPaths(cfgPath string) error

func (*Env) RefreshConfig

func (env *Env) RefreshConfig() error

func (*Env) ReportHealth

func (env *Env) ReportHealth(service string, health HealthType)

func (*Env) SetConfigFile

func (env *Env) SetConfigFile(configFile string) *Env

func (*Env) SetupRequired

func (env *Env) SetupRequired() bool

func (*Env) UpdateState

func (env *Env) UpdateState(i int32)

type HealthType

type HealthType int
const HEALTH_GREEN HealthType = 1
const HEALTH_RED HealthType = 3
const HEALTH_UNAVAILABLE HealthType = 4
const HEALTH_UNKNOWN HealthType = 0
const HEALTH_YELLOW HealthType = 2

func GetHealthType

func GetHealthType(health string) HealthType

func (HealthType) ToString

func (h HealthType) ToString() string

type Version

type Version struct {
	VersionNumber                  string `json:"number,omitempty"`
	FrameworkBuildCommitHash       string `json:"framework_hash,omitempty"`
	FrameworkVendorBuildCommitHash string `json:"vendor_hash,omitempty"`
	BuildCommitHash                string `json:"build_hash,omitempty"`
	BuildDate                      string `json:"build_date,omitempty"`
	BuildNumber                    string `json:"build_number,omitempty"`
	EolDate                        string `json:"eol_date,omitempty"`
}

Jump to

Keyboard shortcuts

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