Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultKey = struct{}{}
Functions ¶
func GetKeyedRoutine ¶
func GetKeyedRoutine[T any](provider IRoutineProvider, key any) T
func GetRoutine ¶
func GetRoutine[T any](provider IRoutineProvider) T
Types ¶
type IRoutineCollection ¶
type IRoutineCollection interface { AddDescriptor(descriptor *RoutineDescriptor) GetDescriptors() []*RoutineDescriptor GetDescriptor(ty reflect.Type) *RoutineDescriptor GetKeyedDescriptor(key any, ty reflect.Type) *RoutineDescriptor }
type IRoutineProvider ¶
type IRoutineProvider interface { GetRoutine(ty reflect.Type) any GetKeyedRoutine(key any, ty reflect.Type) any CreateScope() IRoutineScope GetRootScope() IRoutineScope }
type IRoutineScope ¶
type RoutineDescriptor ¶
type RoutineDescriptor struct { Lifetime RoutineLifetime // Routine 生命期 InitLock int32 // 初始化锁 Key any // 按 Key 注册 TyKey reflect.Type // 注册的接口类型 Key TyImpl reflect.Type // 注册的实现类型 Factory func(scope IRoutineScope) any // 工厂方法,用于在 scope 中创建实例,方法必须返回新实例 }
type RoutineLifetime ¶
type RoutineLifetime uint8
const ( Singleton RoutineLifetime = iota Scoped Transient )
Click to show internal directories.
Click to hide internal directories.