app

package
v0.0.0-...-418145e Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Config = system.Config

	// ProfilesInclude is the property that allow user include profiles at runtime
	ProfilesInclude = "app.profiles.include"

	// Version is the property key of app.version
	Version = "app.version"
)
View Source
const (
	ApplicationContextName = "app.applicationContext"
)

Variables

View Source
var (

	// Profiles include profiles initially
	Profiles []string

	// ErrInvalidObjectType indicates that configuration type is invalid
	ErrInvalidObjectType = errors.New("[app] invalid Configuration type, one of app.Configuration need to be embedded")
)

Functions

func ConfigureHostServe

func ConfigureHostServe(cb ...func(host.TaskHost))

func IncludeProfiles

func IncludeProfiles(profiles ...string)

IncludeProfiles include specific profiles

func Register

func Register(params ...interface{})

Register register a struct instance or constructor (func), so that it will be injectable.

func RegisterOneShutdown

func RegisterOneShutdown(p interface{})

注册一个

func RegisterPostProcessor

func RegisterPostProcessor(p ...interface{})

RegisterPostProcessor register post processor

func RegisterShutdown

func RegisterShutdown(p ...interface{})

注册一组

func RegisterStartupAction

func RegisterStartupAction(p ...interface{})

注册一组startupAction

Types

type Application

type Application interface {
	Initialize() error
	SetProperty(name string, value ...interface{}) Application
	GetProperty(name string) (value interface{}, ok bool)
	SetAddCommandLineProperties(enabled bool) Application
	Run()

	ConfigurableFactory() factory.ConfigurableFactory
	SystemConfig() *system.Configuration

	//获取serviceProvider
	GetServiceProvider() IServiceProvider
	// 运行启动时行为
	Build() Application
	RunStartup()
	//shutdown
	Shutdown()
}
var (
	HostApplication Application
)

type ApplicationContext

type ApplicationContext interface {
	IServiceProvider
	GetProperty(name string) (value interface{}, ok bool)
}

ApplicationContext is the alias interface of Application

var (
	Context ApplicationContext
)

type BaseApplication

type BaseApplication struct {
	WorkDir string
	// contains filtered or unexported fields
}

BaseApplication is the base application

func (*BaseApplication) AfterInitialization

func (a *BaseApplication) AfterInitialization(configs ...cmap.ConcurrentMap)

初始化完后执行的post行为

func (*BaseApplication) Build

func (a *BaseApplication) Build() Application

构建应用运行所需的环境

func (*BaseApplication) BuildConfigurations

func (a *BaseApplication) BuildConfigurations() (err error)

获取BuildConfigurations对象

func (*BaseApplication) ConfigurableFactory

func (a *BaseApplication) ConfigurableFactory() factory.ConfigurableFactory

func (*BaseApplication) GetInstance

func (a *BaseApplication) GetInstance(params ...interface{}) (instance interface{})

从ioc容器中获取对象实例

func (*BaseApplication) GetListByBaseInterface

func (a *BaseApplication) GetListByBaseInterface(interfaceInstance interface{}) (instanceList []interface{})

func (*BaseApplication) GetProperty

func (a *BaseApplication) GetProperty(name string) (value interface{}, ok bool)

获取应用属性

func (*BaseApplication) GetServiceProvider

func (a *BaseApplication) GetServiceProvider() IServiceProvider

func (*BaseApplication) Initialize

func (a *BaseApplication) Initialize() (err error)

初始化应用

func (*BaseApplication) RegistInstance

func (a *BaseApplication) RegistInstance(instance interface{}) error

func (*BaseApplication) RegistInstanceAs

func (a *BaseApplication) RegistInstanceAs(instance interface{}, typ interface{}) error

注册一个服务 instance 服务实例 typ 要注册的类型实例

func (*BaseApplication) Run

func (a *BaseApplication) Run()

启动应用,继承类实现

func (*BaseApplication) RunStartup

func (a *BaseApplication) RunStartup()

运行启动时行为

func (*BaseApplication) SetAddCommandLineProperties

func (a *BaseApplication) SetAddCommandLineProperties(enabled bool) Application

SetAddCommandLineProperties set add command line properties to be enabled or disabled

func (*BaseApplication) SetInstance

func (a *BaseApplication) SetInstance(params ...interface{}) (err error)

func (*BaseApplication) SetProperty

func (a *BaseApplication) SetProperty(name string, value ...interface{}) Application

SetProperty set application property should be able to set property from source code by SetProperty, it can be override by program argument, e.g. myapp --app.profiles.active=dev

func (*BaseApplication) Shutdown

func (a *BaseApplication) Shutdown()

shutdown 应用

func (*BaseApplication) SystemConfig

func (a *BaseApplication) SystemConfig() *system.Configuration

返回应用系统配置

type Configuration

type Configuration struct {
	RuntimeDeps factory.Deps
}

应用配置基类

type IServiceProvider

type IServiceProvider interface {
	SetInstance(params ...interface{}) (err error)
	GetInstance(params ...interface{}) (instance interface{})
	GetListByBaseInterface(interfaceInstance interface{}) (instanceList []interface{})

	//注册一个服务
	//instance 服务实例
	//typ 要注册的类型实例
	RegistInstanceAs(instance interface{}, typ interface{}) error
	RegistInstance(instance interface{}) error
}

type IShutdownAction

type IShutdownAction interface {
	Run()
}

用于shutdown处理

func NewShutdownAction

func NewShutdownAction(runFunc func()) IShutdownAction

使用函数创建一个IShutdownAction对象

type IStartupAction

type IStartupAction interface {
	Run()
}

用于post处理

func NewStartupAction

func NewStartupAction(runFunc func()) IStartupAction

使用函数创建一个PostProcessor对象

type IStartupActionInfo

type IStartupActionInfo interface {
	//设置优先级,越小越高,优先级越高的执行在最前面
	// SetPriority(priority int32)
	SetName(name string) IStartupActionInfo
	//设置最后执行,最后调用的执行在最后
	SetLast() IStartupActionInfo
}

封装一个IStartupAction对象信息

func RegisterOneStartupAction

func RegisterOneStartupAction(p interface{}) IStartupActionInfo

注册一个startupAction

type PostProcessor

type PostProcessor interface {
	AfterInitialization()
}

用于post处理

func NewPostProcessor

func NewPostProcessor(initializeFunc func()) PostProcessor

使用函数创建一个PostProcessor对象

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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