From f3b4390838592ff262849dfb0943b3012d79a88f Mon Sep 17 00:00:00 2001 From: adi Date: Wed, 5 Oct 2022 17:03:17 +0300 Subject: [PATCH] Dispatchers and cache --- apis/dispatchers.go | 5 +++++ engine/caches.go | 2 +- utils/apitpdata.go | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apis/dispatchers.go b/apis/dispatchers.go index f7e8b186e..6aebf5d02 100644 --- a/apis/dispatchers.go +++ b/apis/dispatchers.go @@ -137,6 +137,11 @@ func (admS *AdminSv1) SetDispatcherProfile(ctx *context.Context, args *Dispatche args.TenantID(), &args.FilterIDs, args.APIOpts); err != nil { return utils.APIErrorHandler(err) } + //handle caching for DispatcherProfile + if err := admS.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]), args.Tenant, utils.CacheDispatcherProfiles, + args.TenantID(), &args.FilterIDs, args.APIOpts); err != nil { + return utils.APIErrorHandler(err) + } *reply = utils.OK return nil } diff --git a/engine/caches.go b/engine/caches.go index 2038a852c..0e5dc73b5 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -207,7 +207,7 @@ func (chS *CacheS) GetWithRemote(ctx *context.Context, args *utils.ArgsGetCacheI } if len(chS.cfg.CacheCfg().RemoteConns) == 0 || !chS.cfg.CacheCfg().Partitions[args.CacheID].Remote { - return nil, fmt.Errorf("Remote connections are missing from Cache config or Remote field of partition: %s is false", args.CacheID) + return nil, utils.ErrNotFound } // item was not found locally, query from remote if err = chS.connMgr.Call(ctx, chS.cfg.CacheCfg().RemoteConns, diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 3d8fde708..09fb0cb2f 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -463,6 +463,8 @@ func NewAttrReloadCacheWithOptsFromMap(arg map[string][]string, tnt string, opts ChargerProfileIDs: arg[CacheChargerProfiles], DispatcherProfileIDs: arg[CacheDispatcherProfiles], DispatcherHostIDs: arg[CacheDispatcherHosts], + Dispatchers: arg[CacheDispatchers], + DispatcherRoutes: arg[CacheDispatcherRoutes], RateProfileIDs: arg[CacheRateProfiles], ActionProfileIDs: arg[CacheActionProfiles], AccountIDs: arg[CacheAccounts], @@ -497,6 +499,8 @@ type AttrReloadCacheWithAPIOpts struct { ChargerProfileIDs []string `json:",omitempty"` DispatcherProfileIDs []string `json:",omitempty"` DispatcherHostIDs []string `json:",omitempty"` + Dispatchers []string `json:",omitempty"` + DispatcherRoutes []string `json:",omitempty"` RateProfileIDs []string `json:",omitempty"` ActionProfileIDs []string `json:",omitempty"` AccountIDs []string `json:",omitempty"`