application

package module
v0.9.25 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 14 Imported by: 159

README

application

the go module "github.com/starter-go/application"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collections

type Collections struct {
	Arguments   arguments.Table
	Attributes  attributes.Table
	Environment environment.Table
	Parameters  parameters.Table
	Properties  properties.Table
	Resources   resources.Table
}

Collections 持有上下文中的各种资源集合

func (*Collections) Clone added in v0.9.6

func (inst *Collections) Clone(mode safe.Mode) *Collections

Clone 以指定模式克隆这个集合

func (*Collections) Complete

func (inst *Collections) Complete(mode safe.Mode)

Complete 完善集合中的内容(如果需要)

type ComponentRegistration added in v0.9.5

type ComponentRegistration struct {
	ID components.ID

	Classes string // 类名列表,项与项之间以空格符(SPACE)分隔
	Aliases string // 别名列表,项与项之间以空格符(SPACE)分隔
	Scope   string // 作用域 'singleton'|'prototype'

	Registry ComponentRegistry // 提交后,这个字段会重置为nil

	NewFunc    func() any
	InjectFunc func(c InjectionExt, instance any) error
}

ComponentRegistration 表示组件注册信息

func (*ComponentRegistration) Commit added in v0.9.5

func (inst *ComponentRegistration) Commit() error

Commit 把注册信息提交到 ComponentRegistry

type ComponentRegistry added in v0.9.5

type ComponentRegistry interface {
	NewRegistration() *ComponentRegistration
	Register(r *ComponentRegistration) error
}

ComponentRegistry 是组件注册

type ComponentRegistryFunc added in v0.9.5

type ComponentRegistryFunc func(r ComponentRegistry) error

ComponentRegistryFunc 是组件的注册函数

type Context

type Context interface {
	io.Closer
	context.Context

	Mode() safe.Mode

	// NewChild() Context
	NewInjection(scope components.Scope) Injection

	GetArguments() arguments.Table
	GetAttributes() attributes.Table
	GetComponents() components.Table
	GetEnvironment() environment.Table
	GetProperties() properties.Table
	GetParameters() parameters.Table
	GetResources() resources.Table

	GetModules() []Module
	GetMainModule() Module

	GetLifeManager() LifeManager

	SelectComponents(selector components.Selector) ([]any, error)
	SelectComponent(selector components.Selector) (any, error)
	GetComponent(id components.ID) (any, error)
	ListComponentIDs() []components.ID
}

Context 表示一个 starter 应用上下文

type Injection

type Injection interface {
	components.Injection

	Ext() InjectionExt

	GetContext() Context

	LifeManager() LifeManager

	Complete() error
}

Injection 表示一个注入上下文

type InjectionExt added in v0.9.5

type InjectionExt interface {
	GetInjection() Injection

	GetContext() Context

	GetString(selector components.Selector) string
	GetBool(selector components.Selector) bool
	GetRune(selector components.Selector) rune
	GetByte(selector components.Selector) byte
	GetAny(selector components.Selector) any

	GetInt(selector components.Selector) int
	GetInt8(selector components.Selector) int8
	GetInt16(selector components.Selector) int16
	GetInt32(selector components.Selector) int32
	GetInt64(selector components.Selector) int64

	GetUint(selector components.Selector) uint
	GetUint8(selector components.Selector) uint8
	GetUint16(selector components.Selector) uint16
	GetUint32(selector components.Selector) uint32
	GetUint64(selector components.Selector) uint64

	GetFloat32(selector components.Selector) float32
	GetFloat64(selector components.Selector) float64

	GetComponent(selector components.Selector) any

	ListComponents(selector components.Selector) []any
}

InjectionExt 是 Injection 的扩展部分

type Life

type Life struct {
	Order int // 表示初始化顺序, 值越大越靠后

	OnCreate    OnCreateFunc
	OnStartPre  OnStartPreFunc
	OnStart     OnStartFunc
	OnStartPost OnStartPostFunc
	OnLoop      OnLoopFunc
	OnStopPre   OnStopPreFunc
	OnStop      OnStopFunc
	OnStopPost  OnStopPostFunc
	OnDestroy   OnDestroyFunc
}

Life ...

type LifeManager

type LifeManager interface {
	Add(l *Life)
	GetMaster() *Life
}

LifeManager ...

func NewLifeManager added in v0.9.21

func NewLifeManager() LifeManager

NewLifeManager 新建一个 LifeManager

type Lifecycle

type Lifecycle interface {
	Life() *Life
}

Lifecycle ...

type Module

type Module interface {
	Name() string
	Version() string
	Revision() int
	Dependencies() []Module
	Resources() resources.Table
	RegisterComponents(r ComponentRegistry) error
}

Module 表示一个 Starter 模块

type ModuleBuilder

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

ModuleBuilder 是用来创建模块的工具

func (*ModuleBuilder) Components

func (inst *ModuleBuilder) Components(fn ComponentRegistryFunc) *ModuleBuilder

Components 用于设置组件注册函数

func (*ModuleBuilder) Create

func (inst *ModuleBuilder) Create() Module

Create 创建模块

func (*ModuleBuilder) Depend

func (inst *ModuleBuilder) Depend(deps ...Module) *ModuleBuilder

Depend 方法用来添加依赖项

func (*ModuleBuilder) EmbedResources

func (inst *ModuleBuilder) EmbedResources(fs embed.FS, basepath string) *ModuleBuilder

EmbedResources 方法用来添加嵌入的资源

func (*ModuleBuilder) Name

func (inst *ModuleBuilder) Name(name string) *ModuleBuilder

Name 方法用来设置模块名称

func (*ModuleBuilder) Revision

func (inst *ModuleBuilder) Revision(rev int) *ModuleBuilder

Revision 方法用来设置模块的版本编号

func (*ModuleBuilder) Version

func (inst *ModuleBuilder) Version(version string) *ModuleBuilder

Version 方法用来设置模块的版本号

type OnCreateFunc

type OnCreateFunc func() error

OnCreateFunc ...

type OnDestroyFunc

type OnDestroyFunc func() error

OnDestroyFunc ...

type OnLoopFunc

type OnLoopFunc func() error

OnLoopFunc ...

type OnStartFunc

type OnStartFunc func() error

OnStartFunc ...

type OnStartPostFunc

type OnStartPostFunc func() error

OnStartPostFunc ...

type OnStartPreFunc

type OnStartPreFunc func() error

OnStartPreFunc ...

type OnStopFunc

type OnStopFunc func() error

OnStopFunc ...

type OnStopPostFunc

type OnStopPostFunc func() error

OnStopPostFunc ...

type OnStopPreFunc

type OnStopPreFunc func() error

OnStopPreFunc ...

Jump to

Keyboard shortcuts

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