blasphem/pkg/blas/components.go
2022-12-20 13:31:31 -05:00

26 lines
328 B
Go

package blas
import (
"fmt"
)
type (
Setup func(Core) (Component, error)
Key string
Component interface {
Shutdown()
}
)
var Registry = make(map[Key]Setup)
func Register(key Key, c Setup) {
_, already := Registry[key]
if already {
panic(fmt.Sprintf("component %s already exists", key))
}
Registry[key] = c
}