scene

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 4 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

Driver

  • Simple Database Driver
Repository
  • Code Generator

Documentation

Index

Constants

View Source
const (
	ImplTypeCore  = ImplType("core")
	ImplTypeRepo  = ImplType("repo")
	ImplTypeSrv   = ImplType("srv")
	ImplTypeApp   = ImplType("app")
	ImplTypeScene = ImplType("scene")
)
View Source
const Version = "0.3.0"

Variables

This section is empty.

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

Types

type AppContainerStatus

type AppContainerStatus int
const (
	AppContainerStatusStopped AppContainerStatus = iota
	AppContainerStatusRunning
	AppContainerStatusError
)

type AppInit

type AppInit[T Application] func() T

type AppStatus

type AppStatus int
const (
	AppStatusStopped AppStatus = iota
	AppStatusRunning
	AppStatusError
)

type Application

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

}

type ApplicationContainer

type ApplicationContainer interface {
	Name() ImplName // return container name

	Start() error                   // start container
	Stop(ctx context.Context) error // stop container

	// GetAppInfo(appID string) Application // return application info
	ListAppNames() []string // return application names
}

type ApplicationFactory

type ApplicationFactory[T Application] interface {
	Name() string        // return factory name
	Create(app T) error  // create application
	Destroy(app T) error // not used for now
}

type ApplicationManager

type ApplicationManager[T Application] interface {
	Name() string             // return registry name
	LoadApp(app T) error      // load application
	LoadApps(apps ...T) error // load applications
	GetApp(appID string) T    // return application
	ListAppNames() []string   // return application names
	ListApps() []T            // return list of applications
}

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 Disposable

type Disposable interface {
	Dispose() error
}

type Engine

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

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

type IDefaultableModuleFactory

type IDefaultableModuleFactory[T any] interface {
	IModuleFactory
	Default() 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
	Implementation string
	Version        string
}

func NewAppImplName

func NewAppImplName(module, implementation, version string) ImplName

func NewAppImplNameNoVer

func NewAppImplNameNoVer(module, implementation string) ImplName

func NewCoreImplName

func NewCoreImplName(module, implementation, version string) ImplName

func NewCoreImplNameNoVer

func NewCoreImplNameNoVer(module, implementation string) ImplName

func NewImplName

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

func NewImplNameNoVer

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

func NewRepoImplName

func NewRepoImplName(module, implementation, version string) ImplName

func NewRepoImplNameNoVer

func NewRepoImplNameNoVer(module, implementation string) ImplName

func NewSceneImplName

func NewSceneImplName(module, implementation, version string) ImplName

func NewSceneImplNameNoVer

func NewSceneImplNameNoVer(module, implementation string) ImplName

func NewSrvImplName

func NewSrvImplName(module, implementation, version string) ImplName

func NewSrvImplNameNoVer

func NewSrvImplNameNoVer(module, implementation string) ImplName

func (ImplName) EndpointName

func (i ImplName) EndpointName() string

func (ImplName) Identifier

func (i ImplName) Identifier() string

Identifier returns a string identifier of the implementation name.

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 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 NamableImplementation

type NamableImplementation interface {
	ImplName() ImplName
}

type Repository

type Repository interface {
	RepoImplName() ImplName
	Status() error
}

type Service

type Service interface {
	SrvImplName() ImplName
}

type Setupable

type Setupable interface {
	Setup() error
}

Jump to

Keyboard shortcuts

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