scene

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 6 Imported by: 0

README

稀音微服务框架

名字来源: 稀音 Arknights

Author: @Aynakeya(Yiyang Lu)

Still In development.

For design details and development diaries, please refer to my blog

For example usage, please refer to scene-template

Framework structure

structure

TODO

  • interface logger proxy generation

Driver

  • Simple Database Driver
Repository
  • Code Generator

Documentation

Index

Constants

View Source
const (
	ImplTypeCore   = ImplType("core")      // core type
	ImplTypeScene  = ImplType("scene")     // scenario type
	ImplTypeInfra  = ImplType("infra")     // infrastructure type
	ImplTypeComp   = ImplType("composite") // composition type
	ImplTypeModule = ImplType("module")    // module type
)
View Source
const Version = "0.4.0"

Variables

View Source
var (
	AppName         string = ""
	AppBuildTime    string = "0"
	AppBuildHash    string = "0000000000000000000000000000000000000000"
	AppBuildVersion string = "v0.0.0"
)
View Source
var DEFAULT_ENV string = "development"

DEFAULT_ENV is the environment variable that can be set to "production", "test" or "development" this is the default

Functions

func BuildApps

func BuildApps[T Application](builders ModuleFactoryArray) []T

func ContextFindValue

func ContextFindValue[T any](ctx Context) (T, bool)

func ContextSetValue

func ContextSetValue[T any](ctx Context, value T)

func GetInterfaceName

func GetInterfaceName[T any]() string

func SetEnvironment added in v0.2.6

func SetEnvironment(e Environment)

Types

type AppInit

type AppInit[T Application] func() T

AppInit is a function initialize an app

type Application

type Application interface {
	Name() ImplName // return scene
}

type CompositionName added in v0.2.6

type CompositionName string

func (CompositionName) ImplName added in v0.2.6

func (c CompositionName) ImplName(implementation, version string) ImplName

func (CompositionName) ImplNameNoVer added in v0.2.6

func (c CompositionName) ImplNameNoVer(implementation string) ImplName

func (CompositionName) String added in v0.2.6

func (c CompositionName) String() string

type Context

type Context interface {
	Get(key string) (value any, exists bool)
	Set(key string, value any)
}

Context should be a "context container" that store module's context

func NewContext

func NewContext() Context

type Defaultable added in v0.2.10

type Defaultable[T any] interface {
	Default() T
}

type Disposable

type Disposable interface {
	Dispose() error
}

type Engine

type Engine interface {
	Run() error
	Start() error
	Stop()

	ListContainers() []Scene
	GetContainer(name string) Scene
}

type Environment added in v0.2.6

type Environment uint8
const (
	EnvDevelopment Environment = iota
	EnvProduction
	EnvTest
)

func GetEnvironment added in v0.2.6

func GetEnvironment() Environment

func (Environment) String added in v0.2.6

func (e Environment) String() string

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() LensInit
	Apps() []any
}

type ImplName

type ImplName struct {
	ImplType       ImplType
	Module         string
	Interface      string
	Implementation string
}

func NewCoreImplName

func NewCoreImplName(module, iface, version string) ImplName

func NewCoreImplNameNoVer

func NewCoreImplNameNoVer(module, iface string) ImplName

func NewImplName

func NewImplName(implType ImplType, module, implementation, version string) ImplName

func NewImplNameNoVer

func NewImplNameNoVer(implType ImplType, module, iface string) ImplName

func NewInfraImplName added in v0.2.6

func NewInfraImplName(module, iface, implementation string) ImplName

func NewInfraImplNameNoVer added in v0.2.6

func NewInfraImplNameNoVer(module, iface string) ImplName

func NewModuleImplName added in v0.2.6

func NewModuleImplName(module, iface, implementation string) ImplName

func NewModuleImplNameNoVer added in v0.2.6

func NewModuleImplNameNoVer(module, iface string) ImplName

func NewSceneImplName

func NewSceneImplName(module, iface, version string) ImplName

func NewSceneImplNameNoVer

func NewSceneImplNameNoVer(module, iface string) ImplName

func (ImplName) EndpointName

func (i ImplName) EndpointName() string

currently no usage?

func (ImplName) ExportName added in v0.2.8

func (i ImplName) ExportName() string

ExportName return interface name with capitalized module name used by arpc

func (ImplName) Identifier

func (i ImplName) Identifier() string

Identifier returns a string identifier of the implementation name.

func (ImplName) MethodName added in v0.3.2

func (i ImplName) MethodName(method ...string) string

MethodName return method name in the for this interface used by mcp tools

func (ImplName) String

func (i ImplName) String() string

String returns a string representation of the implementation name. String is a pretty representation of the implementation name. If you want to use the implementation name as an identifier, use Identifier().

type ImplType

type ImplType string

type InfraName added in v0.2.6

type InfraName string

func (InfraName) ImplName added in v0.2.6

func (i InfraName) ImplName(implementation, version string) ImplName

func (InfraName) ImplNameNoVer added in v0.2.6

func (i InfraName) ImplNameNoVer(implementation string) ImplName

func (InfraName) String added in v0.2.6

func (i InfraName) String() string

type InitArray

type InitArray []LensInit

func BuildInitArray

func BuildInitArray(builders ModuleFactoryArray) InitArray

func (InitArray) Inits

func (inits InitArray) Inits()

type LensInit

type LensInit func()

LensInit is a function initialize a lens if error happens, it should panic

type ModuleFactory

type ModuleFactory struct {
}

func (ModuleFactory) Apps

func (b ModuleFactory) Apps() []any

func (ModuleFactory) Init

func (b ModuleFactory) Init() LensInit

type ModuleFactoryArray

type ModuleFactoryArray []IModuleFactory

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 Named added in v0.2.8

type Named interface {
	ImplName() ImplName
}

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 Service

type Service interface {
	SrvImplName() ImplName
}

type Setupable

type Setupable interface {
	Setup() error
}

type WithContext added in v0.2.10

type WithContext[T any] interface {
	WithSceneContext(ctx Context) T
	NoContext() T
}

Jump to

Keyboard shortcuts

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