runtime

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Domain  = version.Domain
	Block   = true
	Trace   = false
	Addr    = ":8080"
	Project = ""
	Level   = "debug"
	Mode    = RunModeLocal

	// DeviceID 主机设备ID
	DeviceID = xerror.ExitErr(machineid.ID())

	// AppID service id
	AppID = uuid.New().String()

	Signal os.Signal = syscall.Signal(0)

	// Pwd 当前目录
	Pwd = xerror.ExitErr(os.Getwd()).(string)

	// Hostname 主机名
	Hostname = utils.FirstFnNotEmpty(
		func() string { return os.Getenv("HOSTNAME") },
		func() string {
			var h, err = os.Hostname()
			xerror.Exit(err)
			return h
		},
	)

	// Namespace 命名空间
	Namespace = utils.FirstFnNotEmpty(
		func() string { return os.Getenv("NAMESPACE") },
		func() string { return os.Getenv("POD_NAMESPACE") },
		func() string {
			if data, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace"); err == nil {
				if ns := strings.TrimSpace(string(data)); len(ns) > 0 {
					return ns
				}
			}
			return ""
		},
	)
)

默认的全局配置

Functions

func GetVersion

func GetVersion() map[string]interface{}

func IsDev

func IsDev() bool

func IsK8s added in v0.2.0

func IsK8s() bool

func IsLocal added in v0.2.0

func IsLocal() bool

func IsProd

func IsProd() bool

func IsRelease

func IsRelease() bool

func IsStag

func IsStag() bool

func IsTest

func IsTest() bool

Types

type RunMode

type RunMode int32
const (
	RunModeLocal   RunMode = 0
	RunModeDev     RunMode = 1
	RunModeTest    RunMode = 2
	RunModeStag    RunMode = 3
	RunModeProd    RunMode = 4
	RunModeRelease RunMode = 5
)

func (RunMode) String

func (x RunMode) String() string

Jump to

Keyboard shortcuts

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