40 lines
820 B
Go
40 lines
820 B
Go
package api
|
|
|
|
import "git.sendico.io/tech/sxchnge/shared/service"
|
|
|
|
type ConfigProvider interface {
|
|
SharedConfig() *Config
|
|
}
|
|
|
|
type ConfigFactory func() ConfigProvider
|
|
type RuntimeComponents map[string]any
|
|
type RuntimeBootstrapFunc func(API) (RuntimeComponents, error)
|
|
type RuntimeFinishFunc func(API) error
|
|
|
|
type RuntimeConfig struct {
|
|
Name string
|
|
Services []ServiceFactory
|
|
ConfigFactory ConfigFactory
|
|
Bootstrap RuntimeBootstrapFunc
|
|
Finish RuntimeFinishFunc
|
|
}
|
|
|
|
type ServiceFactory struct {
|
|
Name mservice.Type
|
|
Factory MicroServiceFactoryT
|
|
}
|
|
|
|
func (cfg RuntimeConfig) RuntimeName() string {
|
|
if cfg.Name == "" {
|
|
return "edge"
|
|
}
|
|
return cfg.Name
|
|
}
|
|
|
|
func (cfg RuntimeConfig) NewConfig() ConfigProvider {
|
|
if cfg.ConfigFactory != nil {
|
|
return cfg.ConfigFactory()
|
|
}
|
|
return &Config{}
|
|
}
|