runmode

package
v0.2.10 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Domain  = "lava"
	Block   = true
	Project = env.Get("app_name", "service_name", "project_name")
	Level   = "debug"

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

	// InstanceID service id
	InstanceID = 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 ""
		},
	)
)

默认的全局配置

View Source
var Mode = Local

Functions

func GetVersion

func GetVersion() map[string]interface{}

func IsDev

func IsDev() bool

func IsK8s

func IsK8s() bool

func IsLocal

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 (
	Local   RunMode = 0
	Dev     RunMode = 1
	Test    RunMode = 2
	Stag    RunMode = 3
	Prod    RunMode = 4
	Release 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