You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nnet/component/hub.go

21 lines
436 B
Go

package component
type CompWithOptions struct {
Comp Component
Opts []Option
}
type Components struct {
comps []CompWithOptions
}
// Register 全局注册组件,必须在服务启动之前初始化
func (cs *Components) Register(c Component, options ...Option) {
cs.comps = append(cs.comps, CompWithOptions{c, options})
}
// List 获取所有已注册组件
func (cs *Components) List() []CompWithOptions {
return cs.comps
}