本文整理匯總了Golang中github.com/cgrates/cgrates/engine.LcrRequest類的典型用法代碼示例。如果您正苦於以下問題:Golang LcrRequest類的具體用法?Golang LcrRequest怎麽用?Golang LcrRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了LcrRequest類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetLcr
// Computes the LCR for a specific request emulating a call
func (self *ApierV1) GetLcr(lcrReq engine.LcrRequest, lcrReply *engine.LcrReply) 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.Entry == nil {
return utils.ErrNotFound
}
lcrReply.DestinationId = lcrQried.Entry.DestinationId
lcrReply.RPCategory = lcrQried.Entry.RPCategory
lcrReply.Strategy = lcrQried.Entry.Strategy
for _, qriedSuppl := range lcrQried.SupplierCosts {
if qriedSuppl.Error != "" {
utils.Logger.Err(fmt.Sprintf("LCR_ERROR: supplier <%s>, error <%s>", qriedSuppl.Supplier, qriedSuppl.Error))
if !lcrReq.IgnoreErrors {
return fmt.Errorf("%s:%s", utils.ErrServerError.Error(), "LCR_COMPUTE_ERRORS")
}
continue
}
if dtcs, err := utils.NewDTCSFromRPKey(qriedSuppl.Supplier); err != nil {
return utils.NewErrServerError(err)
} else {
lcrReply.Suppliers = append(lcrReply.Suppliers, &engine.LcrSupplier{Supplier: dtcs.Subject, Cost: qriedSuppl.Cost, QOS: qriedSuppl.QOS})
}
}
return nil
}
示例2: 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
}