mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Added Replication APIs to dispatcher
This commit is contained in:
committed by
Dan Christian Bogos
parent
b5b2251fab
commit
743c4e8a38
@@ -172,30 +172,38 @@ type CoreSv1Interface interface {
|
||||
|
||||
type ReplicatorSv1Interface interface {
|
||||
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
|
||||
GetAccount(args *dispatchers.StringWithApiKey, reply *engine.Account) error
|
||||
GetDestination(key *dispatchers.StringWithApiKey, reply *engine.Destination) error
|
||||
GetReverseDestination(key *dispatchers.StringWithApiKey, reply *[]string) error
|
||||
GetAccount(args *utils.StringWithApiKey, reply *engine.Account) error
|
||||
GetDestination(key *utils.StringWithApiKey, reply *engine.Destination) error
|
||||
GetReverseDestination(key *utils.StringWithApiKey, reply *[]string) error
|
||||
GetStatQueue(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueue) error
|
||||
GetFilter(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Filter) error
|
||||
GetThreshold(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Threshold) error
|
||||
GetThresholdProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ThresholdProfile) error
|
||||
GetStatQueueProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueueProfile) error
|
||||
GetTiming(id *dispatchers.StringWithApiKey, reply *utils.TPTiming) error
|
||||
GetTiming(id *utils.StringWithApiKey, reply *utils.TPTiming) error
|
||||
GetResource(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Resource) error
|
||||
GetResourceProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ResourceProfile) error
|
||||
GetActionTriggers(id *dispatchers.StringWithApiKey, reply *engine.ActionTriggers) error
|
||||
GetShareGroup(id *dispatchers.StringWithApiKey, reply *engine.SharedGroup) error
|
||||
GetActions(id *dispatchers.StringWithApiKey, reply *engine.Actions) error
|
||||
GetActionPlan(id *dispatchers.StringWithApiKey, reply *engine.ActionPlan) error
|
||||
GetAllActionPlans(_ *dispatchers.StringWithApiKey, reply *map[string]*engine.ActionPlan) error
|
||||
GetAccountActionPlans(id *dispatchers.StringWithApiKey, reply *[]string) error
|
||||
GetRatingPlan(id *dispatchers.StringWithApiKey, reply *engine.RatingPlan) error
|
||||
GetRatingProfile(id *dispatchers.StringWithApiKey, reply *engine.RatingProfile) error
|
||||
GetActionTriggers(id *utils.StringWithApiKey, reply *engine.ActionTriggers) error
|
||||
GetShareGroup(id *utils.StringWithApiKey, reply *engine.SharedGroup) error
|
||||
GetActions(id *utils.StringWithApiKey, reply *engine.Actions) error
|
||||
GetActionPlan(id *utils.StringWithApiKey, reply *engine.ActionPlan) error
|
||||
GetAllActionPlans(_ *utils.StringWithApiKey, reply *map[string]*engine.ActionPlan) error
|
||||
GetAccountActionPlans(id *utils.StringWithApiKey, reply *[]string) error
|
||||
GetRatingPlan(id *utils.StringWithApiKey, reply *engine.RatingPlan) error
|
||||
GetRatingProfile(id *utils.StringWithApiKey, reply *engine.RatingProfile) error
|
||||
GetSupplierProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.SupplierProfile) error
|
||||
GetAttributeProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.AttributeProfile) error
|
||||
GetChargerProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ChargerProfile) error
|
||||
GetDispatcherProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherProfile) error
|
||||
GetDispatcherHost(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherHost) error
|
||||
GetItemLoadIDs(itemID *dispatchers.StringWithApiKey, reply *map[string]int64) error
|
||||
GetItemLoadIDs(itemID *utils.StringWithApiKey, reply *map[string]int64) error
|
||||
GetFilterIndexes(args *utils.GetFilterIndexesArgWithArgDispatcher, reply *map[string]utils.StringMap) error
|
||||
MatchFilterIndex(args *utils.MatchFilterIndexArgWithArgDispatcher, reply *utils.StringMap) error
|
||||
SetThresholdProfile(th *engine.ThresholdProfileWithArgDispatcher, reply *string) error
|
||||
SetThreshold(th *engine.ThresholdWithArgDispatcher, reply *string) error
|
||||
SetFilterIndexes(args *utils.SetFilterIndexesArgWithArgDispatcher, reply *string) error
|
||||
SetAccount(acc *engine.AccountWithArgDispatcher, reply *string) error
|
||||
SetReverseDestination(dst *engine.DestinationWithArgDispatcher, reply *string) error
|
||||
SetStatQueue(ssq *engine.StoredStatQueueWithArgDispatcher, reply *string) error
|
||||
SetFilter(fltr *engine.FilterWithArgDispatcher, reply *string) error
|
||||
}
|
||||
|
||||
@@ -833,7 +833,7 @@ func testApierLoadAccountActions(t *testing.T) {
|
||||
func testApierReloadScheduler(t *testing.T) {
|
||||
var reply string
|
||||
// Simple test that command is executed without errors
|
||||
if err := rater.Call(utils.SchedulerSv1Reload, dispatchers.StringWithApiKey{}, &reply); err != nil {
|
||||
if err := rater.Call(utils.SchedulerSv1Reload, utils.StringWithApiKey{}, &reply); err != nil {
|
||||
t.Error("Got error on SchedulerSv1.Reload: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Calling SchedulerSv1.Reload got reply: ", reply)
|
||||
@@ -1790,7 +1790,7 @@ func testApierReloadCache2(t *testing.T) {
|
||||
func testApierReloadScheduler2(t *testing.T) {
|
||||
var reply string
|
||||
// Simple test that command is executed without errors
|
||||
if err := rater.Call(utils.SchedulerSv1Reload, dispatchers.StringWithApiKey{}, &reply); err != nil {
|
||||
if err := rater.Call(utils.SchedulerSv1Reload, utils.StringWithApiKey{}, &reply); err != nil {
|
||||
t.Error("Got error on SchedulerSv1.Reload: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Calling SchedulerSv1.Reload got reply: ", reply)
|
||||
@@ -1876,7 +1876,7 @@ func testApierStartStopServiceStatus(t *testing.T) {
|
||||
} else if reply != utils.RunningCaps {
|
||||
t.Errorf("Received: <%s>", reply)
|
||||
}
|
||||
if err := rater.Call(utils.SchedulerSv1Reload, dispatchers.StringWithApiKey{}, &reply); err != nil {
|
||||
if err := rater.Call(utils.SchedulerSv1Reload, utils.StringWithApiKey{}, &reply); err != nil {
|
||||
t.Error("Got error on SchedulerSv1.Reload: ", err.Error())
|
||||
} else if reply != utils.OK {
|
||||
t.Error("Calling SchedulerSv1.Reload got reply: ", reply)
|
||||
|
||||
@@ -847,17 +847,17 @@ func (dS *DispatcherReplicatorSv1) Ping(args *utils.CGREventWithArgDispatcher, r
|
||||
}
|
||||
|
||||
// GetAccount
|
||||
func (dS *DispatcherReplicatorSv1) GetAccount(args *dispatchers.StringWithApiKey, reply *engine.Account) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetAccount(args *utils.StringWithApiKey, reply *engine.Account) error {
|
||||
return dS.dS.ReplicatorSv1GetAccount(args, reply)
|
||||
}
|
||||
|
||||
// GetDestination
|
||||
func (dS *DispatcherReplicatorSv1) GetDestination(key *dispatchers.StringWithApiKey, reply *engine.Destination) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetDestination(key *utils.StringWithApiKey, reply *engine.Destination) error {
|
||||
return dS.dS.ReplicatorSv1GetDestination(key, reply)
|
||||
}
|
||||
|
||||
// GetReverseDestination
|
||||
func (dS *DispatcherReplicatorSv1) GetReverseDestination(key *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetReverseDestination(key *utils.StringWithApiKey, reply *[]string) error {
|
||||
return dS.dS.ReplicatorSv1GetReverseDestination(key, reply)
|
||||
}
|
||||
|
||||
@@ -887,7 +887,7 @@ func (dS *DispatcherReplicatorSv1) GetStatQueueProfile(tntID *utils.TenantIDWith
|
||||
}
|
||||
|
||||
// GetTiming
|
||||
func (dS *DispatcherReplicatorSv1) GetTiming(id *dispatchers.StringWithApiKey, reply *utils.TPTiming) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetTiming(id *utils.StringWithApiKey, reply *utils.TPTiming) error {
|
||||
return dS.dS.ReplicatorSv1GetTiming(id, reply)
|
||||
}
|
||||
|
||||
@@ -902,42 +902,42 @@ func (dS *DispatcherReplicatorSv1) GetResourceProfile(tntID *utils.TenantIDWithA
|
||||
}
|
||||
|
||||
// GetActionTriggers
|
||||
func (dS *DispatcherReplicatorSv1) GetActionTriggers(id *dispatchers.StringWithApiKey, reply *engine.ActionTriggers) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetActionTriggers(id *utils.StringWithApiKey, reply *engine.ActionTriggers) error {
|
||||
return dS.dS.ReplicatorSv1GetActionTriggers(id, reply)
|
||||
}
|
||||
|
||||
// GetShareGroup
|
||||
func (dS *DispatcherReplicatorSv1) GetShareGroup(id *dispatchers.StringWithApiKey, reply *engine.SharedGroup) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetShareGroup(id *utils.StringWithApiKey, reply *engine.SharedGroup) error {
|
||||
return dS.dS.ReplicatorSv1GetShareGroup(id, reply)
|
||||
}
|
||||
|
||||
// GetActions
|
||||
func (dS *DispatcherReplicatorSv1) GetActions(id *dispatchers.StringWithApiKey, reply *engine.Actions) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetActions(id *utils.StringWithApiKey, reply *engine.Actions) error {
|
||||
return dS.dS.ReplicatorSv1GetActions(id, reply)
|
||||
}
|
||||
|
||||
// GetActionPlan
|
||||
func (dS *DispatcherReplicatorSv1) GetActionPlan(id *dispatchers.StringWithApiKey, reply *engine.ActionPlan) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetActionPlan(id *utils.StringWithApiKey, reply *engine.ActionPlan) error {
|
||||
return dS.dS.ReplicatorSv1GetActionPlan(id, reply)
|
||||
}
|
||||
|
||||
// GetAllActionPlans
|
||||
func (dS *DispatcherReplicatorSv1) GetAllActionPlans(args *dispatchers.StringWithApiKey, reply *map[string]*engine.ActionPlan) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetAllActionPlans(args *utils.StringWithApiKey, reply *map[string]*engine.ActionPlan) error {
|
||||
return dS.dS.ReplicatorSv1GetAllActionPlans(args, reply)
|
||||
}
|
||||
|
||||
// GetAccountActionPlans
|
||||
func (dS *DispatcherReplicatorSv1) GetAccountActionPlans(id *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetAccountActionPlans(id *utils.StringWithApiKey, reply *[]string) error {
|
||||
return dS.dS.ReplicatorSv1GetAccountActionPlans(id, reply)
|
||||
}
|
||||
|
||||
// GetRatingPlan
|
||||
func (dS *DispatcherReplicatorSv1) GetRatingPlan(id *dispatchers.StringWithApiKey, reply *engine.RatingPlan) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetRatingPlan(id *utils.StringWithApiKey, reply *engine.RatingPlan) error {
|
||||
return dS.dS.ReplicatorSv1GetRatingPlan(id, reply)
|
||||
}
|
||||
|
||||
// GetRatingProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetRatingProfile(id *dispatchers.StringWithApiKey, reply *engine.RatingProfile) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetRatingProfile(id *utils.StringWithApiKey, reply *engine.RatingProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetRatingProfile(id, reply)
|
||||
}
|
||||
|
||||
@@ -967,7 +967,7 @@ func (dS *DispatcherReplicatorSv1) GetDispatcherHost(tntID *utils.TenantIDWithAr
|
||||
}
|
||||
|
||||
// GetItemLoadIDs
|
||||
func (dS *DispatcherReplicatorSv1) GetItemLoadIDs(itemID *dispatchers.StringWithApiKey, reply *map[string]int64) error {
|
||||
func (dS *DispatcherReplicatorSv1) GetItemLoadIDs(itemID *utils.StringWithApiKey, reply *map[string]int64) error {
|
||||
return dS.dS.ReplicatorSv1GetItemLoadIDs(itemID, reply)
|
||||
}
|
||||
|
||||
@@ -975,3 +975,45 @@ func (dS *DispatcherReplicatorSv1) GetItemLoadIDs(itemID *dispatchers.StringWith
|
||||
func (dS *DispatcherReplicatorSv1) GetFilterIndexes(args *utils.GetFilterIndexesArgWithArgDispatcher, reply *map[string]utils.StringMap) error {
|
||||
return dS.dS.ReplicatorSv1GetFilterIndexes(args, reply)
|
||||
}
|
||||
|
||||
// MatchFilterIndex
|
||||
func (dS *DispatcherReplicatorSv1) MatchFilterIndex(args *utils.MatchFilterIndexArgWithArgDispatcher, reply *utils.StringMap) error {
|
||||
return dS.dS.ReplicatorSv1MatchFilterIndex(args, reply)
|
||||
}
|
||||
|
||||
//finished all the above
|
||||
|
||||
// SetThresholdProfile
|
||||
func (dS *DispatcherReplicatorSv1) SetThresholdProfile(args *engine.ThresholdProfileWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetThresholdProfile(args, reply)
|
||||
}
|
||||
|
||||
// SetThreshold
|
||||
func (dS *DispatcherReplicatorSv1) SetThreshold(args *engine.ThresholdWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetThreshold(args, reply)
|
||||
}
|
||||
|
||||
// SetFilterIndexes
|
||||
func (dS *DispatcherReplicatorSv1) SetFilterIndexes(args *utils.SetFilterIndexesArgWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetFilterIndexes(args, reply)
|
||||
}
|
||||
|
||||
// SetAccount
|
||||
func (dS *DispatcherReplicatorSv1) SetAccount(args *engine.AccountWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetAccount(args, reply)
|
||||
}
|
||||
|
||||
// SetReverseDestination
|
||||
func (dS *DispatcherReplicatorSv1) SetReverseDestination(args *engine.DestinationWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetReverseDestination(args, reply)
|
||||
}
|
||||
|
||||
// SetStatQueue
|
||||
func (dS *DispatcherReplicatorSv1) SetStatQueue(args *engine.StoredStatQueueWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetStatQueue(args, reply)
|
||||
}
|
||||
|
||||
// SetFilter
|
||||
func (dS *DispatcherReplicatorSv1) SetFilter(args *engine.FilterWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1SetFilter(args, reply)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/cgrates/cgrates/dispatchers"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -39,7 +38,7 @@ func (rplSv1 *ReplicatorSv1) Call(serviceMethod string, args interface{}, reply
|
||||
}
|
||||
|
||||
//GetAccount
|
||||
func (rplSv1 *ReplicatorSv1) GetAccount(args *dispatchers.StringWithApiKey, reply *engine.Account) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetAccount(args *utils.StringWithApiKey, reply *engine.Account) error {
|
||||
if rcv, err := rplSv1.dm.GetAccount(args.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -49,7 +48,7 @@ func (rplSv1 *ReplicatorSv1) GetAccount(args *dispatchers.StringWithApiKey, repl
|
||||
}
|
||||
|
||||
//GetDestination
|
||||
func (rplSv1 *ReplicatorSv1) GetDestination(key *dispatchers.StringWithApiKey, reply *engine.Destination) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetDestination(key *utils.StringWithApiKey, reply *engine.Destination) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetDestinationDrv(key.Arg, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -59,7 +58,7 @@ func (rplSv1 *ReplicatorSv1) GetDestination(key *dispatchers.StringWithApiKey, r
|
||||
}
|
||||
|
||||
//GetDestination
|
||||
func (rplSv1 *ReplicatorSv1) GetReverseDestination(key *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetReverseDestination(key *utils.StringWithApiKey, reply *[]string) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetReverseDestinationDrv(key.Arg, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -119,7 +118,7 @@ func (rplSv1 *ReplicatorSv1) GetStatQueueProfile(tntID *utils.TenantIDWithArgDis
|
||||
}
|
||||
|
||||
//GetTiming
|
||||
func (rplSv1 *ReplicatorSv1) GetTiming(id *dispatchers.StringWithApiKey, reply *utils.TPTiming) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetTiming(id *utils.StringWithApiKey, reply *utils.TPTiming) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetTimingDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -149,7 +148,7 @@ func (rplSv1 *ReplicatorSv1) GetResourceProfile(tntID *utils.TenantIDWithArgDisp
|
||||
}
|
||||
|
||||
//GetActionTriggers
|
||||
func (rplSv1 *ReplicatorSv1) GetActionTriggers(id *dispatchers.StringWithApiKey, reply *engine.ActionTriggers) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetActionTriggers(id *utils.StringWithApiKey, reply *engine.ActionTriggers) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionTriggersDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -159,7 +158,7 @@ func (rplSv1 *ReplicatorSv1) GetActionTriggers(id *dispatchers.StringWithApiKey,
|
||||
}
|
||||
|
||||
//GetShareGroup
|
||||
func (rplSv1 *ReplicatorSv1) GetShareGroup(id *dispatchers.StringWithApiKey, reply *engine.SharedGroup) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetShareGroup(id *utils.StringWithApiKey, reply *engine.SharedGroup) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetSharedGroupDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -169,7 +168,7 @@ func (rplSv1 *ReplicatorSv1) GetShareGroup(id *dispatchers.StringWithApiKey, rep
|
||||
}
|
||||
|
||||
//GetActions
|
||||
func (rplSv1 *ReplicatorSv1) GetActions(id *dispatchers.StringWithApiKey, reply *engine.Actions) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetActions(id *utils.StringWithApiKey, reply *engine.Actions) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionsDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -179,7 +178,7 @@ func (rplSv1 *ReplicatorSv1) GetActions(id *dispatchers.StringWithApiKey, reply
|
||||
}
|
||||
|
||||
//GetActions
|
||||
func (rplSv1 *ReplicatorSv1) GetActionPlan(id *dispatchers.StringWithApiKey, reply *engine.ActionPlan) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetActionPlan(id *utils.StringWithApiKey, reply *engine.ActionPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionPlanDrv(id.Arg, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -189,7 +188,7 @@ func (rplSv1 *ReplicatorSv1) GetActionPlan(id *dispatchers.StringWithApiKey, rep
|
||||
}
|
||||
|
||||
//GetAllActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetAllActionPlans(_ *dispatchers.StringWithApiKey, reply *map[string]*engine.ActionPlan) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetAllActionPlans(_ *utils.StringWithApiKey, reply *map[string]*engine.ActionPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetAllActionPlansDrv(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -199,7 +198,7 @@ func (rplSv1 *ReplicatorSv1) GetAllActionPlans(_ *dispatchers.StringWithApiKey,
|
||||
}
|
||||
|
||||
//GetAccountActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetAccountActionPlans(id *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetAccountActionPlans(id *utils.StringWithApiKey, reply *[]string) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetAccountActionPlansDrv(id.Arg, false, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -209,7 +208,7 @@ func (rplSv1 *ReplicatorSv1) GetAccountActionPlans(id *dispatchers.StringWithApi
|
||||
}
|
||||
|
||||
//GetAllActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingPlan(id *dispatchers.StringWithApiKey, reply *engine.RatingPlan) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingPlan(id *utils.StringWithApiKey, reply *engine.RatingPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetRatingPlanDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -219,7 +218,7 @@ func (rplSv1 *ReplicatorSv1) GetRatingPlan(id *dispatchers.StringWithApiKey, rep
|
||||
}
|
||||
|
||||
//GetAllActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingProfile(id *dispatchers.StringWithApiKey, reply *engine.RatingProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingProfile(id *utils.StringWithApiKey, reply *engine.RatingProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetRatingProfileDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -279,7 +278,7 @@ func (rplSv1 *ReplicatorSv1) GetDispatcherHost(tntID *utils.TenantIDWithArgDispa
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetItemLoadIDs(itemID *dispatchers.StringWithApiKey, reply *map[string]int64) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetItemLoadIDs(itemID *utils.StringWithApiKey, reply *map[string]int64) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetItemLoadIDsDrv(itemID.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -300,7 +299,7 @@ func (rplSv1 *ReplicatorSv1) GetFilterIndexes(args *utils.GetFilterIndexesArgWit
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) MatchFilterIndex(args *utils.MatchFilterIndexArg, reply *utils.StringMap) error {
|
||||
func (rplSv1 *ReplicatorSv1) MatchFilterIndex(args *utils.MatchFilterIndexArgWithArgDispatcher, reply *utils.StringMap) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().MatchFilterIndexDrv(args.CacheID, args.ItemIDPrefix,
|
||||
args.FilterType, args.FieldName, args.FieldVal); err != nil {
|
||||
return err
|
||||
@@ -311,8 +310,8 @@ func (rplSv1 *ReplicatorSv1) MatchFilterIndex(args *utils.MatchFilterIndexArg, r
|
||||
}
|
||||
|
||||
// SetThresholdProfile alters/creates a ThresholdProfile
|
||||
func (rplSv1 *ReplicatorSv1) SetThresholdProfile(th *engine.ThresholdProfile, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetThresholdProfileDrv(th); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) SetThresholdProfile(th *engine.ThresholdProfileWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetThresholdProfileDrv(th.ThresholdProfile); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
@@ -320,8 +319,8 @@ func (rplSv1 *ReplicatorSv1) SetThresholdProfile(th *engine.ThresholdProfile, re
|
||||
}
|
||||
|
||||
// SetThreshold
|
||||
func (rplSv1 *ReplicatorSv1) SetThreshold(th *engine.Threshold, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetThresholdDrv(th); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) SetThreshold(th *engine.ThresholdWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetThresholdDrv(th.Threshold); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
@@ -329,7 +328,7 @@ func (rplSv1 *ReplicatorSv1) SetThreshold(th *engine.Threshold, reply *string) e
|
||||
}
|
||||
|
||||
// SetFilterIndexes
|
||||
func (rplSv1 *ReplicatorSv1) SetFilterIndexes(args *utils.SetFilterIndexesArg, reply *string) error {
|
||||
func (rplSv1 *ReplicatorSv1) SetFilterIndexes(args *utils.SetFilterIndexesArgWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetFilterIndexesDrv(args.CacheID, args.ItemIDPrefix,
|
||||
args.Indexes, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
@@ -339,8 +338,8 @@ func (rplSv1 *ReplicatorSv1) SetFilterIndexes(args *utils.SetFilterIndexesArg, r
|
||||
}
|
||||
|
||||
// SetAccount
|
||||
func (rplSv1 *ReplicatorSv1) SetAccount(acc *engine.Account, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetAccountDrv(acc); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) SetAccount(acc *engine.AccountWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetAccountDrv(acc.Account); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
@@ -357,8 +356,8 @@ func (rplSv1 *ReplicatorSv1) SetDestination(dst *engine.Destination, reply *stri
|
||||
}
|
||||
|
||||
// SetDestination
|
||||
func (rplSv1 *ReplicatorSv1) SetReverseDestination(dst *engine.Destination, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetReverseDestinationDrv(dst, utils.NonTransactional); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) SetReverseDestination(dst *engine.DestinationWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetReverseDestinationDrv(dst.Destination, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
@@ -366,8 +365,8 @@ func (rplSv1 *ReplicatorSv1) SetReverseDestination(dst *engine.Destination, repl
|
||||
}
|
||||
|
||||
// SetDestination
|
||||
func (rplSv1 *ReplicatorSv1) SetStatQueue(ssq *engine.StoredStatQueue, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetStatQueueDrv(ssq, nil); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) SetStatQueue(ssq *engine.StoredStatQueueWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetStatQueueDrv(ssq.StoredStatQueue, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
@@ -375,8 +374,8 @@ func (rplSv1 *ReplicatorSv1) SetStatQueue(ssq *engine.StoredStatQueue, reply *st
|
||||
}
|
||||
|
||||
// SetDestination
|
||||
func (rplSv1 *ReplicatorSv1) SetFilter(fltr *engine.Filter, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetFilterDrv(fltr); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) SetFilter(fltr *engine.FilterWithArgDispatcher, reply *string) error {
|
||||
if err := rplSv1.dm.DataDB().SetFilterDrv(fltr.Filter); err != nil {
|
||||
return err
|
||||
}
|
||||
*reply = utils.OK
|
||||
|
||||
@@ -47,9 +47,9 @@ func (dS *DispatcherService) ReplicatorSv1Ping(args *utils.CGREventWithArgDispat
|
||||
utils.ReplicatorSv1Ping, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAccount(args *StringWithApiKey, rpl *engine.Account) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAccount(args *utils.StringWithApiKey, rpl *engine.Account) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -69,9 +69,9 @@ func (dS *DispatcherService) ReplicatorSv1GetAccount(args *StringWithApiKey, rpl
|
||||
utils.ReplicatorSv1GetAccount, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetDestination(args *StringWithApiKey, rpl *engine.Destination) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetDestination(args *utils.StringWithApiKey, rpl *engine.Destination) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -91,9 +91,9 @@ func (dS *DispatcherService) ReplicatorSv1GetDestination(args *StringWithApiKey,
|
||||
utils.ReplicatorSv1GetDestination, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetReverseDestination(args *StringWithApiKey, rpl *[]string) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetReverseDestination(args *utils.StringWithApiKey, rpl *[]string) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -218,9 +218,9 @@ func (dS *DispatcherService) ReplicatorSv1GetStatQueueProfile(args *utils.Tenant
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetStatQueueProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetTiming(args *StringWithApiKey, rpl *utils.TPTiming) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetTiming(args *utils.StringWithApiKey, rpl *utils.TPTiming) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -282,9 +282,9 @@ func (dS *DispatcherService) ReplicatorSv1GetResourceProfile(args *utils.TenantI
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetResourceProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActionTriggers(args *StringWithApiKey, rpl *engine.ActionTriggers) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActionTriggers(args *utils.StringWithApiKey, rpl *engine.ActionTriggers) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -304,9 +304,9 @@ func (dS *DispatcherService) ReplicatorSv1GetActionTriggers(args *StringWithApiK
|
||||
utils.ReplicatorSv1GetActionTriggers, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetShareGroup(args *StringWithApiKey, rpl *engine.SharedGroup) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetShareGroup(args *utils.StringWithApiKey, rpl *engine.SharedGroup) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -326,9 +326,9 @@ func (dS *DispatcherService) ReplicatorSv1GetShareGroup(args *StringWithApiKey,
|
||||
utils.ReplicatorSv1GetShareGroup, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActions(args *StringWithApiKey, rpl *engine.Actions) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActions(args *utils.StringWithApiKey, rpl *engine.Actions) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -348,9 +348,9 @@ func (dS *DispatcherService) ReplicatorSv1GetActions(args *StringWithApiKey, rpl
|
||||
utils.ReplicatorSv1GetActions, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActionPlan(args *StringWithApiKey, rpl *engine.ActionPlan) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActionPlan(args *utils.StringWithApiKey, rpl *engine.ActionPlan) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -370,9 +370,9 @@ func (dS *DispatcherService) ReplicatorSv1GetActionPlan(args *StringWithApiKey,
|
||||
utils.ReplicatorSv1GetActionPlan, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAllActionPlans(args *StringWithApiKey, rpl *map[string]*engine.ActionPlan) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAllActionPlans(args *utils.StringWithApiKey, rpl *map[string]*engine.ActionPlan) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -392,9 +392,9 @@ func (dS *DispatcherService) ReplicatorSv1GetAllActionPlans(args *StringWithApiK
|
||||
utils.ReplicatorSv1GetAllActionPlans, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAccountActionPlans(args *StringWithApiKey, rpl *[]string) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAccountActionPlans(args *utils.StringWithApiKey, rpl *[]string) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -414,9 +414,9 @@ func (dS *DispatcherService) ReplicatorSv1GetAccountActionPlans(args *StringWith
|
||||
utils.ReplicatorSv1GetAccountActionPlans, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetRatingPlan(args *StringWithApiKey, rpl *engine.RatingPlan) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetRatingPlan(args *utils.StringWithApiKey, rpl *engine.RatingPlan) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -436,9 +436,9 @@ func (dS *DispatcherService) ReplicatorSv1GetRatingPlan(args *StringWithApiKey,
|
||||
utils.ReplicatorSv1GetRatingPlan, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetRatingProfile(args *StringWithApiKey, rpl *engine.RatingProfile) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetRatingProfile(args *utils.StringWithApiKey, rpl *engine.RatingProfile) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -563,9 +563,9 @@ func (dS *DispatcherService) ReplicatorSv1GetDispatcherHost(args *utils.TenantID
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetDispatcherHost, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetItemLoadIDs(args *StringWithApiKey, rpl *map[string]int64) (err error) {
|
||||
func (dS *DispatcherService) ReplicatorSv1GetItemLoadIDs(args *utils.StringWithApiKey, rpl *map[string]int64) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
args = &utils.StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
@@ -606,3 +606,179 @@ func (dS *DispatcherService) ReplicatorSv1GetFilterIndexes(args *utils.GetFilter
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetFilterIndexes, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1MatchFilterIndex(args *utils.MatchFilterIndexArgWithArgDispatcher, rpl *utils.StringMap) (err error) {
|
||||
if args == nil {
|
||||
args = &utils.MatchFilterIndexArgWithArgDispatcher{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1MatchFilterIndex, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1MatchFilterIndex, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetThresholdProfile(args *engine.ThresholdProfileWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &engine.ThresholdProfileWithArgDispatcher{}
|
||||
}
|
||||
args.ThresholdProfile.Tenant = utils.FirstNonEmpty(args.ThresholdProfile.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetThresholdProfile, args.ThresholdProfile.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.ThresholdProfile.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetThresholdProfile, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetThreshold(args *engine.ThresholdWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &engine.ThresholdWithArgDispatcher{}
|
||||
}
|
||||
args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetThreshold, args.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetThreshold, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetFilterIndexes(args *utils.SetFilterIndexesArgWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &utils.SetFilterIndexesArgWithArgDispatcher{}
|
||||
}
|
||||
args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetFilterIndexes, args.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetFilterIndexes, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetAccount(args *engine.AccountWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &engine.AccountWithArgDispatcher{}
|
||||
}
|
||||
tenant := utils.FirstNonEmpty(utils.SplitConcatenatedKey(args.ID)[0], dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetAccount, tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetAccount, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetReverseDestination(args *engine.DestinationWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &engine.DestinationWithArgDispatcher{}
|
||||
}
|
||||
args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetReverseDestination, args.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetReverseDestination, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetStatQueue(args *engine.StoredStatQueueWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &engine.StoredStatQueueWithArgDispatcher{}
|
||||
}
|
||||
args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetStatQueue, args.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetStatQueue, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1SetFilter(args *engine.FilterWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = &engine.FilterWithArgDispatcher{}
|
||||
}
|
||||
args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1SetFilter, args.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1SetFilter, args, rpl)
|
||||
}
|
||||
|
||||
@@ -59,12 +59,6 @@ type AttrRemoteUnlockWithApiKey struct {
|
||||
RefID string
|
||||
}
|
||||
|
||||
type StringWithApiKey struct {
|
||||
*utils.ArgDispatcher
|
||||
utils.TenantArg
|
||||
Arg string
|
||||
}
|
||||
|
||||
type ArgStartServiceWithApiKey struct {
|
||||
*utils.ArgDispatcher
|
||||
utils.TenantArg
|
||||
|
||||
@@ -44,6 +44,11 @@ type Account struct {
|
||||
executingTriggers bool
|
||||
}
|
||||
|
||||
type AccountWithArgDispatcher struct {
|
||||
*Account
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
// User's available minutes for the specified destination
|
||||
func (acc *Account) getCreditForPrefix(cd *CallDescriptor) (duration time.Duration, credit float64, balances Balances) {
|
||||
creditBalances := acc.getBalancesForPrefix(cd.Destination, cd.Category, utils.MONETARY, "", cd.TimeStart)
|
||||
|
||||
@@ -320,9 +320,16 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b
|
||||
func (dm *DataManager) GetDestination(key string, skipCache bool, transactionID string) (dest *Destination, err error) {
|
||||
dest, err = dm.dataDB.GetDestinationDrv(key, skipCache, transactionID)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound && config.CgrConfig().DataDbCfg().Items[utils.MetaDestinations].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDestinations]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetDestination, key, &dest); err == nil {
|
||||
utils.ReplicatorSv1GetDestination, &utils.StringWithApiKey{
|
||||
Arg: key,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &dest); err == nil {
|
||||
err = dm.dataDB.SetDestinationDrv(dest, utils.NonTransactional)
|
||||
}
|
||||
}
|
||||
@@ -380,9 +387,16 @@ func (dm *DataManager) GetReverseDestination(prefix string,
|
||||
skipCache bool, transactionID string) (ids []string, err error) {
|
||||
ids, err = dm.dataDB.GetReverseDestinationDrv(prefix, skipCache, transactionID)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound && config.CgrConfig().DataDbCfg().Items[utils.MetaReverseDestinations].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaReverseDestinations]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetReverseDestination, prefix, &ids); err == nil {
|
||||
utils.ReplicatorSv1GetReverseDestination, &utils.StringWithApiKey{
|
||||
Arg: prefix,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &ids); err == nil {
|
||||
// need to discuss
|
||||
}
|
||||
}
|
||||
@@ -402,10 +416,19 @@ func (dm *DataManager) UpdateReverseDestination(oldDest, newDest *Destination,
|
||||
func (dm *DataManager) GetAccount(id string) (acc *Account, err error) {
|
||||
acc, err = dm.dataDB.GetAccountDrv(id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts]; err == utils.ErrNotFound &&
|
||||
itm.Remote {
|
||||
splt := utils.SplitConcatenatedKey(id)
|
||||
tenant := utils.FirstNonEmpty(splt[0], config.CgrConfig().GeneralCfg().DefaultTenant)
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetAccount, id, &acc); err == nil {
|
||||
utils.ReplicatorSv1GetAccount, &utils.StringWithApiKey{
|
||||
Arg: id,
|
||||
TenantArg: utils.TenantArg{Tenant: tenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &acc); err == nil {
|
||||
err = dm.dataDB.SetAccountDrv(acc)
|
||||
}
|
||||
}
|
||||
@@ -421,10 +444,16 @@ func (dm *DataManager) SetAccount(acc *Account) (err error) {
|
||||
if err = dm.dataDB.SetAccountDrv(acc); err != nil {
|
||||
return
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts].Replicate {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts]; itm.Replicate {
|
||||
var reply string
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1Account, acc, &reply); err != nil {
|
||||
utils.ReplicatorSv1SetAccount,
|
||||
&AccountWithArgDispatcher{
|
||||
Account: acc,
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &reply); err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
return
|
||||
}
|
||||
@@ -459,9 +488,14 @@ func (dm *DataManager) GetStatQueue(tenant, id string,
|
||||
}
|
||||
sq, err = dm.dataDB.GetStatQueueDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound && config.CgrConfig().DataDbCfg().Items[utils.MetaStatQueues].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaStatQueues]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetStatQueue,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, sq); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, sq); err == nil {
|
||||
var ssq *StoredStatQueue
|
||||
if dm.dataDB.GetStorageType() != utils.MetaInternal {
|
||||
// in case of internal we don't marshal
|
||||
@@ -502,10 +536,16 @@ func (dm *DataManager) SetStatQueue(sq *StatQueue) (err error) {
|
||||
if err = dm.dataDB.SetStatQueueDrv(ssq, sq); err != nil {
|
||||
return
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaStatQueues].Replicate {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaStatQueues]; itm.Replicate {
|
||||
var reply string
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1SetStatQueue, ssq, &reply); err != nil {
|
||||
utils.ReplicatorSv1SetStatQueue,
|
||||
&StoredStatQueueWithArgDispatcher{
|
||||
StoredStatQueue: ssq,
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &reply); err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
return
|
||||
}
|
||||
@@ -547,10 +587,14 @@ func GetFilter(dm *DataManager, tenant, id string, cacheRead, cacheWrite bool,
|
||||
fltr, err = dm.DataDB().GetFilterDrv(tenant, id)
|
||||
}
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaFilters].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaFilters]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetFilter,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &fltr); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &fltr); err == nil {
|
||||
err = dm.dataDB.SetFilterDrv(fltr)
|
||||
}
|
||||
}
|
||||
@@ -611,10 +655,14 @@ func (dm *DataManager) GetThreshold(tenant, id string,
|
||||
}
|
||||
th, err = dm.dataDB.GetThresholdDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaThresholds].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaThresholds]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetThreshold, &utils.TenantID{Tenant: tenant, ID: id}, &th); err == nil {
|
||||
utils.ReplicatorSv1GetThreshold, &utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &th); err == nil {
|
||||
err = dm.dataDB.SetThresholdDrv(th)
|
||||
}
|
||||
}
|
||||
@@ -638,10 +686,16 @@ func (dm *DataManager) SetThreshold(th *Threshold) (err error) {
|
||||
if err = dm.DataDB().SetThresholdDrv(th); err != nil {
|
||||
return
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaThresholds].Replicate {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaThresholds]; itm.Replicate {
|
||||
var reply string
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1SetThreshold, th, &reply); err != nil {
|
||||
utils.ReplicatorSv1SetThreshold,
|
||||
&ThresholdWithArgDispatcher{
|
||||
Threshold: th,
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &reply); err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
return
|
||||
}
|
||||
@@ -674,11 +728,15 @@ func (dm *DataManager) GetThresholdProfile(tenant, id string, cacheRead, cacheWr
|
||||
}
|
||||
th, err = dm.dataDB.GetThresholdProfileDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaThresholdProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaThresholdProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetThresholdProfile,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &th); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &th); err == nil {
|
||||
err = dm.dataDB.SetThresholdProfileDrv(th)
|
||||
}
|
||||
}
|
||||
@@ -727,10 +785,16 @@ func (dm *DataManager) SetThresholdProfile(th *ThresholdProfile, withIndex bool)
|
||||
return err
|
||||
}
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaThresholdProfiles].Replicate {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaThresholdProfiles]; itm.Replicate {
|
||||
var reply string
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1SetThresholdProfile, th, &reply); err != nil {
|
||||
utils.ReplicatorSv1SetThresholdProfile,
|
||||
&ThresholdProfileWithArgDispatcher{
|
||||
ThresholdProfile: th,
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID)},
|
||||
}, &reply); err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
return
|
||||
}
|
||||
@@ -777,11 +841,15 @@ func (dm *DataManager) GetStatQueueProfile(tenant, id string, cacheRead, cacheWr
|
||||
}
|
||||
sqp, err = dm.dataDB.GetStatQueueProfileDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaStatQueueProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaStatQueueProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetStatQueueProfile,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &sqp); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &sqp); err == nil {
|
||||
err = dm.dataDB.SetStatQueueProfileDrv(sqp)
|
||||
}
|
||||
}
|
||||
@@ -879,10 +947,16 @@ func (dm *DataManager) GetTiming(id string, skipCache bool,
|
||||
}
|
||||
t, err = dm.dataDB.GetTimingDrv(id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaTimings].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaTimings]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetTiming,
|
||||
id, &t); err == nil {
|
||||
&utils.StringWithApiKey{
|
||||
Arg: id,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &t); err == nil {
|
||||
err = dm.dataDB.SetTimingDrv(t)
|
||||
}
|
||||
}
|
||||
@@ -946,11 +1020,15 @@ func (dm *DataManager) GetResource(tenant, id string, cacheRead, cacheWrite bool
|
||||
}
|
||||
rs, err = dm.dataDB.GetResourceDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaResources].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaResources]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetResource,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &rs); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &rs); err == nil {
|
||||
err = dm.dataDB.SetResourceDrv(rs)
|
||||
}
|
||||
}
|
||||
@@ -1011,10 +1089,14 @@ func (dm *DataManager) GetResourceProfile(tenant, id string, cacheRead, cacheWri
|
||||
}
|
||||
rp, err = dm.dataDB.GetResourceProfileDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaResourceProfile].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaResourceProfile]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetResourceProfile, &utils.TenantID{Tenant: tenant, ID: id}, &rp); err == nil {
|
||||
utils.ReplicatorSv1GetResourceProfile, &utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &rp); err == nil {
|
||||
err = dm.dataDB.SetResourceProfileDrv(rp)
|
||||
}
|
||||
}
|
||||
@@ -1111,10 +1193,16 @@ func (dm *DataManager) GetActionTriggers(id string, skipCache bool,
|
||||
}
|
||||
attrs, err = dm.dataDB.GetActionTriggersDrv(id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaActionTriggers].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaActionTriggers]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetActionTriggers,
|
||||
id, attrs); err == nil {
|
||||
&utils.StringWithApiKey{
|
||||
Arg: id,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, attrs); err == nil {
|
||||
err = dm.dataDB.SetActionTriggersDrv(id, attrs)
|
||||
}
|
||||
}
|
||||
@@ -1183,10 +1271,16 @@ func (dm *DataManager) GetSharedGroup(key string, skipCache bool,
|
||||
}
|
||||
sg, err = dm.DataDB().GetSharedGroupDrv(key)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaSharedGroups].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaSharedGroups]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetShareGroup, key, &sg); err == nil {
|
||||
utils.ReplicatorSv1GetShareGroup, &utils.StringWithApiKey{
|
||||
Arg: key,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &sg); err == nil {
|
||||
err = dm.dataDB.SetSharedGroupDrv(sg)
|
||||
}
|
||||
}
|
||||
@@ -1252,10 +1346,16 @@ func (dm *DataManager) GetActions(key string, skipCache bool, transactionID stri
|
||||
}
|
||||
as, err = dm.DataDB().GetActionsDrv(key)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaActions].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaActions]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetActions, key, &as); err == nil {
|
||||
utils.ReplicatorSv1GetActions, &utils.StringWithApiKey{
|
||||
Arg: key,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &as); err == nil {
|
||||
err = dm.dataDB.SetActionsDrv(key, as)
|
||||
}
|
||||
}
|
||||
@@ -1313,10 +1413,16 @@ func (dm *DataManager) RemoveActions(key, transactionID string) (err error) {
|
||||
|
||||
func (dm *DataManager) GetActionPlan(key string, skipCache bool, transactionID string) (ats *ActionPlan, err error) {
|
||||
ats, err = dm.dataDB.GetActionPlanDrv(key, skipCache, transactionID)
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaActionPlans].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaActionPlans]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetActionPlan, key, &ats); err == nil {
|
||||
utils.ReplicatorSv1GetActionPlan, &utils.StringWithApiKey{
|
||||
Arg: key,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &ats); err == nil {
|
||||
err = dm.dataDB.SetActionPlanDrv(key, ats, true, utils.NonTransactional)
|
||||
}
|
||||
}
|
||||
@@ -1355,11 +1461,17 @@ func (dm *DataManager) SetActionPlan(key string, ats *ActionPlan,
|
||||
|
||||
func (dm *DataManager) GetAllActionPlans() (ats map[string]*ActionPlan, err error) {
|
||||
ats, err = dm.dataDB.GetAllActionPlansDrv()
|
||||
if ((err == nil && len(ats) == 0) || err == utils.ErrNotFound) &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaActionPlans].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaActionPlans]; ((err == nil && len(ats) == 0) || err == utils.ErrNotFound) && itm.Remote {
|
||||
err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetAllActionPlans,
|
||||
utils.EmptyString, &ats)
|
||||
&utils.StringWithApiKey{
|
||||
Arg: utils.EmptyString,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &ats)
|
||||
}
|
||||
if err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
@@ -1382,10 +1494,17 @@ func (dm *DataManager) RemoveActionPlan(key string, transactionID string) (err e
|
||||
func (dm *DataManager) GetAccountActionPlans(acntID string,
|
||||
skipCache bool, transactionID string) (apIDs []string, err error) {
|
||||
apIDs, err = dm.dataDB.GetAccountActionPlansDrv(acntID, skipCache, transactionID)
|
||||
if ((err == nil && len(apIDs) == 0) || err == utils.ErrNotFound) &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaAccountActionPlans].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccountActionPlans]; ((err == nil && len(apIDs) == 0) || err == utils.ErrNotFound) && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetAccountActionPlans, acntID, &apIDs); err == nil {
|
||||
utils.ReplicatorSv1GetAccountActionPlans,
|
||||
&utils.StringWithApiKey{
|
||||
Arg: acntID,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &apIDs); err == nil {
|
||||
err = dm.dataDB.SetAccountActionPlansDrv(acntID, apIDs, true)
|
||||
}
|
||||
}
|
||||
@@ -1450,11 +1569,17 @@ func (dm *DataManager) GetRatingPlan(key string, skipCache bool,
|
||||
}
|
||||
rp, err = dm.DataDB().GetRatingPlanDrv(key)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaRatingPlans].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaRatingPlans]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetRatingPlan,
|
||||
key, &rp); err == nil {
|
||||
&utils.StringWithApiKey{
|
||||
Arg: key,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &rp); err == nil {
|
||||
err = dm.dataDB.SetRatingPlanDrv(rp)
|
||||
}
|
||||
}
|
||||
@@ -1519,11 +1644,17 @@ func (dm *DataManager) GetRatingProfile(key string, skipCache bool,
|
||||
}
|
||||
rpf, err = dm.DataDB().GetRatingProfileDrv(key)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaRatingProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaRatingProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetRatingProfile,
|
||||
key, &rpf); err == nil {
|
||||
&utils.StringWithApiKey{
|
||||
Arg: key,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &rpf); err == nil {
|
||||
err = dm.dataDB.SetRatingProfileDrv(rpf)
|
||||
}
|
||||
}
|
||||
@@ -1582,15 +1713,19 @@ func (dm *DataManager) HasData(category, subject, tenant string) (has bool, err
|
||||
func (dm *DataManager) GetFilterIndexes(cacheID, itemIDPrefix, filterType string,
|
||||
fldNameVal map[string]string) (indexes map[string]utils.StringMap, err error) {
|
||||
if indexes, err = dm.DataDB().GetFilterIndexesDrv(cacheID, itemIDPrefix, filterType, fldNameVal); err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetFilterIndexes,
|
||||
&utils.GetFilterIndexesArg{
|
||||
CacheID: cacheID,
|
||||
ItemIDPrefix: itemIDPrefix,
|
||||
FilterType: filterType,
|
||||
FldNameVal: fldNameVal,
|
||||
&utils.GetFilterIndexesArgWithArgDispatcher{
|
||||
GetFilterIndexesArg: &utils.GetFilterIndexesArg{
|
||||
CacheID: cacheID,
|
||||
ItemIDPrefix: itemIDPrefix,
|
||||
FilterType: filterType,
|
||||
FldNameVal: fldNameVal},
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID)},
|
||||
}, &indexes); err == nil {
|
||||
err = dm.dataDB.SetFilterIndexesDrv(cacheID, itemIDPrefix, indexes, true, utils.NonTransactional)
|
||||
}
|
||||
@@ -1609,14 +1744,19 @@ func (dm *DataManager) SetFilterIndexes(cacheID, itemIDPrefix string,
|
||||
indexes, commit, transactionID); err != nil {
|
||||
return
|
||||
}
|
||||
if config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes].Replicate {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes]; itm.Replicate {
|
||||
var reply string
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
utils.ReplicatorSv1SetFilterIndexes,
|
||||
&utils.SetFilterIndexesArg{
|
||||
CacheID: cacheID,
|
||||
ItemIDPrefix: itemIDPrefix,
|
||||
Indexes: indexes,
|
||||
&utils.SetFilterIndexesArgWithArgDispatcher{
|
||||
SetFilterIndexesArg: &utils.SetFilterIndexesArg{
|
||||
CacheID: cacheID,
|
||||
ItemIDPrefix: itemIDPrefix,
|
||||
Indexes: indexes},
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID)},
|
||||
}, &reply); err != nil {
|
||||
err = utils.CastRPCErr(err)
|
||||
return
|
||||
@@ -1658,16 +1798,21 @@ func (dm *DataManager) MatchFilterIndex(cacheID, itemIDPrefix,
|
||||
// Not found in cache, check in DB
|
||||
itemIDs, err = dm.DataDB().MatchFilterIndexDrv(cacheID, itemIDPrefix, filterType, fieldName, fieldVal)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes]; err == utils.ErrNotFound && itm.Remote {
|
||||
err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1MatchFilterIndex,
|
||||
&utils.MatchFilterIndexArg{
|
||||
&utils.MatchFilterIndexArgWithArgDispatcher{MatchFilterIndexArg: &utils.MatchFilterIndexArg{
|
||||
CacheID: cacheID,
|
||||
ItemIDPrefix: itemIDPrefix,
|
||||
FilterType: filterType,
|
||||
FieldName: fieldName,
|
||||
FieldVal: fieldVal,
|
||||
},
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &itemIDs)
|
||||
}
|
||||
if err != nil {
|
||||
@@ -1698,10 +1843,14 @@ func (dm *DataManager) GetSupplierProfile(tenant, id string, cacheRead, cacheWri
|
||||
}
|
||||
supp, err = dm.dataDB.GetSupplierProfileDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaSupplierProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaSupplierProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetSupplierProfile,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &supp); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &supp); err == nil {
|
||||
err = dm.dataDB.SetSupplierProfileDrv(supp)
|
||||
}
|
||||
}
|
||||
@@ -1819,11 +1968,15 @@ func (dm *DataManager) GetAttributeProfile(tenant, id string, cacheRead, cacheWr
|
||||
attrPrfl, err = dm.dataDB.GetAttributeProfileDrv(tenant, id)
|
||||
}
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaAttributeProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAttributeProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetAttributeProfile,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &attrPrfl); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &attrPrfl); err == nil {
|
||||
err = dm.dataDB.SetAttributeProfileDrv(attrPrfl)
|
||||
}
|
||||
}
|
||||
@@ -1934,11 +2087,15 @@ func (dm *DataManager) GetChargerProfile(tenant, id string, cacheRead, cacheWrit
|
||||
}
|
||||
cpp, err = dm.dataDB.GetChargerProfileDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaChargerProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaChargerProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetChargerProfile,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &cpp); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &cpp); err == nil {
|
||||
err = dm.dataDB.SetChargerProfileDrv(cpp)
|
||||
}
|
||||
}
|
||||
@@ -2037,11 +2194,15 @@ func (dm *DataManager) GetDispatcherProfile(tenant, id string, cacheRead, cacheW
|
||||
}
|
||||
dpp, err = dm.dataDB.GetDispatcherProfileDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetDispatcherProfile,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &dpp); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &dpp); err == nil {
|
||||
err = dm.dataDB.SetDispatcherProfileDrv(dpp)
|
||||
}
|
||||
}
|
||||
@@ -2149,11 +2310,15 @@ func (dm *DataManager) GetDispatcherHost(tenant, id string, cacheRead, cacheWrit
|
||||
}
|
||||
dH, err = dm.dataDB.GetDispatcherHostDrv(tenant, id)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherHosts].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherHosts]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetDispatcherHost,
|
||||
&utils.TenantID{Tenant: tenant, ID: id}, &dH); err == nil {
|
||||
&utils.TenantIDWithArgDispatcher{
|
||||
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
}}, &dH); err == nil {
|
||||
err = dm.dataDB.SetDispatcherHostDrv(dH)
|
||||
}
|
||||
}
|
||||
@@ -2222,11 +2387,17 @@ func (dm *DataManager) RemoveDispatcherHost(tenant, id string,
|
||||
func (dm *DataManager) GetItemLoadIDs(itemIDPrefix string, cacheWrite bool) (loadIDs map[string]int64, err error) {
|
||||
loadIDs, err = dm.DataDB().GetItemLoadIDsDrv(itemIDPrefix)
|
||||
if err != nil {
|
||||
if err == utils.ErrNotFound &&
|
||||
config.CgrConfig().DataDbCfg().Items[utils.MetaLoadIDs].Remote {
|
||||
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaLoadIDs]; err == utils.ErrNotFound && itm.Remote {
|
||||
if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil,
|
||||
utils.ReplicatorSv1GetItemLoadIDs,
|
||||
itemIDPrefix, &loadIDs); err == nil {
|
||||
&utils.StringWithApiKey{
|
||||
Arg: itemIDPrefix,
|
||||
TenantArg: utils.TenantArg{Tenant: config.CgrConfig().GeneralCfg().DefaultTenant},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer(itm.APIKey),
|
||||
RouteID: utils.StringPointer(itm.RouteID),
|
||||
},
|
||||
}, &loadIDs); err == nil {
|
||||
err = dm.dataDB.SetLoadIDsDrv(loadIDs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@ type Destination struct {
|
||||
Prefixes []string
|
||||
}
|
||||
|
||||
type DestinationWithArgDispatcher struct {
|
||||
*Destination
|
||||
utils.TenantArg
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
// returns prefix precision
|
||||
func (d *Destination) containsPrefix(prefix string) int {
|
||||
if d == nil {
|
||||
|
||||
@@ -110,6 +110,11 @@ type Filter struct {
|
||||
ActivationInterval *utils.ActivationInterval
|
||||
}
|
||||
|
||||
type FilterWithArgDispatcher struct {
|
||||
*Filter
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
// TenantID returns the tenant wit the ID
|
||||
func (fltr *Filter) TenantID() string {
|
||||
return utils.ConcatenatedKey(fltr.Tenant, fltr.ID)
|
||||
|
||||
@@ -86,6 +86,11 @@ type StoredStatQueue struct {
|
||||
Compressed bool
|
||||
}
|
||||
|
||||
type StoredStatQueueWithArgDispatcher struct {
|
||||
*StoredStatQueue
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
// SqID will compose the unique identifier for the StatQueue out of Tenant and ID
|
||||
func (ssq *StoredStatQueue) SqID() string {
|
||||
return utils.ConcatenatedKey(ssq.Tenant, ssq.ID)
|
||||
|
||||
@@ -34,6 +34,12 @@ type ThresholdWithCache struct {
|
||||
Cache *string
|
||||
}
|
||||
|
||||
// ThresholdProfileWithArgDispatcher is used in replicatorV1 for dispatcher
|
||||
type ThresholdProfileWithArgDispatcher struct {
|
||||
*ThresholdProfile
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
type ThresholdProfile struct {
|
||||
Tenant string
|
||||
ID string
|
||||
@@ -52,6 +58,12 @@ func (tp *ThresholdProfile) TenantID() string {
|
||||
return utils.ConcatenatedKey(tp.Tenant, tp.ID)
|
||||
}
|
||||
|
||||
// ThresholdWithArgDispatcher is used in replicatorV1 for dispatcher
|
||||
type ThresholdWithArgDispatcher struct {
|
||||
*Threshold
|
||||
*utils.ArgDispatcher
|
||||
}
|
||||
|
||||
// Threshold is the unit matched by filters
|
||||
type Threshold struct {
|
||||
Tenant string
|
||||
|
||||
@@ -925,7 +925,7 @@ const (
|
||||
ReplicatorSv1SetThresholdProfile = "ReplicatorSv1.SetThresholdProfile"
|
||||
ReplicatorSv1SetThreshold = "ReplicatorSv1.SetThreshold"
|
||||
ReplicatorSv1SetFilterIndexes = "ReplicatorSv1.SetFilterIndexes"
|
||||
ReplicatorSv1Account = "ReplicatorSv1.SetAccount"
|
||||
ReplicatorSv1SetAccount = "ReplicatorSv1.SetAccount"
|
||||
ReplicatorSv1SetDestination = "ReplicatorSv1.SetDestination"
|
||||
ReplicatorSv1SetReverseDestination = "ReplicatorSv1.SetReverseDestination"
|
||||
ReplicatorSv1SetStatQueue = "ReplicatorSv1.SetStatQueue"
|
||||
|
||||
@@ -918,3 +918,21 @@ type GetFilterIndexesArgWithArgDispatcher struct {
|
||||
TenantArg
|
||||
*ArgDispatcher
|
||||
}
|
||||
|
||||
type MatchFilterIndexArgWithArgDispatcher struct {
|
||||
*MatchFilterIndexArg
|
||||
TenantArg
|
||||
*ArgDispatcher
|
||||
}
|
||||
|
||||
type StringWithApiKey struct {
|
||||
*ArgDispatcher
|
||||
TenantArg
|
||||
Arg string
|
||||
}
|
||||
|
||||
type SetFilterIndexesArgWithArgDispatcher struct {
|
||||
*SetFilterIndexesArg
|
||||
TenantArg
|
||||
*ArgDispatcher
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user