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

26 lines
355 B
Go

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