mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated ActionPlanIndexes Redis set name
This commit is contained in:
committed by
Dan Christian Bogos
parent
9ad83fb6e9
commit
2fd862ee0e
@@ -1158,7 +1158,7 @@ func TestApierSetAccount(t *testing.T) {
|
||||
func TestApierGetAccountActionPlan(t *testing.T) {
|
||||
var reply []*AccountActionTiming
|
||||
req := utils.TenantAccount{Tenant: "cgrates.org", Account: "dan7"}
|
||||
if err := rater.Call("ApierV1.GetAccountActionPlan", req, &reply); err != nil {
|
||||
if err := rater.Call(utils.ApierV1GetAccountActionPlan, req, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.GetAccountActionPlan: ", err.Error())
|
||||
} else if len(reply) != 1 {
|
||||
t.Error("Unexpected action plan received: ", utils.ToJSON(reply))
|
||||
@@ -1193,7 +1193,7 @@ func TestApierRemUniqueIDActionTiming(t *testing.T) {
|
||||
}
|
||||
var reply []*AccountActionTiming
|
||||
req := utils.TenantAccount{Tenant: "cgrates.org", Account: "dan4"}
|
||||
if err := rater.Call("ApierV1.GetAccountActionPlan", req, &reply); err != nil {
|
||||
if err := rater.Call(utils.ApierV1GetAccountActionPlan, req, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.GetAccountActionPlan: ", err.Error())
|
||||
} else if len(reply) != 0 {
|
||||
t.Error("Action timings was not removed")
|
||||
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -47,7 +49,7 @@ func main() {
|
||||
}
|
||||
wg.Wait()
|
||||
for index := 1; index < 1002; index++ {
|
||||
resp, err := http.Post("http://localhost:2080/jsonrpc", "application/json", bytes.NewBuffer([]byte(fmt.Sprintf(`{"method": "ApierV1.GetAccountActionPlan","params": [{"Tenant":"reglo","Account":"100%d"}], "id":%d}`, index, index))))
|
||||
resp, err := http.Post("http://localhost:2080/jsonrpc", "application/json", bytes.NewBuffer([]byte(fmt.Sprintf(`{"method": "%s","params": [{"Tenant":"reglo","Account":"100%d"}], "id":%d}`, utils.ApierV1GetAccountActionPlan, index, index))))
|
||||
if err != nil {
|
||||
log.Print("Post error: ", err)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
func init() {
|
||||
c := &CmdGetAccountActionPlan{
|
||||
name: "account_actionplan_get",
|
||||
rpcMethod: "ApierV1.GetAccountActionPlan",
|
||||
rpcMethod: utils.ApierV1GetAccountActionPlan,
|
||||
rpcParams: &utils.TenantAccount{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -345,7 +345,7 @@ func (rs *RedisStorage) getKeysForFilterIndexesKeys(fkeys []string) (keys []stri
|
||||
func (rs *RedisStorage) GetKeysForPrefix(prefix string) ([]string, error) {
|
||||
var r *redis.Resp
|
||||
if prefix == utils.ACTION_PLAN_PREFIX { //so we can avoid the full scan on scheduler reloads
|
||||
r = rs.Cmd("SMEMBERS", "indx"+utils.ACTION_PLAN_PREFIX)
|
||||
r = rs.Cmd("SMEMBERS", utils.ActionPlanIndexes)
|
||||
} else {
|
||||
r = rs.Cmd("KEYS", prefix+"*")
|
||||
}
|
||||
@@ -891,7 +891,7 @@ func (rs *RedisStorage) GetActionPlan(key string, skipCache bool,
|
||||
func (rs *RedisStorage) RemoveActionPlan(key string,
|
||||
transactionID string) error {
|
||||
cCommit := cacheCommit(transactionID)
|
||||
rs.Cmd("SREM", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
rs.Cmd("SREM", utils.ActionPlanIndexes, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
err := rs.Cmd("DEL", utils.ACTION_PLAN_PREFIX+key).Err
|
||||
Cache.Remove(utils.CacheActionPlans, key,
|
||||
cCommit, transactionID)
|
||||
@@ -903,7 +903,7 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan,
|
||||
cCommit := cacheCommit(transactionID)
|
||||
if len(ats.ActionTimings) == 0 {
|
||||
// delete the key
|
||||
rs.Cmd("SREM", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
rs.Cmd("SREM", utils.ActionPlanIndexes, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
err = rs.Cmd("DEL", utils.ACTION_PLAN_PREFIX+key).Err
|
||||
Cache.Remove(utils.CacheActionPlans, key,
|
||||
cCommit, transactionID)
|
||||
@@ -928,7 +928,7 @@ func (rs *RedisStorage) SetActionPlan(key string, ats *ActionPlan,
|
||||
w := zlib.NewWriter(&b)
|
||||
w.Write(result)
|
||||
w.Close()
|
||||
rs.Cmd("SADD", "indx"+utils.ACTION_PLAN_PREFIX, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
rs.Cmd("SADD", utils.ActionPlanIndexes, utils.ACTION_PLAN_PREFIX+key) // should handle the error here?
|
||||
return rs.Cmd("SET", utils.ACTION_PLAN_PREFIX+key, b.Bytes()).Err
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ func TestA1itConcurrentAPs(t *testing.T) {
|
||||
wg.Add(3)
|
||||
go func(acnt string) {
|
||||
var atms []*v1.AccountActionTiming
|
||||
if err := a1rpc.Call("ApierV1.GetAccountActionPlan",
|
||||
if err := a1rpc.Call(utils.ApierV1GetAccountActionPlan,
|
||||
utils.TenantAccount{Tenant: "cgrates.org", Account: acnt}, &atms); err != nil {
|
||||
t.Error(err)
|
||||
//} else if len(atms) != 2 || atms[0].ActionPlanId != "PACKAGE_1" {
|
||||
|
||||
@@ -460,8 +460,8 @@ const (
|
||||
MetaStorDB = "*stordb"
|
||||
MetaDataDB = "*datadb"
|
||||
MetaWeight = "*weight"
|
||||
MetaLC = "*lc"
|
||||
MetaHC = "*hc"
|
||||
MetaLC = "*lc"
|
||||
MetaHC = "*hc"
|
||||
MetaQOS = "*qos"
|
||||
MetaReas = "*reas"
|
||||
MetaReds = "*reds"
|
||||
@@ -805,6 +805,7 @@ const (
|
||||
ApierV1GetRatingProfileIDs = "ApierV1.GetRatingProfileIDs"
|
||||
ApierV1SetDataDBVersions = "ApierV1.SetDataDBVersions"
|
||||
ApierV1SetStorDBVersions = "ApierV1.SetStorDBVersions"
|
||||
ApierV1GetAccountActionPlan = "ApierV1.GetAccountActionPlan"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -1149,6 +1150,7 @@ const (
|
||||
AttributeFilterIndexes = "afi_"
|
||||
ChargerFilterIndexes = "cfi_"
|
||||
DispatcherFilterIndexes = "dfi_"
|
||||
ActionPlanIndexes = "api_"
|
||||
)
|
||||
|
||||
// Agents
|
||||
|
||||
Reference in New Issue
Block a user