diff --git a/pkg/blas/blas.go b/pkg/blas/blas.go index 8193b08..862816e 100644 --- a/pkg/blas/blas.go +++ b/pkg/blas/blas.go @@ -3,7 +3,6 @@ package blas import ( "context" "dynatron.me/x/blasphem/pkg/auth" - "dynatron.me/x/blasphem/pkg/blas/core" "dynatron.me/x/blasphem/pkg/bus" "dynatron.me/x/blasphem/pkg/config" "dynatron.me/x/blasphem/pkg/storage" @@ -18,8 +17,6 @@ type Core interface { Versioner } -var _ Core = (*core.Blas)(nil) - type Shutdowner interface { ShutdownBlas(context.Context) error } diff --git a/pkg/blas/components.go b/pkg/blas/components.go new file mode 100644 index 0000000..30a5043 --- /dev/null +++ b/pkg/blas/components.go @@ -0,0 +1,26 @@ +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 +} diff --git a/pkg/component/component.go b/pkg/component/component.go deleted file mode 100644 index ca626e3..0000000 --- a/pkg/component/component.go +++ /dev/null @@ -1,13 +0,0 @@ -package component - -import ( - "dynatron.me/x/blasphem/pkg/blas" -) - -type ( - Setup func(blas.Core) (Instance, error) - - Instance interface { - Shutdown() - } -) diff --git a/pkg/component/reg/registry.go b/pkg/component/reg/registry.go deleted file mode 100644 index 489e2d7..0000000 --- a/pkg/component/reg/registry.go +++ /dev/null @@ -1,24 +0,0 @@ -package reg - -import ( - "fmt" - - "dynatron.me/x/blasphem/pkg/component" -) - -type ( - Key string -) - -type Instance = component.Instance - -var Registry = make(map[Key]component.Setup) - -func Register(key Key, c component.Setup) { - _, already := Registry[key] - if already { - panic(fmt.Sprintf("component %s already exists", key)) - } - - Registry[key] = c -} diff --git a/pkg/frontend/frontend.go b/pkg/frontend/frontend.go index 7b859b2..824fd94 100644 --- a/pkg/frontend/frontend.go +++ b/pkg/frontend/frontend.go @@ -8,7 +8,6 @@ import ( "sync" "dynatron.me/x/blasphem/pkg/blas" - "dynatron.me/x/blasphem/pkg/component/reg" "github.com/labstack/echo/v4" ) @@ -50,7 +49,7 @@ func (fe *Frontend) AliasHandler(toFile string) echo.HandlerFunc { func (*Frontend) Shutdown() {} -func Setup(_ blas.Core) (reg.Instance, error) { +func Setup(_ blas.Core) (blas.Component, error) { fe := &Frontend{} var err error @@ -65,5 +64,5 @@ func Setup(_ blas.Core) (reg.Instance, error) { } func init() { - reg.Register(FrontendKey, Setup) + blas.Register(FrontendKey, Setup) }