Skip to content

Commit

Permalink
Merge pull request #75 from webitel/v24.08
Browse files Browse the repository at this point in the history
V24.08
  • Loading branch information
navrotskyj authored Sep 19, 2024
2 parents 47d9299 + 450891f commit d6a8449
Show file tree
Hide file tree
Showing 5 changed files with 639 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ func New(options ...string) (outApp *App, outErr error) {
app.callManager = call_manager.NewCallManager(app.GetInstanceId(), app.Cluster().ServiceDiscovery(), app.MQ)
app.callManager.Start()

app.engine = engine.NewEngine(app, *app.id, app.Store, app.Config().QueueSettings.EnableOmnichannel)
app.engine = engine.NewEngine(app, *app.id, app.Store, app.Config().QueueSettings.EnableOmnichannel,
app.Config().QueueSettings.PollingInterval)
app.engine.Start()

app.agentManager = agent_manager.NewAgentManager(app.GetInstanceId(), app.Store, app.MQ)
Expand Down
2 changes: 2 additions & 0 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
resourceIgnoreEarlyMedia = flag.String("resource_ignore_early_media", "", "Ignore Early Media: True / False / Consume / Ring Ready")
sqlDebug = flag.Int("sql_debug", 0, "Debug sql lvl (0-9)")
bridgeSleep = flag.Duration("before_bridge_sleep", time.Millisecond*200, "Before bridge sleep time")
pollingInterval = flag.Duration("polling_interval", time.Millisecond*500, "Polling distribute interval (default 500ms)")
)

func (a *App) Config() *model.Config {
Expand All @@ -45,6 +46,7 @@ func loadConfig() (*model.Config, error) {
WaitChannelClose: waitChannelClose != nil && *waitChannelClose > 0,
EnableOmnichannel: enableOmnichannel != nil && *enableOmnichannel > 0,
BridgeSleep: *bridgeSleep,
PollingInterval: *pollingInterval,
},
ServiceSettings: model.ServiceSettings{
NodeId: appId,
Expand Down
11 changes: 5 additions & 6 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"github.com/webitel/call_center/utils"
"github.com/webitel/wlog"
"sync"
"time"
)

var DEFAULT_WATCHER_POLLING_INTERVAL = 800

type App interface {
IsReady() bool
}
Expand All @@ -18,24 +17,24 @@ type EngineImp struct {
nodeId string
store store.Store
startOnce sync.Once
pollingInterval int
pollingInterval time.Duration
watcher *utils.Watcher
enableOmnichannel bool
}

func NewEngine(app App, id string, s store.Store, enableOmnichannel bool) Engine {
func NewEngine(app App, id string, s store.Store, enableOmnichannel bool, pollingInterval time.Duration) Engine {
return &EngineImp{
app: app,
nodeId: id,
store: s,
pollingInterval: DEFAULT_WATCHER_POLLING_INTERVAL,
pollingInterval: pollingInterval,
enableOmnichannel: enableOmnichannel,
}
}

func (e *EngineImp) Start() {
wlog.Info("starting engine service")
e.watcher = utils.MakeWatcher("Engine", e.pollingInterval, e.ReserveMembers)
e.watcher = utils.MakeWatcher("Engine", int(e.pollingInterval.Milliseconds()), e.ReserveMembers)
e.UnReserveMembers()
//e.CleanAllAttempts()
e.startOnce.Do(func() {
Expand Down
1 change: 1 addition & 0 deletions model/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type QueueSettings struct {
WaitChannelClose bool
EnableOmnichannel bool
BridgeSleep time.Duration
PollingInterval time.Duration
}

type Config struct {
Expand Down
Loading

0 comments on commit d6a8449

Please sign in to comment.