env

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 6 Imported by: 0

README

env

这是一组通用的api,为应用程序提供运行环境方面的信息

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeEnvName

func ComputeEnvName(c *Want) string

ComputeEnvName 根据条件取环境变量名称

func ComputePropertyName

func ComputePropertyName(c *Want) string

ComputePropertyName 根据条件取属性名称

func ListEnvNames

func ListEnvNames(app string) []string

ListEnvNames 列出可能的环境变量名称

func ListPropertyNames

func ListPropertyNames(app string) []string

ListPropertyNames 列出可能的属性名称

func NewMainModule

func NewMainModule() *application.ModuleBuilder

NewMainModule ...

func NewTestModule

func NewTestModule() *application.ModuleBuilder

NewTestModule ...

func SetDefaultAppName

func SetDefaultAppName(name string)

SetDefaultAppName 设置默认的应用程序名称 这个函数是一次性的,一旦设置成功,后续的调用将无效

Types

type Category

type Category string

Category ...内容分类 [data|code|config|setting|...]

const (
	CategoryData    Category = "data"
	CategoryCode    Category = "code"
	CategoryConfig  Category = "config"
	CategorySetting Category = "setting"
	CategoryHome    Category = "home"
)

定义内容分类

type Context

type Context interface {
	AppName() string

	Query(c *Want) (*Have, error)

	GetPath(c *Want) afs.Path

	GetEnvironment() environment.Table

	GetProperties() properties.Table
}

Context ...

type Have

type Have struct {
	Want *Want
	Path afs.Path
}

Have ... 表示查询结果

type Locator

type Locator interface {
	Locate(q *Query, chain LocatorChain) error
}

Locator ...

type LocatorChain

type LocatorChain interface {
	Locate(q *Query) error
}

LocatorChain ...

type LocatorRegistration

type LocatorRegistration struct {
	Locator  Locator
	Enabled  bool
	Priority int // 优先级越高,越靠近处理链条前端
}

LocatorRegistration ...

type LocatorRegistry

type LocatorRegistry interface {
	Registrations() []*LocatorRegistration
}

LocatorRegistry ...

type Query

type Query struct {
	Want *Want
	Have *Have
}

Query 表示查询文件系统中的某个位置

type Scope

type Scope string

Scope ...作用域[application|system]

const (
	ScopeDefault Scope = ""
	ScopeApp     Scope = "application"
	ScopeSystem  Scope = "system"
)

定义作用域

type Service

type Service interface {
	ForApp(appName string) Context
}

Service ... 对外提供环境信息的服务

type User

type User string

User ...用户范围[current|share]

const (
	UserDefault User = ""
	UserCurrent User = "current"
	UserShare   User = "share"
)

定义用户范围

type Want

type Want struct {
	App      string // the simple-app-name
	Env      string // 环境变量名称
	Property string // 属性名称

	Category Category
	Scope    Scope
	User     User
}

Want ... 表示查询条件

Directories

Path Synopsis
gen
modules
env
src
configen/golang command
main/golang command
test/golang command

Jump to

Keyboard shortcuts

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