it compiles
This commit is contained in:
parent
0378151b9f
commit
0da222577b
5 changed files with 28 additions and 43 deletions
|
@ -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
|
||||
}
|
||||
|
|
26
pkg/blas/components.go
Normal file
26
pkg/blas/components.go
Normal file
|
@ -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
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package component
|
||||
|
||||
import (
|
||||
"dynatron.me/x/blasphem/pkg/blas"
|
||||
)
|
||||
|
||||
type (
|
||||
Setup func(blas.Core) (Instance, error)
|
||||
|
||||
Instance interface {
|
||||
Shutdown()
|
||||
}
|
||||
)
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue