本文整理匯總了Golang中github.com/cgrates/cgrates/engine.LCRCost.LogErrors方法的典型用法代碼示例。如果您正苦於以下問題:Golang LCRCost.LogErrors方法的具體用法?Golang LCRCost.LogErrors怎麽用?Golang LCRCost.LogErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cgrates/cgrates/engine.LCRCost
的用法示例。
在下文中一共展示了LCRCost.LogErrors方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LCRSuppliers
func (smg *SMGeneric) LCRSuppliers(gev SMGenericEvent) (suppls []string, err error) {
cacheKey := "LCRSuppliers" + gev.GetCgrId(smg.timezone) + gev.GetAccount(utils.META_DEFAULT) + gev.GetDestination(utils.META_DEFAULT)
if item, err := smg.responseCache.Get(cacheKey); err == nil && item != nil {
if item.Value != nil {
suppls = (item.Value.([]string))
}
err = item.Err
return suppls, err
}
defer smg.responseCache.Cache(cacheKey, &cache.CacheItem{Value: suppls, Err: err})
gev[utils.EVENT_NAME] = utils.CGR_LCR_REQUEST
var cd *engine.CallDescriptor
cd, err = gev.AsLcrRequest().AsCallDescriptor(smg.timezone)
cd.CgrID = gev.GetCgrId(smg.timezone)
if err != nil {
return
}
var lcr engine.LCRCost
if err = smg.rater.Call("Responder.GetLCR", &engine.AttrGetLcr{CallDescriptor: cd}, &lcr); err != nil {
return
}
if lcr.HasErrors() {
lcr.LogErrors()
err = errors.New("LCR_COMPUTE_ERROR")
return
}
suppls, err = lcr.SuppliersSlice()
return
}
示例2: onChannelPark
func (sm *FSSessionManager) onChannelPark(ev engine.Event, connId string) {
fsev := ev.(FSEvent)
if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE || fsev[IGNOREPARK] == "true" { // Do not process this request
return
}
var maxCallDuration float64 // This will be the maximum duration this channel will be allowed to last
if err := sm.rater.Call("Responder.GetDerivedMaxSessionTime", ev.AsStoredCdr(config.CgrConfig().DefaultTimezone), &maxCallDuration); err != nil {
utils.Logger.Err(fmt.Sprintf("<SM-FreeSWITCH> Could not get max session time for %s, error: %s", ev.GetUUID(), err.Error()))
}
if maxCallDuration != -1 { // For calls different than unlimited, set limits
maxCallDur := time.Duration(maxCallDuration)
if maxCallDur <= sm.cfg.MinCallDuration {
//utils.Logger.Info(fmt.Sprintf("Not enough credit for trasferring the call %s for %s.", ev.GetUUID(), cd.GetKey(cd.Subject)))
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), INSUFFICIENT_FUNDS)
return
}
sm.setMaxCallDuration(ev.GetUUID(), connId, maxCallDur)
}
// ComputeLcr
if ev.ComputeLcr() {
cd, err := fsev.AsCallDescriptor()
cd.CgrID = fsev.GetCgrId(sm.Timezone())
if err != nil {
utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_PREPROCESS_ERROR: %s", err.Error()))
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
return
}
var lcr engine.LCRCost
if err = sm.Rater().Call("Responder.GetLCR", &engine.AttrGetLcr{CallDescriptor: cd}, &lcr); err != nil {
utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_API_ERROR: %s", err.Error()))
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
}
if lcr.HasErrors() {
lcr.LogErrors()
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
return
}
if supps, err := lcr.SuppliersSlice(); err != nil {
utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_ERROR: %s", err.Error()))
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
return
} else {
fsArray := SliceAsFsArray(supps)
if _, err = sm.conns[connId].SendApiCmd(fmt.Sprintf("uuid_setvar %s %s %s\n\n", ev.GetUUID(), utils.CGR_SUPPLIERS, fsArray)); err != nil {
utils.Logger.Info(fmt.Sprintf("<SM-FreeSWITCH> LCR_ERROR: %s", err.Error()))
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), SYSTEM_ERROR)
}
}
}
sm.unparkCall(ev.GetUUID(), connId, ev.GetCallDestNr(utils.META_DEFAULT), AUTH_OK)
}
示例3: GetLcrSuppliers
func (self *SMGeneric) GetLcrSuppliers(gev SMGenericEvent, clnt *rpc2.Client) ([]string, error) {
gev[utils.EVENT_NAME] = utils.CGR_LCR_REQUEST
cd, err := gev.AsLcrRequest().AsCallDescriptor(self.timezone)
if err != nil {
return nil, err
}
var lcr engine.LCRCost
if err = self.rater.GetLCR(&engine.AttrGetLcr{CallDescriptor: cd}, &lcr); err != nil {
return nil, err
}
if lcr.HasErrors() {
lcr.LogErrors()
return nil, errors.New("LCR_COMPUTE_ERROR")
}
return lcr.SuppliersSlice()
}
示例4: getSuppliers
func (self *KamailioSessionManager) getSuppliers(kev KamEvent) (string, error) {
cd, err := kev.AsCallDescriptor()
if err != nil {
utils.Logger.Info(fmt.Sprintf("<SM-Kamailio> LCR_PREPROCESS_ERROR error: %s", err.Error()))
return "", errors.New("LCR_PREPROCESS_ERROR")
}
var lcr engine.LCRCost
if err = self.Rater().GetLCR(&engine.AttrGetLcr{CallDescriptor: cd}, &lcr); err != nil {
utils.Logger.Info(fmt.Sprintf("<SM-Kamailio> LCR_API_ERROR error: %s", err.Error()))
return "", errors.New("LCR_API_ERROR")
}
if lcr.HasErrors() {
lcr.LogErrors()
return "", errors.New("LCR_COMPUTE_ERROR")
}
return lcr.SuppliersString()
}
示例5: LCRSuppliers
func (smg *SMGeneric) LCRSuppliers(gev SMGenericEvent) ([]string, error) {
gev[utils.EVENT_NAME] = utils.CGR_LCR_REQUEST
cd, err := gev.AsLcrRequest().AsCallDescriptor(smg.timezone)
cd.CgrID = gev.GetCgrId(smg.timezone)
if err != nil {
return nil, err
}
var lcr engine.LCRCost
if err = smg.rater.Call("Responder.GetLCR", &engine.AttrGetLcr{CallDescriptor: cd}, &lcr); err != nil {
return nil, err
}
if lcr.HasErrors() {
lcr.LogErrors()
return nil, errors.New("LCR_COMPUTE_ERROR")
}
return lcr.SuppliersSlice()
}
示例6: GetLcrSuppliers
// Computes the LCR for a specific request emulating a call, returns a comma separated list of suppliers
func (self *ApierV1) GetLcrSuppliers(lcrReq engine.LcrRequest, suppliers *string) (err error) {
cd, err := lcrReq.AsCallDescriptor(self.Config.DefaultTimezone)
if err != nil {
return err
}
var lcrQried engine.LCRCost
if err := self.Responder.GetLCR(&engine.AttrGetLcr{CallDescriptor: cd, Paginator: lcrReq.Paginator}, &lcrQried); err != nil {
return utils.NewErrServerError(err)
}
if lcrQried.HasErrors() {
lcrQried.LogErrors()
if !lcrReq.IgnoreErrors {
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_COMPUTE_ERRORS")
}
}
if suppliersStr, err := lcrQried.SuppliersString(); err != nil {
return utils.NewErrServerError(err)
} else {
*suppliers = suppliersStr
}
return nil
}