Use channel instead of context to handle shutdown

This commit is contained in:
ionutboangiu
2024-12-12 20:27:23 +02:00
committed by Dan Christian Bogos
parent d9359a4005
commit c8a3ebe5e8
50 changed files with 281 additions and 333 deletions

View File

@@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/accounts"
"github.com/cgrates/cgrates/commonlisteners"
@@ -37,7 +35,7 @@ import (
// NewAccountService returns the Account Service
func NewAccountService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *AccountService {
return &AccountService{
cfg: cfg,
connMgr: connMgr,
@@ -65,7 +63,7 @@ type AccountService struct {
}
// Start should handle the service start
func (acts *AccountService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (acts *AccountService) Start(shutdown chan struct{}) (err error) {
if acts.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -78,7 +76,7 @@ func (acts *AccountService) Start(ctx *context.Context, _ context.CancelFunc) (e
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), acts.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.AccountS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheAccounts,
utils.CacheAccountsFilterIndexes); err != nil {
return
@@ -119,7 +117,7 @@ func (acts *AccountService) Start(ctx *context.Context, _ context.CancelFunc) (e
}
// Reload handles the change of config
func (acts *AccountService) Reload(*context.Context, context.CancelFunc) (err error) {
func (acts *AccountService) Reload(_ chan struct{}) (err error) {
acts.rldChan <- struct{}{}
return // for the moment nothing to reload
}

View File

@@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/actions"
"github.com/cgrates/cgrates/commonlisteners"
@@ -37,7 +35,7 @@ import (
// NewActionService returns the Action Service
func NewActionService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *ActionService {
return &ActionService{
connMgr: connMgr,
cfg: cfg,
@@ -66,7 +64,7 @@ type ActionService struct {
}
// Start should handle the service start
func (acts *ActionService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (acts *ActionService) Start(shutdown chan struct{}) (err error) {
if acts.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -80,7 +78,7 @@ func (acts *ActionService) Start(ctx *context.Context, _ context.CancelFunc) (er
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), acts.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.ActionS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheActionProfiles,
utils.CacheActionProfilesFilterIndexes); err != nil {
return
@@ -120,7 +118,7 @@ func (acts *ActionService) Start(ctx *context.Context, _ context.CancelFunc) (er
}
// Reload handles the change of config
func (acts *ActionService) Reload(*context.Context, context.CancelFunc) (err error) {
func (acts *ActionService) Reload(_ chan struct{}) (err error) {
acts.rldChan <- struct{}{}
return // for the moment nothing to reload
}

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/apis"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -34,7 +33,7 @@ import (
// NewAPIerSv1Service returns the APIerSv1 Service
func NewAdminSv1Service(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *AdminSv1Service {
return &AdminSv1Service{
cfg: cfg,
connMgr: connMgr,
@@ -61,7 +60,7 @@ type AdminSv1Service struct {
// Start should handle the sercive start
// For this service the start should be called from RAL Service
func (apiService *AdminSv1Service) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (apiService *AdminSv1Service) Start(_ chan struct{}) (err error) {
if apiService.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -113,7 +112,7 @@ func (apiService *AdminSv1Service) Start(ctx *context.Context, _ context.CancelF
}
// Reload handles the change of config
func (apiService *AdminSv1Service) Reload(*context.Context, context.CancelFunc) (err error) {
func (apiService *AdminSv1Service) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -59,7 +59,7 @@ type AnalyzerService struct {
}
// Start should handle the sercive start
func (anz *AnalyzerService) Start(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (anz *AnalyzerService) Start(shutdown chan struct{}) (err error) {
if anz.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -76,12 +76,12 @@ func (anz *AnalyzerService) Start(ctx *context.Context, shtDwn context.CancelFun
utils.Logger.Crit(fmt.Sprintf("<%s> Could not init, error: %s", utils.AnalyzerS, err.Error()))
return
}
anzCtx, cancel := context.WithCancel(ctx)
anzCtx, cancel := context.WithCancel(context.TODO())
anz.cancelFunc = cancel
go func(a *analyzers.AnalyzerS) {
if err := a.ListenAndServe(anzCtx); err != nil {
utils.Logger.Crit(fmt.Sprintf("<%s> Error: %s listening for packets", utils.AnalyzerS, err.Error()))
shtDwn()
close(shutdown)
}
}(anz.anz)
anz.cl.SetAnalyzer(anz.anz)
@@ -114,7 +114,7 @@ func (anz *AnalyzerService) start() {
}
// Reload handles the change of config
func (anz *AnalyzerService) Reload(*context.Context, context.CancelFunc) (err error) {
func (anz *AnalyzerService) Reload(_ chan struct{}) (err error) {
return // for the momment nothing to reload
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/agents"
@@ -35,7 +34,7 @@ import (
// NewAsteriskAgent returns the Asterisk Agent
func NewAsteriskAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *AsteriskAgent {
return &AsteriskAgent{
cfg: cfg,
connMgr: connMgr,
@@ -59,7 +58,7 @@ type AsteriskAgent struct {
}
// Start should handle the sercive start
func (ast *AsteriskAgent) Start(_ *context.Context, shtDwn context.CancelFunc) (err error) {
func (ast *AsteriskAgent) Start(shutdown chan struct{}) (err error) {
if ast.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -70,7 +69,7 @@ func (ast *AsteriskAgent) Start(_ *context.Context, shtDwn context.CancelFunc) (
listenAndServe := func(sma *agents.AsteriskAgent, stopChan chan struct{}) {
if err := sma.ListenAndServe(stopChan); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> runtime error: %s!", utils.AsteriskAgent, err))
shtDwn()
close(shutdown)
}
}
ast.stopChan = make(chan struct{})
@@ -84,9 +83,9 @@ func (ast *AsteriskAgent) Start(_ *context.Context, shtDwn context.CancelFunc) (
}
// Reload handles the change of config
func (ast *AsteriskAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (ast *AsteriskAgent) Reload(shutdown chan struct{}) (err error) {
ast.shutdown()
return ast.Start(ctx, shtDwn)
return ast.Start(shutdown)
}
// Shutdown stops the service

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/apis"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -35,7 +34,7 @@ import (
// NewAttributeService returns the Attribute Service
func NewAttributeService(cfg *config.CGRConfig,
dspS *DispatcherService,
sIndxr *servmanager.ServiceIndexer) servmanager.Service {
sIndxr *servmanager.ServiceIndexer) *AttributeService {
return &AttributeService{
cfg: cfg,
dspS: dspS,
@@ -62,7 +61,7 @@ type AttributeService struct {
}
// Start should handle the service start
func (attrS *AttributeService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (attrS *AttributeService) Start(shutdown chan struct{}) (err error) {
if attrS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -80,7 +79,7 @@ func (attrS *AttributeService) Start(ctx *context.Context, _ context.CancelFunc)
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), attrS.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.AttributeS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheAttributeProfiles,
utils.CacheAttributeFilterIndexes); err != nil {
return
@@ -129,7 +128,7 @@ func (attrS *AttributeService) Start(ctx *context.Context, _ context.CancelFunc)
}
// Reload handles the change of config
func (attrS *AttributeService) Reload(*context.Context, context.CancelFunc) (err error) {
func (attrS *AttributeService) Reload(_ chan struct{}) (err error) {
return // for the moment nothing to reload
}

View File

@@ -20,7 +20,6 @@ package services
import (
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -54,7 +53,7 @@ type CacheService struct {
}
// Start should handle the sercive start
func (cS *CacheService) Start(ctx *context.Context, shtDw context.CancelFunc) (err error) {
func (cS *CacheService) Start(shutdown chan struct{}) (err error) {
cls := cS.srvIndexer.GetService(utils.CommonListenerS).(*CommonListenerService)
if utils.StructChanTimeout(cls.StateChan(utils.StateServiceUP), cS.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.CacheS, utils.CommonListenerS, utils.StateServiceUP)
@@ -73,7 +72,7 @@ func (cS *CacheService) Start(ctx *context.Context, shtDw context.CancelFunc) (e
return utils.NewServiceStateTimeoutError(utils.CacheS, utils.CoreS, utils.StateServiceUP)
}
engine.Cache = engine.NewCacheS(cS.cfg, dbs.DataManager(), cS.connMgr, cs.CoreS().CapsStats)
go engine.Cache.Precache(ctx, shtDw)
go engine.Cache.Precache(shutdown)
cS.cacheCh <- engine.Cache
@@ -90,7 +89,7 @@ func (cS *CacheService) Start(ctx *context.Context, shtDw context.CancelFunc) (e
}
// Reload handles the change of config
func (cS *CacheService) Reload(*context.Context, context.CancelFunc) (_ error) {
func (cS *CacheService) Reload(_ chan struct{}) (_ error) {
return
}
@@ -120,18 +119,18 @@ func (cS *CacheService) GetCacheSChan() chan *engine.CacheS {
return cS.cacheCh
}
func (cS *CacheService) WaitToPrecache(ctx *context.Context, cacheIDs ...string) (err error) {
func (cS *CacheService) WaitToPrecache(shutdown chan struct{}, cacheIDs ...string) (err error) {
var cacheS *engine.CacheS
select {
case <-ctx.Done():
return ctx.Err()
case <-shutdown:
return
case cacheS = <-cS.cacheCh:
cS.cacheCh <- cacheS
}
for _, cacheID := range cacheIDs {
select {
case <-ctx.Done():
return ctx.Err()
case <-shutdown:
return
case <-cacheS.GetPrecacheChannel(cacheID):
}
}

View File

@@ -24,7 +24,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/cdrs"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -36,7 +35,7 @@ import (
// NewCDRServer returns the CDR Server
func NewCDRServer(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *CDRService {
return &CDRService{
cfg: cfg,
connMgr: connMgr,
@@ -61,7 +60,7 @@ type CDRService struct {
}
// Start should handle the sercive start
func (cs *CDRService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (cs *CDRService) Start(_ chan struct{}) (err error) {
if cs.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -110,7 +109,7 @@ func (cs *CDRService) Start(ctx *context.Context, _ context.CancelFunc) (err err
}
// Reload handles the change of config
func (cs *CDRService) Reload(*context.Context, context.CancelFunc) (err error) {
func (cs *CDRService) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -35,7 +33,7 @@ import (
// NewChargerService returns the Charger Service
func NewChargerService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *ChargerService {
return &ChargerService{
cfg: cfg,
connMgr: connMgr,
@@ -60,7 +58,7 @@ type ChargerService struct {
}
// Start should handle the service start
func (chrS *ChargerService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (chrS *ChargerService) Start(shutdown chan struct{}) (err error) {
if chrS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -74,7 +72,7 @@ func (chrS *ChargerService) Start(ctx *context.Context, _ context.CancelFunc) (e
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), chrS.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.ChargerS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheChargerProfiles,
utils.CacheChargerFilterIndexes); err != nil {
return
@@ -110,7 +108,7 @@ func (chrS *ChargerService) Start(ctx *context.Context, _ context.CancelFunc) (e
}
// Reload handles the change of config
func (chrS *ChargerService) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (chrS *ChargerService) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -57,7 +56,7 @@ type CommonListenerService struct {
}
// Start handles the service start.
func (cl *CommonListenerService) Start(*context.Context, context.CancelFunc) error {
func (cl *CommonListenerService) Start(_ chan struct{}) error {
if cl.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -75,7 +74,7 @@ func (cl *CommonListenerService) Start(*context.Context, context.CancelFunc) err
}
// Reload handles the config changes.
func (cl *CommonListenerService) Reload(*context.Context, context.CancelFunc) error {
func (cl *CommonListenerService) Reload(_ chan struct{}) error {
return nil
}

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/servmanager"
@@ -48,7 +47,7 @@ type ConfigService struct {
}
// Start handles the service start.
func (s *ConfigService) Start(_ *context.Context, _ context.CancelFunc) error {
func (s *ConfigService) Start(_ chan struct{}) error {
cls := s.srvIndexer.GetService(utils.CommonListenerS).(*CommonListenerService)
if utils.StructChanTimeout(cls.StateChan(utils.StateServiceUP), s.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.GuardianS, utils.CommonListenerS, utils.StateServiceUP)
@@ -70,7 +69,7 @@ func (s *ConfigService) Start(_ *context.Context, _ context.CancelFunc) error {
}
// Reload handles the config changes.
func (s *ConfigService) Reload(*context.Context, context.CancelFunc) error {
func (s *ConfigService) Reload(_ chan struct{}) error {
return nil
}

View File

@@ -24,7 +24,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/cores"
@@ -68,7 +67,7 @@ type CoreService struct {
}
// Start should handle the service start
func (cS *CoreService) Start(ctx *context.Context, shtDw context.CancelFunc) error {
func (cS *CoreService) Start(shutdown chan struct{}) error {
if cS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -87,7 +86,7 @@ func (cS *CoreService) Start(ctx *context.Context, shtDw context.CancelFunc) err
defer cS.mu.Unlock()
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.CoreS))
cS.stopChan = make(chan struct{})
cS.cS = cores.NewCoreService(cS.cfg, cS.caps, cS.fileCPU, cS.stopChan, cS.shdWg, shtDw)
cS.cS = cores.NewCoreService(cS.cfg, cS.caps, cS.fileCPU, cS.stopChan, cS.shdWg, shutdown)
cS.csCh <- cS.cS
srv, err := engine.NewService(cS.cS)
if err != nil {
@@ -105,7 +104,7 @@ func (cS *CoreService) Start(ctx *context.Context, shtDw context.CancelFunc) err
}
// Reload handles the change of config
func (cS *CoreService) Reload(*context.Context, context.CancelFunc) error {
func (cS *CoreService) Reload(_ chan struct{}) error {
return nil
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/servmanager"
@@ -62,7 +61,7 @@ type DataDBService struct {
}
// Start handles the service start.
func (db *DataDBService) Start(*context.Context, context.CancelFunc) (err error) {
func (db *DataDBService) Start(_ chan struct{}) (err error) {
if db.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -94,7 +93,7 @@ func (db *DataDBService) Start(*context.Context, context.CancelFunc) (err error)
}
// Reload handles the change of config
func (db *DataDBService) Reload(*context.Context, context.CancelFunc) (err error) {
func (db *DataDBService) Reload(_ chan struct{}) (err error) {
db.Lock()
defer db.Unlock()
if db.needsConnectionReload() {

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -34,7 +33,7 @@ import (
// NewDiameterAgent returns the Diameter Agent
func NewDiameterAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager, caps *engine.Caps,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *DiameterAgent {
return &DiameterAgent{
cfg: cfg,
connMgr: connMgr,
@@ -63,7 +62,7 @@ type DiameterAgent struct {
}
// Start should handle the sercive start
func (da *DiameterAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) error {
func (da *DiameterAgent) Start(shutdown chan struct{}) error {
if da.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -74,10 +73,10 @@ func (da *DiameterAgent) Start(ctx *context.Context, shtDwn context.CancelFunc)
}
da.Lock()
defer da.Unlock()
return da.start(fs.FilterS(), shtDwn, da.caps)
return da.start(fs.FilterS(), da.caps, shutdown)
}
func (da *DiameterAgent) start(filterS *engine.FilterS, shtDwn context.CancelFunc, caps *engine.Caps) error {
func (da *DiameterAgent) start(filterS *engine.FilterS, caps *engine.Caps, shutdown chan struct{}) error {
var err error
da.da, err = agents.NewDiameterAgent(da.cfg, filterS, da.connMgr, caps)
if err != nil {
@@ -92,7 +91,7 @@ func (da *DiameterAgent) start(filterS *engine.FilterS, shtDwn context.CancelFun
if err := d.ListenAndServe(da.stopChan); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> error: %s!",
utils.DiameterAgent, err))
shtDwn()
close(shutdown)
}
}(da.da)
close(da.stateDeps.StateChan(utils.StateServiceUP))
@@ -100,7 +99,7 @@ func (da *DiameterAgent) start(filterS *engine.FilterS, shtDwn context.CancelFun
}
// Reload handles the change of config
func (da *DiameterAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (da *DiameterAgent) Reload(shutdown chan struct{}) (err error) {
da.Lock()
defer da.Unlock()
if da.lnet == da.cfg.DiameterAgentCfg().ListenNet &&
@@ -112,7 +111,7 @@ func (da *DiameterAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc)
if utils.StructChanTimeout(fs.StateChan(utils.StateServiceUP), da.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.DiameterAgent, utils.FilterS, utils.StateServiceUP)
}
return da.start(fs.FilterS(), shtDwn, da.caps)
return da.start(fs.FilterS(), da.caps, shutdown)
}
// Shutdown stops the service

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/dispatchers"
@@ -61,7 +60,7 @@ type DispatcherService struct {
}
// Start should handle the sercive start
func (dspS *DispatcherService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (dspS *DispatcherService) Start(shutdown chan struct{}) (err error) {
if dspS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -75,7 +74,7 @@ func (dspS *DispatcherService) Start(ctx *context.Context, _ context.CancelFunc)
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), dspS.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.DispatcherS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheDispatcherProfiles,
utils.CacheDispatcherHosts,
utils.CacheDispatcherFilterIndexes); err != nil {
@@ -117,7 +116,7 @@ func (dspS *DispatcherService) Start(ctx *context.Context, _ context.CancelFunc)
}
// Reload handles the change of config
func (dspS *DispatcherService) Reload(*context.Context, context.CancelFunc) (err error) {
func (dspS *DispatcherService) Reload(_ chan struct{}) (err error) {
return // for the momment nothing to reload
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -34,7 +33,7 @@ import (
// NewDNSAgent returns the DNS Agent
func NewDNSAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *DNSAgent {
return &DNSAgent{
cfg: cfg,
connMgr: connMgr,
@@ -59,7 +58,7 @@ type DNSAgent struct {
}
// Start should handle the service start
func (dns *DNSAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (dns *DNSAgent) Start(shutdown chan struct{}) (err error) {
if dns.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -77,13 +76,13 @@ func (dns *DNSAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) (err
return
}
dns.stopChan = make(chan struct{})
go dns.listenAndServe(dns.stopChan, shtDwn)
go dns.listenAndServe(dns.stopChan, shutdown)
close(dns.stateDeps.StateChan(utils.StateServiceUP))
return
}
// Reload handles the change of config
func (dns *DNSAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (dns *DNSAgent) Reload(shutdown chan struct{}) (err error) {
fs := dns.srvIndexer.GetService(utils.FilterS).(*FilterService)
if utils.StructChanTimeout(fs.StateChan(utils.StateServiceUP), dns.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.DNSAgent, utils.FilterS, utils.StateServiceUP)
@@ -106,16 +105,16 @@ func (dns *DNSAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc) (er
dns.dns.Lock()
defer dns.dns.Unlock()
dns.stopChan = make(chan struct{})
go dns.listenAndServe(dns.stopChan, shtDwn)
go dns.listenAndServe(dns.stopChan, shutdown)
return
}
func (dns *DNSAgent) listenAndServe(stopChan chan struct{}, shtDwn context.CancelFunc) (err error) {
func (dns *DNSAgent) listenAndServe(stopChan chan struct{}, shutdown chan struct{}) (err error) {
dns.dns.RLock()
defer dns.dns.RUnlock()
if err = dns.dns.ListenAndServe(stopChan); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> error: <%s>", utils.DNSAgent, err.Error()))
shtDwn() // stop the engine here
close(shutdown) // stop the engine here
}
return
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/ees"
@@ -35,7 +34,7 @@ import (
// NewEventExporterService constructs EventExporterService
func NewEventExporterService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *EventExporterService {
return &EventExporterService{
cfg: cfg,
connMgr: connMgr,
@@ -77,7 +76,7 @@ func (es *EventExporterService) IsRunning() bool {
}
// Reload handles the change of config
func (es *EventExporterService) Reload(*context.Context, context.CancelFunc) error {
func (es *EventExporterService) Reload(_ chan struct{}) error {
es.mu.Lock()
defer es.mu.Unlock()
es.eeS.ClearExporterCache()
@@ -96,7 +95,7 @@ func (es *EventExporterService) Shutdown() error {
}
// Start should handle the service start
func (es *EventExporterService) Start(ctx *context.Context, _ context.CancelFunc) error {
func (es *EventExporterService) Start(_ chan struct{}) error {
if es.IsRunning() {
return utils.ErrServiceAlreadyRunning
}

View File

@@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -62,7 +60,7 @@ func NewExportFailoverService(cfg *config.CGRConfig, connMgr *engine.ConnManager
}
// Start should handle the service start
func (efServ *ExportFailoverService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (efServ *ExportFailoverService) Start(_ chan struct{}) (err error) {
if efServ.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -83,7 +81,7 @@ func (efServ *ExportFailoverService) Start(ctx *context.Context, _ context.Cance
}
// Reload handles the change of config
func (efServ *ExportFailoverService) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (efServ *ExportFailoverService) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -36,7 +35,7 @@ import (
func NewEventReaderService(
cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *EventReaderService {
return &EventReaderService{
rldChan: make(chan struct{}, 1),
cfg: cfg,
@@ -64,7 +63,7 @@ type EventReaderService struct {
}
// Start should handle the sercive start
func (erS *EventReaderService) Start(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (erS *EventReaderService) Start(shutdown chan struct{}) (err error) {
if erS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -93,7 +92,7 @@ func (erS *EventReaderService) Start(ctx *context.Context, shtDwn context.Cancel
// build the service
erS.ers = ers.NewERService(erS.cfg, fs.FilterS(), erS.connMgr)
go erS.listenAndServe(erS.ers, erS.stopChan, erS.rldChan, shtDwn)
go erS.listenAndServe(erS.ers, erS.stopChan, erS.rldChan, shutdown)
srv, err := engine.NewServiceWithPing(erS.ers, utils.ErSv1, utils.V1Prfx)
if err != nil {
@@ -107,16 +106,16 @@ func (erS *EventReaderService) Start(ctx *context.Context, shtDwn context.Cancel
return
}
func (erS *EventReaderService) listenAndServe(ers *ers.ERService, stopChan chan struct{}, rldChan chan struct{}, shtDwn context.CancelFunc) (err error) {
func (erS *EventReaderService) listenAndServe(ers *ers.ERService, stopChan, rldChan, shutdown chan struct{}) (err error) {
if err = ers.ListenAndServe(stopChan, rldChan); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> error: <%v>", utils.ERs, err))
shtDwn()
close(shutdown)
}
return
}
// Reload handles the change of config
func (erS *EventReaderService) Reload(*context.Context, context.CancelFunc) (err error) {
func (erS *EventReaderService) Reload(_ chan struct{}) (err error) {
erS.RLock()
erS.rldChan <- struct{}{}
erS.RUnlock()

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/servmanager"
@@ -55,12 +54,12 @@ type FilterService struct {
}
// Start handles the service start.
func (s *FilterService) Start(ctx *context.Context, _ context.CancelFunc) error {
func (s *FilterService) Start(shutdown chan struct{}) error {
cacheS := s.srvIndexer.GetService(utils.CacheS).(*CacheService)
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), s.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.FilterS, utils.CacheS, utils.StateServiceUP)
}
if err := cacheS.WaitToPrecache(ctx, utils.CacheFilters); err != nil {
if err := cacheS.WaitToPrecache(shutdown, utils.CacheFilters); err != nil {
return err
}
dbs := s.srvIndexer.GetService(utils.DataDB).(*DataDBService)
@@ -73,7 +72,7 @@ func (s *FilterService) Start(ctx *context.Context, _ context.CancelFunc) error
}
// Reload handles the config changes.
func (s *FilterService) Reload(*context.Context, context.CancelFunc) error {
func (s *FilterService) Reload(_ chan struct{}) error {
return nil
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/agents"
@@ -35,7 +34,7 @@ import (
// NewFreeswitchAgent returns the Freeswitch Agent
func NewFreeswitchAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *FreeswitchAgent {
return &FreeswitchAgent{
cfg: cfg,
connMgr: connMgr,
@@ -58,7 +57,7 @@ type FreeswitchAgent struct {
}
// Start should handle the sercive start
func (fS *FreeswitchAgent) Start(_ *context.Context, shtDwn context.CancelFunc) (err error) {
func (fS *FreeswitchAgent) Start(shutdown chan struct{}) (err error) {
if fS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -68,27 +67,27 @@ func (fS *FreeswitchAgent) Start(_ *context.Context, shtDwn context.CancelFunc)
fS.fS = agents.NewFSsessions(fS.cfg.FsAgentCfg(), fS.cfg.GeneralCfg().DefaultTimezone, fS.connMgr)
go fS.connect(shtDwn)
go fS.connect(shutdown)
close(fS.stateDeps.StateChan(utils.StateServiceUP))
return
}
// Reload handles the change of config
func (fS *FreeswitchAgent) Reload(_ *context.Context, shtDwn context.CancelFunc) (err error) {
func (fS *FreeswitchAgent) Reload(shutdown chan struct{}) (err error) {
fS.Lock()
defer fS.Unlock()
if err = fS.fS.Shutdown(); err != nil {
return
}
fS.fS.Reload()
go fS.connect(shtDwn)
go fS.connect(shutdown)
return
}
func (fS *FreeswitchAgent) connect(shtDwn context.CancelFunc) {
func (fS *FreeswitchAgent) connect(shutdown chan struct{}) {
if err := fS.fS.Connect(); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> error: %s!", utils.FreeSWITCHAgent, err))
shtDwn() // stop the engine here
close(shutdown) // stop the engine here
}
return
}

View File

@@ -20,7 +20,6 @@ package services
import (
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/config"
@@ -48,7 +47,7 @@ type GlobalVarS struct {
}
// Start should handle the sercive start
func (gv *GlobalVarS) Start(*context.Context, context.CancelFunc) error {
func (gv *GlobalVarS) Start(_ chan struct{}) error {
engine.SetHTTPPstrTransport(gv.cfg.HTTPCfg().ClientOpts)
utils.DecimalContext.MaxScale = gv.cfg.GeneralCfg().DecimalMaxScale
utils.DecimalContext.MinScale = gv.cfg.GeneralCfg().DecimalMinScale
@@ -59,7 +58,7 @@ func (gv *GlobalVarS) Start(*context.Context, context.CancelFunc) error {
}
// Reload handles the change of config
func (gv *GlobalVarS) Reload(*context.Context, context.CancelFunc) error {
func (gv *GlobalVarS) Reload(_ chan struct{}) error {
engine.SetHTTPPstrTransport(gv.cfg.HTTPCfg().ClientOpts)
utils.DecimalContext.MaxScale = gv.cfg.GeneralCfg().DecimalMaxScale
utils.DecimalContext.MinScale = gv.cfg.GeneralCfg().DecimalMinScale

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/guardian"
@@ -49,7 +48,7 @@ type GuardianService struct {
}
// Start handles the service start.
func (s *GuardianService) Start(_ *context.Context, _ context.CancelFunc) error {
func (s *GuardianService) Start(_ chan struct{}) error {
cls := s.srvIndexer.GetService(utils.CommonListenerS).(*CommonListenerService)
if utils.StructChanTimeout(cls.StateChan(utils.StateServiceUP), s.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.GuardianS, utils.CommonListenerS, utils.StateServiceUP)
@@ -70,7 +69,7 @@ func (s *GuardianService) Start(_ *context.Context, _ context.CancelFunc) error
}
// Reload handles the config changes.
func (s *GuardianService) Reload(*context.Context, context.CancelFunc) error {
func (s *GuardianService) Reload(_ chan struct{}) error {
return nil
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -35,7 +34,7 @@ import (
// NewHTTPAgent returns the HTTP Agent
func NewHTTPAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *HTTPAgent {
return &HTTPAgent{
cfg: cfg,
connMgr: connMgr,
@@ -63,7 +62,7 @@ type HTTPAgent struct {
}
// Start should handle the sercive start
func (ha *HTTPAgent) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ha *HTTPAgent) Start(_ chan struct{}) (err error) {
if ha.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -93,7 +92,7 @@ func (ha *HTTPAgent) Start(ctx *context.Context, _ context.CancelFunc) (err erro
}
// Reload handles the change of config
func (ha *HTTPAgent) Reload(*context.Context, context.CancelFunc) (err error) {
func (ha *HTTPAgent) Reload(_ chan struct{}) (err error) {
return // no reload
}

View File

@@ -24,7 +24,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -35,7 +34,7 @@ import (
// NewJanusAgent returns the Janus Agent
func NewJanusAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *JanusAgent {
return &JanusAgent{
cfg: cfg,
connMgr: connMgr,
@@ -63,7 +62,7 @@ type JanusAgent struct {
}
// Start should jandle the sercive start
func (ja *JanusAgent) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ja *JanusAgent) Start(_ chan struct{}) (err error) {
cls := ja.srvIndexer.GetService(utils.CommonListenerS).(*CommonListenerService)
if utils.StructChanTimeout(cls.StateChan(utils.StateServiceUP), ja.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.JanusAgent, utils.CommonListenerS, utils.StateServiceUP)
@@ -103,7 +102,7 @@ func (ja *JanusAgent) Start(ctx *context.Context, _ context.CancelFunc) (err err
}
// Reload jandles the change of config
func (ja *JanusAgent) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ja *JanusAgent) Reload(_ chan struct{}) (err error) {
return // no reload
}

View File

@@ -24,11 +24,9 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/servmanager"
"github.com/cgrates/cgrates/utils"
)
@@ -36,7 +34,7 @@ import (
// NewKamailioAgent returns the Kamailio Agent
func NewKamailioAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *KamailioAgent {
return &KamailioAgent{
cfg: cfg,
connMgr: connMgr,
@@ -59,7 +57,7 @@ type KamailioAgent struct {
}
// Start should handle the sercive start
func (kam *KamailioAgent) Start(_ *context.Context, shtDwn context.CancelFunc) (err error) {
func (kam *KamailioAgent) Start(shutdown chan struct{}) (err error) {
if kam.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -70,30 +68,30 @@ func (kam *KamailioAgent) Start(_ *context.Context, shtDwn context.CancelFunc) (
kam.kam = agents.NewKamailioAgent(kam.cfg.KamAgentCfg(), kam.connMgr,
utils.FirstNonEmpty(kam.cfg.KamAgentCfg().Timezone, kam.cfg.GeneralCfg().DefaultTimezone))
go kam.connect(kam.kam, shtDwn)
go kam.connect(kam.kam, shutdown)
close(kam.stateDeps.StateChan(utils.StateServiceUP))
return
}
// Reload handles the change of config
func (kam *KamailioAgent) Reload(_ *context.Context, shtDwn context.CancelFunc) (err error) {
func (kam *KamailioAgent) Reload(shutdown chan struct{}) (err error) {
kam.Lock()
defer kam.Unlock()
if err = kam.kam.Shutdown(); err != nil {
return
}
kam.kam.Reload()
go kam.connect(kam.kam, shtDwn)
go kam.connect(kam.kam, shutdown)
return
}
func (kam *KamailioAgent) connect(k *agents.KamailioAgent, shtDwn context.CancelFunc) (err error) {
func (kam *KamailioAgent) connect(k *agents.KamailioAgent, shutdown chan struct{}) (err error) {
if err = k.Connect(); err != nil {
if !strings.Contains(err.Error(), "use of closed network connection") { // if closed by us do not log
if !strings.Contains(err.Error(), "KamEvapi") {
utils.Logger.Err(fmt.Sprintf("<%s> error: %s", utils.KamailioAgent, err))
}
shtDwn()
close(shutdown)
}
}
return

View File

@@ -21,8 +21,6 @@ package services
import (
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -62,7 +60,7 @@ type LoaderService struct {
}
// Start should handle the service start
func (ldrs *LoaderService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ldrs *LoaderService) Start(_ chan struct{}) (err error) {
if ldrs.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -110,7 +108,7 @@ func (ldrs *LoaderService) Start(ctx *context.Context, _ context.CancelFunc) (er
}
// Reload handles the change of config
func (ldrs *LoaderService) Reload(ctx *context.Context, _ context.CancelFunc) error {
func (ldrs *LoaderService) Reload(_ chan struct{}) error {
fs := ldrs.srvIndexer.GetService(utils.FilterS).(*FilterService)
if utils.StructChanTimeout(fs.StateChan(utils.StateServiceUP), ldrs.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.LoaderS, utils.FilterS, utils.StateServiceUP)

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -34,7 +33,7 @@ import (
// NewRadiusAgent returns the Radius Agent
func NewRadiusAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *RadiusAgent {
return &RadiusAgent{
cfg: cfg,
connMgr: connMgr,
@@ -62,7 +61,7 @@ type RadiusAgent struct {
}
// Start should handle the sercive start
func (rad *RadiusAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (rad *RadiusAgent) Start(shutdown chan struct{}) (err error) {
if rad.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -85,21 +84,21 @@ func (rad *RadiusAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) (
}
rad.stopChan = make(chan struct{})
go rad.listenAndServe(rad.rad, shtDwn)
go rad.listenAndServe(rad.rad, shutdown)
close(rad.stateDeps.StateChan(utils.StateServiceUP))
return
}
func (rad *RadiusAgent) listenAndServe(r *agents.RadiusAgent, shtDwn context.CancelFunc) (err error) {
func (rad *RadiusAgent) listenAndServe(r *agents.RadiusAgent, shutdown chan struct{}) (err error) {
if err = r.ListenAndServe(rad.stopChan); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> error: <%s>", utils.RadiusAgent, err.Error()))
shtDwn()
close(shutdown)
}
return
}
// Reload handles the change of config
func (rad *RadiusAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (rad *RadiusAgent) Reload(shutdown chan struct{}) (err error) {
if rad.lnet == rad.cfg.RadiusAgentCfg().ListenNet &&
rad.lauth == rad.cfg.RadiusAgentCfg().ListenAuth &&
rad.lacct == rad.cfg.RadiusAgentCfg().ListenAcct {
@@ -107,7 +106,7 @@ func (rad *RadiusAgent) Reload(ctx *context.Context, shtDwn context.CancelFunc)
}
rad.shutdown()
return rad.Start(ctx, shtDwn)
return rad.Start(shutdown)
}
// Shutdown stops the service

View File

@@ -36,7 +36,7 @@ import (
func NewRankingService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvDep map[string]*sync.WaitGroup,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *RankingService {
return &RankingService{
cfg: cfg,
connMgr: connMgr,
@@ -62,7 +62,7 @@ type RankingService struct {
}
// Start should handle the sercive start
func (ran *RankingService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ran *RankingService) Start(shutdown chan struct{}) (err error) {
if ran.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -77,7 +77,7 @@ func (ran *RankingService) Start(ctx *context.Context, _ context.CancelFunc) (er
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), ran.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.RankingS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheRankingProfiles,
utils.CacheRankings,
); err != nil {
@@ -102,7 +102,7 @@ func (ran *RankingService) Start(ctx *context.Context, _ context.CancelFunc) (er
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem",
utils.CoreS, utils.RankingS))
if err := ran.ran.StartRankingS(ctx); err != nil {
if err := ran.ran.StartRankingS(context.TODO()); err != nil {
return err
}
srv, err := engine.NewService(ran.ran)
@@ -120,9 +120,9 @@ func (ran *RankingService) Start(ctx *context.Context, _ context.CancelFunc) (er
}
// Reload handles the change of config
func (ran *RankingService) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ran *RankingService) Reload(_ chan struct{}) (err error) {
ran.Lock()
ran.ran.Reload(ctx)
ran.ran.Reload(context.TODO())
ran.Unlock()
return
}

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -33,7 +32,7 @@ import (
// NewRateService constructs RateService
func NewRateService(cfg *config.CGRConfig,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *RateService {
return &RateService{
cfg: cfg,
rldChan: make(chan struct{}),
@@ -76,7 +75,7 @@ func (rs *RateService) IsRunning() bool {
}
// Reload handles the change of config
func (rs *RateService) Reload(*context.Context, context.CancelFunc) (_ error) {
func (rs *RateService) Reload(_ chan struct{}) (_ error) {
rs.rldChan <- struct{}{}
return
}
@@ -93,7 +92,7 @@ func (rs *RateService) Shutdown() (err error) {
}
// Start should handle the service start
func (rs *RateService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (rs *RateService) Start(shutdown chan struct{}) (err error) {
if rs.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -107,7 +106,7 @@ func (rs *RateService) Start(ctx *context.Context, _ context.CancelFunc) (err er
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), rs.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.RateS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheRateProfiles,
utils.CacheRateProfilesFilterIndexes,
utils.CacheRateFilterIndexes); err != nil {

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/registrarc"
@@ -32,7 +31,7 @@ import (
// NewRegistrarCService returns the Dispatcher Service
func NewRegistrarCService(cfg *config.CGRConfig, connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *RegistrarCService {
return &RegistrarCService{
cfg: cfg,
connMgr: connMgr,
@@ -58,7 +57,7 @@ type RegistrarCService struct {
}
// Start should handle the sercive start
func (dspS *RegistrarCService) Start(*context.Context, context.CancelFunc) (err error) {
func (dspS *RegistrarCService) Start(_ chan struct{}) (err error) {
if dspS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -75,7 +74,7 @@ func (dspS *RegistrarCService) Start(*context.Context, context.CancelFunc) (err
}
// Reload handles the change of config
func (dspS *RegistrarCService) Reload(*context.Context, context.CancelFunc) (err error) {
func (dspS *RegistrarCService) Reload(_ chan struct{}) (err error) {
dspS.rldChan <- struct{}{}
return // for the momment nothing to reload
}

View File

@@ -35,7 +35,7 @@ import (
func NewResourceService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvDep map[string]*sync.WaitGroup,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *ResourceService {
return &ResourceService{
cfg: cfg,
connMgr: connMgr,
@@ -62,7 +62,7 @@ type ResourceService struct {
}
// Start should handle the service start
func (reS *ResourceService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (reS *ResourceService) Start(shutdown chan struct{}) (err error) {
if reS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -77,7 +77,7 @@ func (reS *ResourceService) Start(ctx *context.Context, _ context.CancelFunc) (e
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), reS.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.ResourceS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheResourceProfiles,
utils.CacheResources,
utils.CacheResourceFilterIndexes); err != nil {
@@ -100,7 +100,7 @@ func (reS *ResourceService) Start(ctx *context.Context, _ context.CancelFunc) (e
defer reS.Unlock()
reS.reS = engine.NewResourceService(dbs.DataManager(), reS.cfg, fs.FilterS(), reS.connMgr)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ResourceS))
reS.reS.StartLoop(ctx)
reS.reS.StartLoop(context.TODO())
srv, _ := engine.NewService(reS.reS)
// srv, _ := birpc.NewService(apis.NewResourceSv1(reS.reS), "", false)
if !reS.cfg.DispatcherSCfg().Enabled {
@@ -115,9 +115,9 @@ func (reS *ResourceService) Start(ctx *context.Context, _ context.CancelFunc) (e
}
// Reload handles the change of config
func (reS *ResourceService) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (reS *ResourceService) Reload(_ chan struct{}) (err error) {
reS.Lock()
reS.reS.Reload(ctx)
reS.reS.Reload(context.TODO())
reS.Unlock()
return
}

View File

@@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -35,7 +33,7 @@ import (
// NewRouteService returns the Route Service
func NewRouteService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *RouteService {
return &RouteService{
cfg: cfg,
connMgr: connMgr,
@@ -60,7 +58,7 @@ type RouteService struct {
}
// Start should handle the sercive start
func (routeS *RouteService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (routeS *RouteService) Start(shutdown chan struct{}) (err error) {
if routeS.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -74,7 +72,7 @@ func (routeS *RouteService) Start(ctx *context.Context, _ context.CancelFunc) (e
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), routeS.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.RouteS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheRouteProfiles,
utils.CacheRouteFilterIndexes); err != nil {
return
@@ -110,7 +108,7 @@ func (routeS *RouteService) Start(ctx *context.Context, _ context.CancelFunc) (e
}
// Reload handles the change of config
func (routeS *RouteService) Reload(*context.Context, context.CancelFunc) (err error) {
func (routeS *RouteService) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/engine"
@@ -37,7 +35,7 @@ import (
// NewSessionService returns the Session Service
func NewSessionService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *SessionService {
return &SessionService{
cfg: cfg,
connMgr: connMgr,
@@ -64,7 +62,7 @@ type SessionService struct {
}
// Start should handle the service start
func (smg *SessionService) Start(ctx *context.Context, shtDw context.CancelFunc) (err error) {
func (smg *SessionService) Start(shutdown chan struct{}) (err error) {
if smg.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -111,26 +109,26 @@ func (smg *SessionService) Start(ctx *context.Context, shtDw context.CancelFunc)
smg.cl.BiRPCRegisterName(n, s)
}
// run this in it's own goroutine
go smg.start(shtDw)
go smg.start(shutdown)
}
close(smg.stateDeps.StateChan(utils.StateServiceUP))
return
}
func (smg *SessionService) start(shtDw context.CancelFunc) (err error) {
func (smg *SessionService) start(shutdown chan struct{}) (err error) {
if err := smg.cl.ServeBiRPC(smg.cfg.SessionSCfg().ListenBijson,
smg.cfg.SessionSCfg().ListenBigob, smg.sm.OnBiJSONConnect, smg.sm.OnBiJSONDisconnect); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> serve BiRPC error: %s!", utils.SessionS, err))
smg.Lock()
smg.bircpEnabled = false
smg.Unlock()
shtDw()
close(shutdown)
}
return
}
// Reload handles the change of config
func (smg *SessionService) Reload(*context.Context, context.CancelFunc) (err error) {
func (smg *SessionService) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/agents"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
@@ -34,7 +33,7 @@ import (
// NewSIPAgent returns the sip Agent
func NewSIPAgent(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *SIPAgent {
return &SIPAgent{
cfg: cfg,
connMgr: connMgr,
@@ -59,7 +58,7 @@ type SIPAgent struct {
}
// Start should handle the sercive start
func (sip *SIPAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) (err error) {
func (sip *SIPAgent) Start(shutdown chan struct{}) (err error) {
if sip.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -78,20 +77,20 @@ func (sip *SIPAgent) Start(ctx *context.Context, shtDwn context.CancelFunc) (err
utils.SIPAgent, err))
return
}
go sip.listenAndServe(shtDwn)
go sip.listenAndServe(shutdown)
close(sip.stateDeps.StateChan(utils.StateServiceUP))
return
}
func (sip *SIPAgent) listenAndServe(shtDwn context.CancelFunc) {
func (sip *SIPAgent) listenAndServe(shutdown chan struct{}) {
if err := sip.sip.ListenAndServe(); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> error: <%s>", utils.SIPAgent, err.Error()))
shtDwn() // stop the engine here
close(shutdown) // stop the engine here
}
}
// Reload handles the change of config
func (sip *SIPAgent) Reload(_ *context.Context, shtDwn context.CancelFunc) (err error) {
func (sip *SIPAgent) Reload(shutdown chan struct{}) (err error) {
if sip.oldListen == sip.cfg.SIPAgentCfg().Listen {
return
}
@@ -100,7 +99,7 @@ func (sip *SIPAgent) Reload(_ *context.Context, shtDwn context.CancelFunc) (err
sip.oldListen = sip.cfg.SIPAgentCfg().Listen
sip.sip.InitStopChan()
sip.Unlock()
go sip.listenAndServe(shtDwn)
go sip.listenAndServe(shutdown)
return
}

View File

@@ -35,7 +35,7 @@ import (
func NewStatService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvDep map[string]*sync.WaitGroup,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *StatService {
return &StatService{
cfg: cfg,
connMgr: connMgr,
@@ -62,7 +62,7 @@ type StatService struct {
}
// Start should handle the sercive start
func (sts *StatService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (sts *StatService) Start(shutdown chan struct{}) (err error) {
if sts.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -77,7 +77,7 @@ func (sts *StatService) Start(ctx *context.Context, _ context.CancelFunc) (err e
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), sts.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.StatS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheStatQueueProfiles,
utils.CacheStatQueues,
utils.CacheStatFilterIndexes); err != nil {
@@ -102,7 +102,7 @@ func (sts *StatService) Start(ctx *context.Context, _ context.CancelFunc) (err e
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem",
utils.CoreS, utils.StatS))
sts.sts.StartLoop(ctx)
sts.sts.StartLoop(context.TODO())
srv, _ := engine.NewService(sts.sts)
// srv, _ := birpc.NewService(apis.NewStatSv1(sts.sts), "", false)
if !sts.cfg.DispatcherSCfg().Enabled {
@@ -116,9 +116,9 @@ func (sts *StatService) Start(ctx *context.Context, _ context.CancelFunc) (err e
}
// Reload handles the change of config
func (sts *StatService) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (sts *StatService) Reload(_ chan struct{}) (err error) {
sts.Lock()
sts.sts.Reload(ctx)
sts.sts.Reload(context.TODO())
sts.Unlock()
return
}

View File

@@ -23,7 +23,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/servmanager"
@@ -56,7 +55,7 @@ type StorDBService struct {
}
// Start should handle the service start
func (db *StorDBService) Start(*context.Context, context.CancelFunc) (err error) {
func (db *StorDBService) Start(_ chan struct{}) (err error) {
if db.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -87,7 +86,7 @@ func (db *StorDBService) Start(*context.Context, context.CancelFunc) (err error)
}
// Reload handles the change of config
func (db *StorDBService) Reload(*context.Context, context.CancelFunc) (err error) {
func (db *StorDBService) Reload(_ chan struct{}) (err error) {
db.Lock()
defer db.Unlock()
if db.needsConnectionReload() {

View File

@@ -35,7 +35,7 @@ import (
func NewThresholdService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvDep map[string]*sync.WaitGroup,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *ThresholdService {
return &ThresholdService{
cfg: cfg,
srvDep: srvDep,
@@ -62,7 +62,7 @@ type ThresholdService struct {
}
// Start should handle the sercive start
func (thrs *ThresholdService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (thrs *ThresholdService) Start(shutdown chan struct{}) (err error) {
if thrs.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -77,7 +77,7 @@ func (thrs *ThresholdService) Start(ctx *context.Context, _ context.CancelFunc)
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), thrs.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.ThresholdS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheThresholdProfiles,
utils.CacheThresholds,
utils.CacheThresholdFilterIndexes); err != nil {
@@ -101,7 +101,7 @@ func (thrs *ThresholdService) Start(ctx *context.Context, _ context.CancelFunc)
thrs.thrs = engine.NewThresholdService(dbs.DataManager(), thrs.cfg, fs.FilterS(), thrs.connMgr)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ThresholdS))
thrs.thrs.StartLoop(ctx)
thrs.thrs.StartLoop(context.TODO())
srv, _ := engine.NewService(thrs.thrs)
// srv, _ := birpc.NewService(apis.NewThresholdSv1(thrs.thrs), "", false)
if !thrs.cfg.DispatcherSCfg().Enabled {
@@ -115,9 +115,9 @@ func (thrs *ThresholdService) Start(ctx *context.Context, _ context.CancelFunc)
}
// Reload handles the change of config
func (thrs *ThresholdService) Reload(ctx *context.Context, _ context.CancelFunc) (_ error) {
func (thrs *ThresholdService) Reload(_ chan struct{}) (_ error) {
thrs.Lock()
thrs.thrs.Reload(ctx)
thrs.thrs.Reload(context.TODO())
thrs.Unlock()
return
}

View File

@@ -22,7 +22,6 @@ import (
"sync"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/apis"
"github.com/cgrates/cgrates/commonlisteners"
"github.com/cgrates/cgrates/config"
@@ -34,7 +33,7 @@ import (
// NewTPeService is the constructor for the TpeService
func NewTPeService(cfg *config.CGRConfig, connMgr *engine.ConnManager,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *TPeService {
return &TPeService{
cfg: cfg,
connMgr: connMgr,
@@ -61,7 +60,7 @@ type TPeService struct {
}
// Start should handle the service start
func (ts *TPeService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (ts *TPeService) Start(_ chan struct{}) (err error) {
cls := ts.srvIndexer.GetService(utils.CommonListenerS).(*CommonListenerService)
if utils.StructChanTimeout(cls.StateChan(utils.StateServiceUP), ts.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.TPeS, utils.CommonListenerS, utils.StateServiceUP)
@@ -82,7 +81,7 @@ func (ts *TPeService) Start(ctx *context.Context, _ context.CancelFunc) (err err
}
// Reload handles the change of config
func (ts *TPeService) Reload(*context.Context, context.CancelFunc) (err error) {
func (ts *TPeService) Reload(_ chan struct{}) (err error) {
return
}

View File

@@ -35,7 +35,7 @@ import (
func NewTrendService(cfg *config.CGRConfig,
connMgr *engine.ConnManager,
srvDep map[string]*sync.WaitGroup,
srvIndexer *servmanager.ServiceIndexer) servmanager.Service {
srvIndexer *servmanager.ServiceIndexer) *TrendService {
return &TrendService{
cfg: cfg,
connMgr: connMgr,
@@ -61,7 +61,7 @@ type TrendService struct {
}
// Start should handle the sercive start
func (trs *TrendService) Start(ctx *context.Context, _ context.CancelFunc) (err error) {
func (trs *TrendService) Start(shutdown chan struct{}) (err error) {
if trs.IsRunning() {
return utils.ErrServiceAlreadyRunning
}
@@ -76,7 +76,7 @@ func (trs *TrendService) Start(ctx *context.Context, _ context.CancelFunc) (err
if utils.StructChanTimeout(cacheS.StateChan(utils.StateServiceUP), trs.cfg.GeneralCfg().ConnectTimeout) {
return utils.NewServiceStateTimeoutError(utils.TrendS, utils.CacheS, utils.StateServiceUP)
}
if err = cacheS.WaitToPrecache(ctx,
if err = cacheS.WaitToPrecache(shutdown,
utils.CacheTrendProfiles,
utils.CacheTrends,
); err != nil {
@@ -99,7 +99,7 @@ func (trs *TrendService) Start(ctx *context.Context, _ context.CancelFunc) (err
defer trs.Unlock()
trs.trs = engine.NewTrendService(dbs.DataManager(), trs.cfg, fs.FilterS(), trs.connMgr)
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.TrendS))
if err := trs.trs.StartTrendS(ctx); err != nil {
if err := trs.trs.StartTrendS(context.TODO()); err != nil {
return err
}
srv, err := engine.NewService(trs.trs)
@@ -117,9 +117,9 @@ func (trs *TrendService) Start(ctx *context.Context, _ context.CancelFunc) (err
}
// Reload handles the change of config
func (trs *TrendService) Reload(ctx *context.Context, _ context.CancelFunc) (err error) {
func (trs *TrendService) Reload(_ chan struct{}) (err error) {
trs.Lock()
trs.trs.Reload(ctx)
trs.trs.Reload(context.TODO())
trs.Unlock()
return
}