feat: moved cli to registry
This commit is contained in:
36
internal/registry/engine.go
Normal file
36
internal/registry/engine.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.maximhutz.com/max/lambda/pkg/engine"
|
||||
)
|
||||
|
||||
type Engine interface {
|
||||
Load() Process
|
||||
Name() string
|
||||
InType() string
|
||||
}
|
||||
|
||||
type convertedEngine[T any] struct {
|
||||
engine engine.Engine[T]
|
||||
name string
|
||||
inType string
|
||||
}
|
||||
|
||||
func (e convertedEngine[T]) InType() string { return e.inType }
|
||||
|
||||
func (e convertedEngine[T]) Name() string { return e.name }
|
||||
|
||||
func (e convertedEngine[T]) Load() Process {
|
||||
return convertedProcess[T]{e.engine.Load(), e.inType}
|
||||
}
|
||||
|
||||
func RegisterEngine[T any](registry *Registry, e engine.Engine[T], name, inType string) error {
|
||||
if _, ok := registry.engines[name]; ok {
|
||||
return fmt.Errorf("engine '%s' already registered", name)
|
||||
}
|
||||
|
||||
registry.engines[name] = &convertedEngine[T]{e, name, inType}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user