Add Envoy v2 initialization to boot levels
This commit is contained in:
parent
535b7c614f
commit
09be722093
53
server/app/boot_envoy.go
Normal file
53
server/app/boot_envoy.go
Normal file
@ -0,0 +1,53 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
automationEnvoy "github.com/cortezaproject/corteza/server/automation/envoy"
|
||||
composeEnvoy "github.com/cortezaproject/corteza/server/compose/envoy"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
systemEnvoy "github.com/cortezaproject/corteza/server/system/envoy"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (app *CortezaApp) initEnvoy(ctx context.Context, log *zap.Logger) (err error) {
|
||||
// no-op - if envoy is already initialized
|
||||
if envoyx.Initialized() {
|
||||
return
|
||||
}
|
||||
|
||||
// Init envoy
|
||||
svc := envoyx.New()
|
||||
envoyx.SetGlobal(svc)
|
||||
|
||||
// Register all component decoders
|
||||
svc.AddDecoder(envoyx.DecodeTypeURI,
|
||||
composeEnvoy.YamlDecoder{},
|
||||
systemEnvoy.YamlDecoder{},
|
||||
automationEnvoy.YamlDecoder{},
|
||||
)
|
||||
svc.AddDecoder(envoyx.DecodeTypeStore,
|
||||
composeEnvoy.StoreDecoder{},
|
||||
systemEnvoy.StoreDecoder{},
|
||||
automationEnvoy.StoreDecoder{},
|
||||
)
|
||||
|
||||
// Register all component encoders
|
||||
svc.AddEncoder(envoyx.EncodeTypeIo,
|
||||
composeEnvoy.YamlEncoder{},
|
||||
systemEnvoy.YamlEncoder{},
|
||||
automationEnvoy.YamlEncoder{},
|
||||
)
|
||||
svc.AddEncoder(envoyx.EncodeTypeStore,
|
||||
composeEnvoy.StoreEncoder{},
|
||||
systemEnvoy.StoreEncoder{},
|
||||
automationEnvoy.StoreEncoder{},
|
||||
)
|
||||
|
||||
// - datasource encoders
|
||||
svc.AddEncoder(envoyx.EncodeTypeIo,
|
||||
composeEnvoy.CsvEncoder{},
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
@ -23,6 +23,7 @@ import (
|
||||
apigwTypes "github.com/cortezaproject/corteza/server/pkg/apigw/types"
|
||||
"github.com/cortezaproject/corteza/server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza/server/pkg/corredor"
|
||||
"github.com/cortezaproject/corteza/server/pkg/envoyx"
|
||||
"github.com/cortezaproject/corteza/server/pkg/eventbus"
|
||||
"github.com/cortezaproject/corteza/server/pkg/healthcheck"
|
||||
"github.com/cortezaproject/corteza/server/pkg/http"
|
||||
@ -354,6 +355,13 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
|
||||
rbac.SetGlobal(ac)
|
||||
}
|
||||
|
||||
if !envoyx.Initialized() {
|
||||
err = app.initEnvoy(ctx, app.Log)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize resource translation stuff
|
||||
locale.Global().BindStore(app.Store)
|
||||
if err = locale.Global().ReloadResourceTranslations(ctx); err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user