mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added SetIndexes
This commit is contained in:
committed by
Dan Christian Bogos
parent
2f0f3f6bd5
commit
760b242bd2
@@ -3281,7 +3281,8 @@ func (dm *DataManager) Reconnect(marshaller string, newcfg *config.DataDbCfg) (e
|
||||
return
|
||||
}
|
||||
|
||||
func (dm *DataManager) GetIndexes(idxItmType, tntCtx, idxKey string, cahceRead, cacheWrite bool) (indexes map[string]utils.StringSet, err error) {
|
||||
func (dm *DataManager) GetIndexes(idxItmType, tntCtx, idxKey string,
|
||||
cahceRead, cacheWrite bool) (indexes map[string]utils.StringSet, err error) {
|
||||
if dm == nil {
|
||||
err = utils.ErrNoDatabaseConn
|
||||
return
|
||||
@@ -3341,39 +3342,36 @@ func (dm *DataManager) GetIndexes(idxItmType, tntCtx, idxKey string, cahceRead,
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
func (dm *DataManager) SetFilterIndexes(cacheID, itemIDPrefix string,
|
||||
indexes map[string]utils.StringMap, commit bool, transactionID string) (err error) {
|
||||
func (dm *DataManager) SetIndexes(idxItmType, tntCtx string,
|
||||
indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
|
||||
if dm == nil {
|
||||
err = utils.ErrNoDatabaseConn
|
||||
return
|
||||
}
|
||||
if err = dm.DataDB().SetFilterIndexesDrv(cacheID, itemIDPrefix,
|
||||
if err = dm.DataDB().SetIndexesDrv(idxItmType, tntCtx,
|
||||
indexes, commit, transactionID); err != nil {
|
||||
return
|
||||
}
|
||||
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.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
|
||||
}
|
||||
}
|
||||
// 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.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
|
||||
// }
|
||||
// }
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
func (dm *DataManager) RemoveIndexes(idxItmType, tntCtx, idxKey string) (err error) {
|
||||
if dm == nil {
|
||||
@@ -3381,4 +3379,20 @@ func (dm *DataManager) RemoveIndexes(idxItmType, tntCtx, idxKey string) (err err
|
||||
return
|
||||
}
|
||||
return dm.DataDB().RemoveIndexesDrv(idxItmType, tntCtx, idxKey)
|
||||
// if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaFilterIndexes]; itm.Replicate {
|
||||
// var reply string
|
||||
// dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil,
|
||||
// utils.ReplicatorSv1RemoveFilterIndexes,
|
||||
// &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)
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -2485,7 +2485,6 @@ func (ms *MongoStorage) SetIndexesDrv(idxItmType, tntCtx string,
|
||||
}
|
||||
|
||||
// RemoveIndexesDrv removes the indexes
|
||||
// the key is the tenant of the item or in case of context dependent profiles is a concatenatedKey between tenant and context
|
||||
func (ms *MongoStorage) RemoveIndexesDrv(idxItmType, tntCtx, idxKey string) (err error) {
|
||||
if len(idxKey) != 0 {
|
||||
return ms.query(func(sctx mongo.SessionContext) (err error) {
|
||||
|
||||
Reference in New Issue
Block a user