Documentation
¶
Index ¶
- Constants
- Variables
- func Applications[T Application](applications []Application) []T
- func ContextFindValue[T any](ctx context.Context, key any) (T, bool)
- func ContextSetValue[T any](ctx context.Context, key any, value T) context.Context
- func NewContext() context.Context
- type AppInit
- type Application
- type Based
- type Defaultable
- type Engine
- type IDefaultableModuleFactory
- type IModuleDependencyProvider
- type IModuleFactory
- type ImplName
- func NewImplName(implType ImplType, module, implementation, version string) ImplName
- func NewImplNameNoVer(implType ImplType, module, iface string) ImplName
- func NewModuleImplName(module, iface, implementation string) ImplName
- func NewModuleImplNameNoVer(module, iface string) ImplName
- func NewSceneImplName(module, iface, version string) ImplName
- func NewSceneImplNameNoVer(module, iface string) ImplName
- type ImplType
- type Lifecycle
- type ModuleFactory
- type ModuleFactoryArray
- type ModuleLoader
- type ModuleName
- type MutableContext
- type Named
- type Scene
- type SceneDefinition
- type SceneFactory
Constants ¶
const ( EnvDevelopment = "development" EnvProduction = "production" EnvTest = "test" )
const ( ImplTypeScene = ImplType("scene") // scenario type ImplTypeModule = ImplType("module") // module type )
const Version = "0.4.0"
Variables ¶
var ( AppName string = "" AppBuildTime string = "0" AppBuildHash string = "0000000000000000000000000000000000000000" AppBuildVersion string = "v0.0.0" )
var Environment = EnvDevelopment
Functions ¶
func Applications ¶ added in v0.4.0
func Applications[T Application](applications []Application) []T
Applications returns the applications that implement T.
func ContextSetValue ¶
func NewContext ¶
Types ¶
type Application ¶
type Application interface {
Name() ImplName // return scene
}
type Based ¶ added in v0.3.7
type Based[T any] interface { Base() T }
Based is an interface imply this service might have an internal core implementation
type Defaultable ¶ added in v0.2.10
type Defaultable[T any] interface { Default() T }
type IDefaultableModuleFactory ¶
type IDefaultableModuleFactory[T any] interface { IModuleFactory Defaultable[T] }
type IModuleDependencyProvider ¶
type IModuleDependencyProvider[T any] interface { Provide() T }
type IModuleFactory ¶
type IModuleFactory interface {
Init(container *registry.Container)
Apps() []Application
}
IModuleFactory declares the objects and applications owned by one module.
type ImplName ¶
func NewImplName ¶
func NewImplNameNoVer ¶
func NewModuleImplName ¶ added in v0.2.6
func NewModuleImplNameNoVer ¶ added in v0.2.6
func NewSceneImplName ¶
func NewSceneImplNameNoVer ¶
func (ImplName) ExportName ¶ added in v0.2.8
ExportName return interface name with capitalized module name used by arpc
func (ImplName) Identifier ¶
Identifier returns a string identifier of the implementation name.
func (ImplName) MethodName ¶ added in v0.3.2
MethodName return method name in the for this interface used by mcp tools
type Lifecycle ¶ added in v0.4.0
Lifecycle is initialized when its module is loaded and released when the module is unloaded.
type ModuleFactory ¶
type ModuleFactory struct{}
func (ModuleFactory) Apps ¶
func (ModuleFactory) Apps() []Application
func (ModuleFactory) Init ¶
func (ModuleFactory) Init(*registry.Container)
type ModuleFactoryArray ¶
type ModuleFactoryArray []IModuleFactory
type ModuleLoader ¶ added in v0.4.0
type ModuleLoader struct {
// contains filtered or unexported fields
}
ModuleLoader builds a flat list of module factories in one registry Scope.
func NewModuleLoader ¶ added in v0.4.0
func NewModuleLoader(factories ModuleFactoryArray) *ModuleLoader
func NewModuleLoaderIn ¶ added in v0.4.0
func NewModuleLoaderIn(scope *registry.Scope, factories ModuleFactoryArray) *ModuleLoader
NewModuleLoaderIn creates a module loader backed by scope.
func (*ModuleLoader) Applications ¶ added in v0.4.0
func (l *ModuleLoader) Applications() []Application
Applications returns the applications declared during Init in module order.
func (*ModuleLoader) Containers ¶ added in v0.4.0
func (l *ModuleLoader) Containers() []*registry.Container
Containers returns the initialized module containers in factory order.
func (*ModuleLoader) Init ¶ added in v0.4.0
func (l *ModuleLoader) Init() error
Init declares all modules, resolves their dependencies, and performs injection. It does not run lifecycle Setup.
func (*ModuleLoader) Scope ¶ added in v0.4.0
func (l *ModuleLoader) Scope() *registry.Scope
Scope returns the registry Scope owned by this loader.
func (*ModuleLoader) Setup ¶ added in v0.4.0
func (l *ModuleLoader) Setup() error
Setup initializes module lifecycles in dependency order. Init must complete successfully before Setup is called.
func (*ModuleLoader) TearDown ¶ added in v0.4.0
func (l *ModuleLoader) TearDown() error
TearDown releases initialized modules in reverse dependency order.
type ModuleName ¶ added in v0.2.6
type ModuleName string
func (ModuleName) ImplName ¶ added in v0.2.6
func (l ModuleName) ImplName(iface, implementation string) ImplName
func (ModuleName) ImplNameNoVer ¶ added in v0.2.6
func (l ModuleName) ImplNameNoVer(implementation string) ImplName
func (ModuleName) String ¶ added in v0.2.6
func (l ModuleName) String() string
func (ModuleName) TableName ¶ added in v0.2.6
func (l ModuleName) TableName(table string) string
type MutableContext ¶ added in v0.3.6
type Scene ¶ added in v0.3.0
type Scene interface {
Named
Start() error // start container
Stop(ctx context.Context) error // stop container
ListAppNames() []string // return application names
}
Scene is the delivery (controller) layer container, contains application from each module
type SceneDefinition ¶ added in v0.4.0
type SceneDefinition struct {
// contains filtered or unexported fields
}
SceneDefinition is the type-erased scene declaration consumed by an Engine. Use WithScene to create one from a typed SceneFactory.
func WithScene ¶ added in v0.4.0
func WithScene[T Application](factory SceneFactory[T]) SceneDefinition
WithScene declares a Scene. The factory receives only applications that implement T, preserving their module declaration order.
func (SceneDefinition) Build ¶ added in v0.4.0
func (d SceneDefinition) Build(loader *ModuleLoader) (Scene, error)
Build builds the declared Scene from an initialized ModuleLoader.
type SceneFactory ¶ added in v0.4.0
type SceneFactory[T Application] interface { Build(scope *registry.Scope, applications []T) (Scene, error) }
SceneFactory builds one Scene from applications of the matching type.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
scene
command
|
|
|
composition
|
|
|
orm
Package orm integrates GORM with Scene's data-source, logging, setup, and dependency-injection lifecycle.
|
Package orm integrates GORM with Scene's data-source, logging, setup, and dependency-injection lifecycle. |
|
infrastructure
|
|
|
lens
|
|
|
pkg
|
|
|
Package registry implements module-scoped dependency declaration and injection.
|
Package registry implements module-scoped dependency declaration and injection. |
|
scenes
|
|
|
gin
Package gin integrates Gin HTTP routing with Scene applications, dependency injection, request binding, middleware, and the common response envelope.
|
Package gin integrates Gin HTTP routing with Scene applications, dependency injection, request binding, middleware, and the common response envelope. |
