本文整理匯總了Golang中github.com/cgrates/cgrates/utils.ConcatenatedKey函數的典型用法代碼示例。如果您正苦於以下問題:Golang ConcatenatedKey函數的具體用法?Golang ConcatenatedKey怎麽用?Golang ConcatenatedKey使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ConcatenatedKey函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deleteIndex
func (um *UserMap) deleteIndex(up *UserProfile) {
key := up.GetId()
for _, index := range um.indexKeys {
if index == "Tenant" {
if up.Tenant != "" {
indexKey := utils.ConcatenatedKey(index, up.Tenant)
delete(um.index[indexKey], key)
if len(um.index[indexKey]) == 0 {
delete(um.index, indexKey)
}
}
continue
}
if index == "UserName" {
if up.UserName != "" {
indexKey := utils.ConcatenatedKey(index, up.UserName)
delete(um.index[indexKey], key)
if len(um.index[indexKey]) == 0 {
delete(um.index, indexKey)
}
}
continue
}
for k, v := range up.Profile {
if k == index && v != "" {
indexKey := utils.ConcatenatedKey(k, v)
delete(um.index[indexKey], key)
if len(um.index[indexKey]) == 0 {
delete(um.index, indexKey)
}
}
}
}
}
示例2: addIndex
func (um *UserMap) addIndex(up *UserProfile, indexes []string) {
key := up.GetId()
for _, index := range indexes {
if index == "Tenant" {
if up.Tenant != "" {
indexKey := utils.ConcatenatedKey(index, up.Tenant)
if um.index[indexKey] == nil {
um.index[indexKey] = make(map[string]bool)
}
um.index[indexKey][key] = true
}
continue
}
if index == "UserName" {
if up.UserName != "" {
indexKey := utils.ConcatenatedKey(index, up.UserName)
if um.index[indexKey] == nil {
um.index[indexKey] = make(map[string]bool)
}
um.index[indexKey][key] = true
}
continue
}
for k, v := range up.Profile {
if k == index && v != "" {
indexKey := utils.ConcatenatedKey(k, v)
if um.index[indexKey] == nil {
um.index[indexKey] = make(map[string]bool)
}
um.index[indexKey][key] = true
}
}
}
}
示例3: GetAccountKey
// GetAccountKey returns the key used to retrive the user balance involved in this call
func (cd *CallDescriptor) GetAccountKey() string {
subj := cd.Subject
if cd.Account != "" {
// check if subject is alias
if aliasService != nil {
var alias string
err := aliasService.GetMatchingAlias(
AttrMatchingAlias{
Destination: cd.Destination,
Direction: cd.Direction,
Tenant: cd.Tenant,
Category: cd.Category,
Account: cd.Account,
Subject: cd.Subject,
Context: utils.ALIAS_GROUP_ACC,
Target: "Account",
Original: cd.Account,
}, &alias)
if err == nil && alias != "" {
cd.Account = alias
}
}
subj = cd.Account
}
return utils.ConcatenatedKey(cd.Direction, cd.Tenant, subj)
}
示例4: RemoveAlias
func (ms *MapStorage) RemoveAlias(key string, transactionID string) error {
// get alias for values list
al, err := ms.GetAlias(key, false, transactionID)
if err != nil {
return err
}
ms.mu.Lock()
defer ms.mu.Unlock()
key = utils.ALIASES_PREFIX + key
aliasValues := make(AliasValues, 0)
if values, ok := ms.dict[key]; ok {
ms.ms.Unmarshal(values, &aliasValues)
}
delete(ms.dict, key)
cCommit := cacheCommit(transactionID)
cache.RemKey(key, cCommit, transactionID)
for _, value := range al.Values {
tmpKey := utils.ConcatenatedKey(al.GetId(), value.DestinationId)
for target, pairs := range value.Pairs {
for _, alias := range pairs {
rKey := utils.REVERSE_ALIASES_PREFIX + alias + target + al.Context
ms.dict.srem(rKey, tmpKey, ms.ms)
cache.RemKey(rKey, cCommit, transactionID)
/*_, err = ms.GetReverseAlias(rKey, true) // recache
if err != nil {
return err
}*/
}
}
}
return nil
}
示例5: TestRDSitSetGetDerivedCharges
func TestRDSitSetGetDerivedCharges(t *testing.T) {
if !*testIntegration {
return
}
keyCharger1 := utils.ConcatenatedKey("*out", "cgrates.org", "call", "dan", "dan")
charger1 := &utils.DerivedChargers{Chargers: []*utils.DerivedCharger{
&utils.DerivedCharger{RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
&utils.DerivedCharger{RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
}}
if err := rds.SetDerivedChargers(keyCharger1, charger1, utils.NonTransactional); err != nil {
t.Error("Error on setting DerivedChargers", err.Error())
}
// Retrieve from db
if rcvCharger, err := rds.GetDerivedChargers(keyCharger1, true, utils.NonTransactional); err != nil {
t.Error("Error when retrieving DerivedCHarger", err.Error())
} else if !reflect.DeepEqual(rcvCharger, charger1) {
t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
}
// Retrieve from cache
if rcvCharger, err := rds.GetDerivedChargers(keyCharger1, false, utils.NonTransactional); err != nil {
t.Error("Error when retrieving DerivedCHarger", err.Error())
} else if !reflect.DeepEqual(rcvCharger, charger1) {
t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
}
}
示例6: testOnStorITCacheDerivedChargers
func testOnStorITCacheDerivedChargers(t *testing.T) {
dcs := &utils.DerivedChargers{
DestinationIDs: make(utils.StringMap),
Chargers: []*utils.DerivedCharger{
&utils.DerivedCharger{RunID: "extra1", RunFilters: "^filteredHeader1/filterValue1/", RequestTypeField: "^prepaid", DirectionField: utils.META_DEFAULT,
TenantField: utils.META_DEFAULT, CategoryField: utils.META_DEFAULT, AccountField: "rif", SubjectField: "rif", DestinationField: utils.META_DEFAULT,
SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT, AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT, CostField: utils.META_DEFAULT, RatedField: utils.META_DEFAULT},
&utils.DerivedCharger{RunID: "extra2", RequestTypeField: utils.META_DEFAULT, DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
CategoryField: utils.META_DEFAULT, AccountField: "ivo", SubjectField: "ivo", DestinationField: utils.META_DEFAULT,
SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT, AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT, CostField: utils.META_DEFAULT, RatedField: utils.META_DEFAULT},
}}
keyDCS := utils.ConcatenatedKey("*out", "itsyscom.com", "call", "dan", "dan")
if err := onStor.SetDerivedChargers(keyDCS, dcs, utils.NonTransactional); err != nil {
t.Error(err)
}
if _, hasIt := cache.Get(utils.DERIVEDCHARGERS_PREFIX + keyDCS); hasIt {
t.Error("Already in cache")
}
if err := onStor.CacheDataFromDB(utils.DERIVEDCHARGERS_PREFIX, []string{keyDCS}, false); err != nil {
t.Error(err)
}
if itm, hasIt := cache.Get(utils.DERIVEDCHARGERS_PREFIX + keyDCS); !hasIt {
t.Error("Did not cache")
} else if rcv := itm.(*utils.DerivedChargers); !reflect.DeepEqual(dcs, rcv) {
t.Errorf("Expecting: %+v, received: %+v", dcs, rcv)
}
}
示例7: testOnStorITSetGetDerivedCharges
func testOnStorITSetGetDerivedCharges(t *testing.T) {
keyCharger1 := utils.ConcatenatedKey("*out", "cgrates.org", "call", "dan", "dan")
if _, err := onStor.GetDerivedChargers(keyCharger1, true, utils.NonTransactional); err == nil {
t.Error("DC exists")
}
charger1 := &utils.DerivedChargers{DestinationIDs: make(utils.StringMap),
Chargers: []*utils.DerivedCharger{
&utils.DerivedCharger{RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
&utils.DerivedCharger{RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
}}
if err := onStor.SetDerivedChargers(keyCharger1, charger1, utils.NonTransactional); err != nil {
t.Error("Error on setting DerivedChargers", err.Error())
}
// Retrieve from db
if rcvCharger, err := onStor.GetDerivedChargers(keyCharger1, true, utils.NonTransactional); err != nil {
t.Error("Error when retrieving DerivedCHarger", err.Error())
} else if !reflect.DeepEqual(rcvCharger, charger1) {
for i, eChrg := range charger1.Chargers {
if !reflect.DeepEqual(eChrg, rcvCharger.Chargers[i]) {
t.Logf("Expecting: %+v, received: %+v", eChrg, rcvCharger.Chargers[i])
}
}
t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
}
// Retrieve from cache
if rcvCharger, err := onStor.GetDerivedChargers(keyCharger1, false, utils.NonTransactional); err != nil {
t.Error("Error when retrieving DerivedCHarger", err.Error())
} else if !reflect.DeepEqual(rcvCharger, charger1) {
t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
}
}
示例8: testOnStorITMatchReqFilterIndex
func testOnStorITMatchReqFilterIndex(t *testing.T) {
eMp := utils.StringMap{
"RL1": true,
"RL2": true,
}
if rcvMp, err := onStor.MatchReqFilterIndex(utils.ResourceLimitsIndex,
utils.ConcatenatedKey("Account", "1002")); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eMp, rcvMp) {
t.Errorf("Expecting: %+v, received: %+v", eMp, rcvMp)
}
if _, err := onStor.MatchReqFilterIndex(utils.ResourceLimitsIndex,
utils.ConcatenatedKey("NonexistentField", "1002")); err == nil || err != utils.ErrNotFound {
t.Error(err)
}
}
示例9: RemoveAlias
func (rs *RedisStorage) RemoveAlias(id string, transactionID string) (err error) {
key := utils.ALIASES_PREFIX + id
// get alias for values list
al, err := rs.GetAlias(id, false, transactionID)
if err != nil {
return
}
err = rs.db.Cmd("DEL", key).Err
if err != nil {
return err
}
cCommit := cacheCommit(transactionID)
cache2go.RemKey(key, cCommit, transactionID)
for _, value := range al.Values {
tmpKey := utils.ConcatenatedKey(al.GetId(), value.DestinationId)
for target, pairs := range value.Pairs {
for _, alias := range pairs {
rKey := utils.REVERSE_ALIASES_PREFIX + alias + target + al.Context
err = rs.db.Cmd("SREM", rKey, tmpKey).Err
if err != nil {
return err
}
cache2go.RemKey(rKey, cCommit, transactionID)
/*_, err = rs.GetReverseAlias(rKey, true) // recache
if err != nil {
return err
}*/
}
}
}
return
}
示例10: IndexFilters
// IndexFilters parses reqFltrs, adding itemID in the indexes and marks the changed keys in chngdIndxKeys
func (rfi *ReqFilterIndexer) IndexFilters(itemID string, reqFltrs []*RequestFilter) {
var hasMetaString bool
for _, fltr := range reqFltrs {
if fltr.Type != MetaString {
continue
}
hasMetaString = true // Mark that we found at least one metatring so we don't index globally
if _, hastIt := rfi.indexes[fltr.FieldName]; !hastIt {
rfi.indexes[fltr.FieldName] = make(map[string]utils.StringMap)
}
for _, fldVal := range fltr.Values {
if _, hasIt := rfi.indexes[fltr.FieldName][fldVal]; !hasIt {
rfi.indexes[fltr.FieldName][fldVal] = make(utils.StringMap)
}
rfi.indexes[fltr.FieldName][fldVal][itemID] = true
rfi.chngdIndxKeys[utils.ConcatenatedKey(fltr.FieldName, fldVal)] = true
}
}
if !hasMetaString {
if _, hasIt := rfi.indexes[utils.NOT_AVAILABLE]; !hasIt {
rfi.indexes[utils.NOT_AVAILABLE] = make(map[string]utils.StringMap)
}
if _, hasIt := rfi.indexes[utils.NOT_AVAILABLE][utils.NOT_AVAILABLE]; !hasIt {
rfi.indexes[utils.NOT_AVAILABLE][utils.NOT_AVAILABLE] = make(utils.StringMap)
}
rfi.indexes[utils.NOT_AVAILABLE][utils.NOT_AVAILABLE][itemID] = true // Fields without real field index will be located in map[NOT_AVAILABLE][NOT_AVAILABLE][rl.ID]
}
return
}
示例11: GetAccountKey
// GetAccountKey returns the key used to retrive the user balance involved in this call
func (cd *CallDescriptor) GetAccountKey() string {
subj := cd.Subject
if cd.Account != "" {
subj = cd.Account
}
return utils.ConcatenatedKey(cd.Tenant, subj)
}
示例12: TestSetGetDerivedCharges
func TestSetGetDerivedCharges(t *testing.T) {
if !*testLocal {
return
}
keyCharger1 := utils.ConcatenatedKey("cgrates.org", "call", "*out", "dan", "dan")
charger1 := utils.DerivedChargers{
&utils.DerivedCharger{RunId: "extra1", ReqTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
&utils.DerivedCharger{RunId: "extra2", ReqTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
}
if err := rds.SetDerivedChargers(keyCharger1, charger1); err != nil {
t.Error("Error on setting DerivedChargers", err.Error())
}
// Try retrieving from cache, should not be in yet
if _, err := rds.GetDerivedChargers(keyCharger1, false); err == nil {
t.Error("DerivedCharger should not be in the cache")
}
// Retrieve from db
if rcvCharger, err := rds.GetDerivedChargers(keyCharger1, true); err != nil {
t.Error("Error when retrieving DerivedCHarger", err.Error())
} else if !reflect.DeepEqual(rcvCharger, charger1) {
t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
}
// Retrieve from cache
if rcvCharger, err := rds.GetDerivedChargers(keyCharger1, false); err != nil {
t.Error("Error when retrieving DerivedCHarger", err.Error())
} else if !reflect.DeepEqual(rcvCharger, charger1) {
t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
}
}
示例13: TestUsersAddIndex
func TestUsersAddIndex(t *testing.T) {
var r string
testMap.AddIndex([]string{"t"}, &r)
if r != utils.OK ||
len(testMap.index) != 1 ||
len(testMap.index[utils.ConcatenatedKey("t", "v")]) != 5 {
t.Error("error adding index: ", testMap.index)
}
}
示例14: SetReverseCache
func (al *Alias) SetReverseCache() {
for _, value := range al.Values {
for target, pairs := range value.Pairs {
for _, alias := range pairs {
rKey := strings.Join([]string{utils.REVERSE_ALIASES_PREFIX, alias, target, al.Context}, "")
CachePush(rKey, utils.ConcatenatedKey(al.GetId(), value.DestinationId))
}
}
}
}
示例15: TestUsersAddIndexFull
func TestUsersAddIndexFull(t *testing.T) {
var r string
testMap.index = make(map[string]map[string]bool) // reset index
testMap.AddIndex([]string{"t", "x", "UserName", "Tenant"}, &r)
if r != utils.OK ||
len(testMap.index) != 7 ||
len(testMap.index[utils.ConcatenatedKey("t", "v")]) != 5 {
t.Error("error adding index: ", testMap.index)
}
}