mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated automatic cache reloads
This commit is contained in:
committed by
Dan Christian Bogos
parent
a8ecf36bec
commit
5148dff2a2
@@ -137,6 +137,9 @@ func (api *APIerSv1) RemoveActionTiming(attrs AttrRemoveActionTiming, reply *str
|
||||
}
|
||||
if err := api.ConnMgr.Call(api.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: attrs.Tenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{ActionPlanIDs: []string{attrs.ActionPlanId}},
|
||||
},
|
||||
@@ -151,6 +154,9 @@ func (api *APIerSv1) RemoveActionTiming(attrs AttrRemoveActionTiming, reply *str
|
||||
if len(remAcntAPids) != 0 {
|
||||
if err := api.ConnMgr.Call(api.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: attrs.Tenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: remAcntAPids},
|
||||
},
|
||||
@@ -251,6 +257,9 @@ func (api *APIerSv1) SetAccount(attr utils.AttrSetAccount, reply *string) (err e
|
||||
}
|
||||
if err := api.ConnMgr.Call(api.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: attr.Tenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: []string{accID}, ActionPlanIDs: apIDs},
|
||||
},
|
||||
@@ -349,6 +358,9 @@ func (api *APIerSv1) RemoveAccount(attr utils.AttrRemoveAccount, reply *string)
|
||||
}
|
||||
if err = api.ConnMgr.Call(api.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: attr.Tenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: []string{accID}},
|
||||
},
|
||||
|
||||
@@ -155,6 +155,9 @@ func (apiv1 *APIerSv1) SetDestination(attrs utils.AttrSetDestination, reply *str
|
||||
}
|
||||
if err := apiv1.ConnMgr.Call(apiv1.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: apiv1.Config.GeneralCfg().DefaultTenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{ReverseDestinationIDs: dest.Prefixes,
|
||||
DestinationIDs: []string{attrs.Id}},
|
||||
@@ -232,6 +235,9 @@ func (apiv1 *APIerSv1) LoadDestination(attrs AttrLoadDestination, reply *string)
|
||||
}
|
||||
if err := apiv1.ConnMgr.Call(apiv1.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: apiv1.Config.GeneralCfg().DefaultTenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{DestinationIDs: []string{attrs.ID}},
|
||||
},
|
||||
@@ -690,6 +696,9 @@ func (apiv1 *APIerSv1) SetActionPlan(attrs AttrSetActionPlan, reply *string) (er
|
||||
}
|
||||
if err := apiv1.ConnMgr.Call(apiv1.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: apiv1.Config.GeneralCfg().DefaultTenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{ActionPlanIDs: []string{ap.Id}},
|
||||
},
|
||||
@@ -705,6 +714,9 @@ func (apiv1 *APIerSv1) SetActionPlan(attrs AttrSetActionPlan, reply *string) (er
|
||||
sl := prevAccountIDs.Slice()
|
||||
if err := apiv1.ConnMgr.Call(apiv1.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: apiv1.Config.GeneralCfg().DefaultTenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: sl},
|
||||
},
|
||||
@@ -806,6 +818,9 @@ func (apiv1 *APIerSv1) RemoveActionPlan(attr AttrGetActionPlan, reply *string) (
|
||||
sl := prevAccountIDs.Slice()
|
||||
if err := apiv1.ConnMgr.Call(apiv1.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: apiv1.Config.GeneralCfg().DefaultTenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: sl},
|
||||
},
|
||||
|
||||
@@ -191,6 +191,9 @@ func (apiv2 *APIerSv2) SetAccount(attr AttrSetAccount, reply *string) error {
|
||||
}
|
||||
return 0, apiv2.ConnMgr.Call(apiv2.Config.ApierCfg().CachesConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: attr.Tenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: []string{accID}, ActionPlanIDs: apIDs},
|
||||
},
|
||||
|
||||
@@ -835,6 +835,9 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
|
||||
var reply string
|
||||
if err := connMgr.Call(tpr.cacheConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
},
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{AccountActionPlanIDs: []string{id},
|
||||
ActionPlanIDs: []string{accountAction.ActionPlanId}},
|
||||
@@ -2399,6 +2402,9 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, argDispatcher *ut
|
||||
|
||||
//compose Reload Cache argument
|
||||
cacheArgs := utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
},
|
||||
ArgDispatcher: argDispatcher,
|
||||
AttrReloadCache: utils.AttrReloadCache{
|
||||
ArgsCache: utils.ArgsCache{
|
||||
@@ -2480,6 +2486,9 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, argDispatcher *ut
|
||||
log.Print("Clearing indexes")
|
||||
}
|
||||
clearArgs := &utils.AttrCacheIDsWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
},
|
||||
ArgDispatcher: argDispatcher,
|
||||
CacheIDs: cacheIDs,
|
||||
}
|
||||
|
||||
@@ -544,6 +544,10 @@ func (ldr *Loader) storeLoadedData(loaderType string,
|
||||
}
|
||||
|
||||
if len(ldr.cacheConns) != 0 {
|
||||
var tnt string
|
||||
if tnt, err = ldr.tenant.ParseValue(""); err != nil {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
switch caching {
|
||||
case utils.META_NONE:
|
||||
@@ -551,18 +555,21 @@ func (ldr *Loader) storeLoadedData(loaderType string,
|
||||
case utils.MetaReload:
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
case utils.MetaLoad:
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1LoadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
case utils.MetaRemove:
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -570,6 +577,7 @@ func (ldr *Loader) storeLoadedData(loaderType string,
|
||||
cacheArgs.FlushAll = true
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -800,6 +808,10 @@ func (ldr *Loader) removeLoadedData(loaderType, tntID, caching string) (err erro
|
||||
}
|
||||
|
||||
if len(ldr.cacheConns) != 0 {
|
||||
var tnt string
|
||||
if tnt, err = ldr.tenant.ParseValue(""); err != nil {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
switch caching {
|
||||
case utils.META_NONE:
|
||||
@@ -807,18 +819,21 @@ func (ldr *Loader) removeLoadedData(loaderType, tntID, caching string) (err erro
|
||||
case utils.MetaReload:
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
case utils.MetaLoad:
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1LoadCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
case utils.MetaRemove:
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -826,6 +841,7 @@ func (ldr *Loader) removeLoadedData(loaderType, tntID, caching string) (err erro
|
||||
cacheArgs.FlushAll = true
|
||||
if err = ldr.connMgr.Call(ldr.cacheConns, nil,
|
||||
utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
|
||||
TenantArg: utils.TenantArg{Tenant: tnt},
|
||||
AttrReloadCache: cacheArgs}, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user