feat: first version.
This commit is contained in:
35
bootstrap.go
Normal file
35
bootstrap.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"github.com/go-kratos/kratos/v2/registry"
|
||||
|
||||
"github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1"
|
||||
)
|
||||
|
||||
// Bootstrap 应用引导启动
|
||||
func Bootstrap(serviceInfo *ServiceInfo) (*conf.Bootstrap, log.Logger, registry.Registrar) {
|
||||
// inject command flags
|
||||
Flags := NewCommandFlags()
|
||||
Flags.Init()
|
||||
|
||||
// load configs
|
||||
cfg := LoadBootstrapConfig(Flags.Conf)
|
||||
if cfg == nil {
|
||||
panic("load config failed")
|
||||
}
|
||||
|
||||
// init logger
|
||||
ll := NewLoggerProvider(cfg.Logger, serviceInfo)
|
||||
|
||||
// init registrar
|
||||
reg := NewRegistry(cfg.Registry)
|
||||
|
||||
// init tracer
|
||||
err := NewTracerProvider(cfg.Trace, serviceInfo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return cfg, ll, reg
|
||||
}
|
||||
Reference in New Issue
Block a user