2022-12-20 13:31:31 -05:00
|
|
|
package blas
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Setup func(Core) (Component, error)
|
2022-12-20 13:54:49 -05:00
|
|
|
ComponentKey string
|
2022-12-20 13:31:31 -05:00
|
|
|
|
|
|
|
Component interface {
|
|
|
|
Shutdown()
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
2022-12-20 13:54:49 -05:00
|
|
|
var Registry = make(map[ComponentKey]Setup)
|
2022-12-20 13:31:31 -05:00
|
|
|
|
2022-12-20 13:54:49 -05:00
|
|
|
func Register(key ComponentKey, c Setup) {
|
2022-12-20 13:31:31 -05:00
|
|
|
_, already := Registry[key]
|
|
|
|
if already {
|
|
|
|
panic(fmt.Sprintf("component %s already exists", key))
|
|
|
|
}
|
|
|
|
|
|
|
|
Registry[key] = c
|
|
|
|
}
|