本文整理汇总了Golang中github.com/cgrates/cgrates/utils.LCRKey函数的典型用法代码示例。如果您正苦于以下问题:Golang LCRKey函数的具体用法?Golang LCRKey怎么用?Golang LCRKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LCRKey函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: GetLCRFromStorage
func (cd *CallDescriptor) GetLCRFromStorage() (*LCR, error) {
keyVariants := []string{
utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, cd.Account, cd.Subject),
utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, cd.Account, utils.ANY),
utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, utils.ANY, utils.ANY),
utils.LCRKey(cd.Direction, cd.Tenant, utils.ANY, utils.ANY, utils.ANY),
utils.LCRKey(utils.ANY, utils.ANY, cd.Category, utils.ANY, utils.ANY),
utils.LCRKey(utils.ANY, utils.ANY, utils.ANY, utils.ANY, utils.ANY),
}
if lcrSubjectPrefixMatching {
var partialSubjects []string
lenSubject := len(cd.Subject)
for i := 1; i < lenSubject; i++ {
partialSubjects = append(partialSubjects, utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, cd.Account, cd.Subject[:lenSubject-i]))
}
// insert partialsubjects into keyVariants
keyVariants = append(keyVariants[:1], append(partialSubjects, keyVariants[1:]...)...)
}
for _, key := range keyVariants {
if lcr, err := ratingStorage.GetLCR(key, false, utils.NonTransactional); err != nil && err != utils.ErrNotFound {
return nil, err
} else if err == nil && lcr != nil {
return lcr, nil
}
}
return nil, utils.ErrNotFound
}
开发者ID:cgrates,项目名称:cgrates,代码行数:27,代码来源:calldesc.go
示例2: GetLCRFromStorage
func (cd *CallDescriptor) GetLCRFromStorage() (*LCR, error) {
keyVariants := []string{
utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, cd.Account, cd.Subject),
utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, cd.Account, utils.ANY),
utils.LCRKey(cd.Direction, cd.Tenant, cd.Category, utils.ANY, utils.ANY),
utils.LCRKey(cd.Direction, cd.Tenant, utils.ANY, utils.ANY, utils.ANY),
utils.LCRKey(cd.Direction, utils.ANY, utils.ANY, utils.ANY, utils.ANY),
utils.LCRKey(utils.ANY, utils.ANY, utils.ANY, utils.ANY, utils.ANY),
}
for _, key := range keyVariants {
if lcr, err := ratingStorage.GetLCR(key, false); err != nil && err != utils.ErrNotFound {
return nil, err
} else if err == nil {
return lcr, nil
}
}
return nil, utils.ErrNotFound
}
开发者ID:perrault,项目名称:cgrates,代码行数:18,代码来源:calldesc.go
示例3: GetLcrRuleId
func (lcr *TpLcrRule) GetLcrRuleId() string {
return utils.LCRKey(lcr.Direction, lcr.Tenant, lcr.Category, lcr.Account, lcr.Subject)
}
开发者ID:kevinlovesing,项目名称:cgrates,代码行数:3,代码来源:models.go
示例4: LoadLCRs
func (tpr *TpReader) LoadLCRs() (err error) {
tps, err := tpr.lr.GetTpLCRs(&TpLcrRule{Tpid: tpr.tpid})
if err != nil {
return err
}
for _, tpLcr := range tps {
// check the rating profiles
ratingProfileSearchKey := utils.ConcatenatedKey(tpLcr.Direction, tpLcr.Tenant, tpLcr.RpCategory)
found := false
for rpfKey := range tpr.ratingProfiles {
if strings.HasPrefix(rpfKey, ratingProfileSearchKey) {
found = true
break
}
}
if !found && tpr.ratingStorage != nil {
if keys, err := tpr.ratingStorage.GetKeysForPrefix(utils.RATING_PROFILE_PREFIX + ratingProfileSearchKey); err != nil {
return fmt.Errorf("[LCR] error querying ratingDb %s", err.Error())
} else if len(keys) != 0 {
found = true
}
}
if !found {
return fmt.Errorf("[LCR] could not find ratingProfiles with prefix %s", ratingProfileSearchKey)
}
// check destination tags
if tpLcr.DestinationTag != "" && tpLcr.DestinationTag != utils.ANY {
_, found := tpr.destinations[tpLcr.DestinationTag]
if !found && tpr.ratingStorage != nil {
if found, err = tpr.ratingStorage.HasData(utils.DESTINATION_PREFIX, tpLcr.DestinationTag); err != nil {
return fmt.Errorf("[LCR] error querying ratingDb %s", err.Error())
}
}
if !found {
return fmt.Errorf("[LCR] could not find destination with tag %s", tpLcr.DestinationTag)
}
}
tag := utils.LCRKey(tpLcr.Direction, tpLcr.Tenant, tpLcr.Category, tpLcr.Account, tpLcr.Subject)
activationTime, _ := utils.ParseTimeDetectLayout(tpLcr.ActivationTime, tpr.timezone)
lcr, found := tpr.lcrs[tag]
if !found {
lcr = &LCR{
Direction: tpLcr.Direction,
Tenant: tpLcr.Tenant,
Category: tpLcr.Category,
Account: tpLcr.Account,
Subject: tpLcr.Subject,
}
}
var act *LCRActivation
for _, existingAct := range lcr.Activations {
if existingAct.ActivationTime.Equal(activationTime) {
act = existingAct
break
}
}
if act == nil {
act = &LCRActivation{
ActivationTime: activationTime,
}
lcr.Activations = append(lcr.Activations, act)
}
act.Entries = append(act.Entries, &LCREntry{
DestinationId: tpLcr.DestinationTag,
RPCategory: tpLcr.RpCategory,
Strategy: tpLcr.Strategy,
StrategyParams: tpLcr.StrategyParams,
Weight: tpLcr.Weight,
})
tpr.lcrs[tag] = lcr
}
return nil
}
开发者ID:foehn,项目名称:cgrates,代码行数:76,代码来源:tp_reader.go
注:本文中的github.com/cgrates/cgrates/utils.LCRKey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论