diff --git a/app/app.go b/app/app.go index 06d15416..f87bd4a8 100644 --- a/app/app.go +++ b/app/app.go @@ -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) diff --git a/app/config.go b/app/config.go index 1966a298..8b61638f 100644 --- a/app/config.go +++ b/app/config.go @@ -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 { @@ -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, diff --git a/engine/engine.go b/engine/engine.go index a33b418e..91bfa6cd 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -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 } @@ -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() { diff --git a/model/config.go b/model/config.go index 32f78197..d76dac3d 100644 --- a/model/config.go +++ b/model/config.go @@ -76,6 +76,7 @@ type QueueSettings struct { WaitChannelClose bool EnableOmnichannel bool BridgeSleep time.Duration + PollingInterval time.Duration } type Config struct { diff --git a/store/sqlstore/migration/24.08/24.04-24.08.sql b/store/sqlstore/migration/24.08/24.04-24.08.sql index ba501fa3..d0f67523 100644 --- a/store/sqlstore/migration/24.08/24.04-24.08.sql +++ b/store/sqlstore/migration/24.08/24.04-24.08.sql @@ -2175,4 +2175,7 @@ create unique index cc_agent_today_stats_uidx on call_center.cc_agent_today_stats (agent_id); create unique index cc_agent_today_stats_usr_uidx - on call_center.cc_agent_today_stats (user_id); \ No newline at end of file + on call_center.cc_agent_today_stats (user_id); + +alter table call_center.cc_queue + alter column calendar_id drop not null; \ No newline at end of file