infra

package
v0.0.0-...-90f78ec Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyProps = "_config"
)

Variables

View Source
var StarterRegister *starterRegister = new(starterRegister)

Functions

func Register

func Register(s Starter)

func RegisterApi

func RegisterApi(ai Initializer)

注册 web api 初始化对象

func SystemRun

func SystemRun()

系统基础资源的启动管理

Types

type BaseStarter

type BaseStarter struct {
}

基础空启动器实现 - 结构体

func (*BaseStarter) Init

func (b *BaseStarter) Init(ctx StarterContext)

基础空启动器实现 - 方法实现

func (*BaseStarter) Priority

func (b *BaseStarter) Priority() int

func (*BaseStarter) PriorityGroup

func (b *BaseStarter) PriorityGroup() PriorityGroup

func (*BaseStarter) Setup

func (b *BaseStarter) Setup(ctx StarterContext)

func (*BaseStarter) Start

func (b *BaseStarter) Start(ctx StarterContext)

func (*BaseStarter) StartBlocking

func (b *BaseStarter) StartBlocking() bool

func (*BaseStarter) Stop

func (b *BaseStarter) Stop(ctx StarterContext)

type BootApplication

type BootApplication struct {
	// contains filtered or unexported fields
}

应用程序启动管理器

func New

func New(config kvs.ConfigSource) *BootApplication

func (*BootApplication) Start

func (b *BootApplication) Start()

type InitializeRegister

type InitializeRegister struct {
	Initializers []Initializer
}

初始化注册器

func (*InitializeRegister) Register

func (i *InitializeRegister) Register(ai Initializer)

注册一个初始化对象

type Initializer

type Initializer interface {
	// 用于对象实例化后的初始化操作
	Init()
}

func GetApiInitializers

func GetApiInitializers() []Initializer

获取注册的 web api 初始化对象

type PriorityGroup

type PriorityGroup int
const (
	SystemGroup         PriorityGroup = 30
	BasicResourcesGroup PriorityGroup = 20
	AppGroup            PriorityGroup = 10

	INT_MAX          = int(^uint(0) >> 1)
	DEFAULT_PRIORITY = 10000
)

type Starter

type Starter interface {
	// 1. 系统启动,初始化一些基础资源
	Init(StarterContext)
	// 2. 系统基础资源的安装
	Setup(StarterContext)
	// 3. 启动基础资源
	Start(StarterContext)
	// 4. 资源停止和销毁
	Stop(StarterContext)
	// 启动器是否可阻塞
	StartBlocking() bool
}

基础资源启动器接口

func GetStarters

func GetStarters() []Starter

获取所有注册的starter

type StarterContext

type StarterContext map[string]interface{}

基础资源上下文结构体

func (StarterContext) Props

func (s StarterContext) Props() kvs.ConfigSource

type WebApiStarter

type WebApiStarter struct {
	BaseStarter
}

func (*WebApiStarter) Setup

func (w *WebApiStarter) Setup(ctx StarterContext)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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