Skip to content

Commit

Permalink
fixed consul service id
Browse files Browse the repository at this point in the history
  • Loading branch information
navrotskyj committed Oct 2, 2023
1 parent 8789309 commit cce9f2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 11 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -21,6 +22,7 @@ import (

type App struct {
id *string
publicId string
Store store.Store
MQ mq.MQ
Log *wlog.Logger
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"flag"
"fmt"
"github.com/webitel/call_center/model"
)

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cce9f2f

Please sign in to comment.