From 088ee37451a972b475de22695e031c799f4d33e0 Mon Sep 17 00:00:00 2001 From: Igor Navrotskyj Date: Mon, 2 Oct 2023 17:17:27 +0300 Subject: [PATCH] fixed consul service id --- app/app.go | 13 +++++++++++-- app/config.go | 3 +-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/app.go b/app/app.go index 92701ba1..b860dc0b 100644 --- a/app/app.go +++ b/app/app.go @@ -1,6 +1,7 @@ package app import ( + "fmt" "github.com/pkg/errors" "github.com/webitel/call_center/agent_manager" "github.com/webitel/call_center/call_manager" @@ -21,6 +22,7 @@ import ( type App struct { id *string + publicId string Store store.Store MQ mq.MQ Log *wlog.Logger @@ -50,7 +52,9 @@ func New(options ...string) (outApp *App, outErr error) { if err := app.LoadConfig(app.configFile); err != nil { return nil, err } - app.id = app.Config().ServiceSettings.NodeId + // TODO + app.setServiceId(app.Config().ServiceSettings.NodeId) + app.Log = wlog.NewLogger(&wlog.LoggerConfiguration{ EnableConsole: true, ConsoleLevel: wlog.LevelDebug, @@ -177,6 +181,11 @@ func (app *App) Shutdown() { } } +func (a *App) setServiceId(id *string) { + a.id = id + a.publicId = fmt.Sprintf("%s-%s", model.ServiceName, *a.id) +} + func (a *App) GetInstanceId() string { - return *a.id + return a.publicId } diff --git a/app/config.go b/app/config.go index 763b1775..e545ec49 100644 --- a/app/config.go +++ b/app/config.go @@ -2,7 +2,6 @@ package app import ( "flag" - "fmt" "github.com/webitel/call_center/model" ) @@ -44,7 +43,7 @@ func loadConfig() (*model.Config, error) { EnableOmnichannel: enableOmnichannel != nil && *enableOmnichannel > 0, }, ServiceSettings: model.ServiceSettings{ - NodeId: model.NewString(fmt.Sprintf("%s-%s", model.ServiceName, *appId)), + NodeId: appId, }, DiscoverySettings: model.DiscoverySettings{ Url: *consulHost,