Apier local tests, added -rater parameter to cgr-engine command to be able to enforce starting of the rater/apier out of command line, useful mostly for test units

This commit is contained in:
DanB
2013-11-20 14:40:58 +01:00
parent 87ea266c4a
commit c7c4aefe0d
4 changed files with 18 additions and 14 deletions

View File

@@ -25,18 +25,8 @@ import (
"github.com/cgrates/cgrates/utils"
)
type ApierTPTiming struct {
TPid string // Tariff plan id
TimingId string // Timing id
Years string // semicolon separated list of years this timing is valid on, *all supported
Months string // semicolon separated list of months this timing is valid on, *none and *all supported
MonthDays string // semicolon separated list of month's days this timing is valid on, *none and *all supported
WeekDays string // semicolon separated list of week day names this timing is valid on *none and *all supported
Time string // String representing the time this timing starts on
}
// Creates a new timing within a tariff plan
func (self *ApierV1) SetTPTiming(attrs ApierTPTiming, reply *string) error {
func (self *ApierV1) SetTPTiming(attrs utils.ApierTPTiming, reply *string) error {
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "TimingId", "Years", "Months", "MonthDays", "WeekDays", "Time"}); len(missing) != 0 {
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
}
@@ -54,7 +44,7 @@ type AttrGetTPTiming struct {
}
// Queries specific Timing on Tariff plan
func (self *ApierV1) GetTPTiming(attrs AttrGetTPTiming, reply *ApierTPTiming) error {
func (self *ApierV1) GetTPTiming(attrs AttrGetTPTiming, reply *utils.ApierTPTiming) error {
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "TimingId"}); len(missing) != 0 { //Params missing
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
}
@@ -63,7 +53,7 @@ func (self *ApierV1) GetTPTiming(attrs AttrGetTPTiming, reply *ApierTPTiming) er
} else if tm == nil {
return errors.New(utils.ERR_NOT_FOUND)
} else {
*reply = ApierTPTiming{attrs.TPid, tm.Id, tm.Years.Serialize(";"),
*reply = utils.ApierTPTiming{attrs.TPid, tm.Id, tm.Years.Serialize(";"),
tm.Months.Serialize(";"), tm.MonthDays.Serialize(";"), tm.WeekDays.Serialize(";"), tm.StartTime}
}
return nil

View File

@@ -56,6 +56,7 @@ const (
var (
cfgPath = flag.String("config", "/etc/cgrates/cgrates.cfg", "Configuration file location.")
version = flag.Bool("version", false, "Prints the application version.")
raterEnabled = flag.Bool("rater", false, "Enforce starting of the rater daemon overwriting config")
bal = balancer2go.NewBalancer()
exitChan = make(chan bool)
sm sessionmanager.SessionManager
@@ -318,6 +319,9 @@ func main() {
}
defer dataDb.Close()
engine.SetDataStorage(dataDb)
if *raterEnabled {
cfg.RaterEnabled = *raterEnabled
}
if cfg.RaterEnabled {
engine.Logger.Info("Starting redis pre-caching...")
if err := dataDb.PreCache(nil, nil); err != nil {

View File

@@ -6,5 +6,5 @@ Architecture: amd64
Depends: daemontools, daemontools-run
Maintainer: DanB <danb@cgrates.org>
Description: Carrier Grade Rating System
CGRateS is a very fast and easy scalable rating engine useful especially for ISPs and Telecom Operators.
CGRateS is a very fast and easy scalable rating engine for Telecom environments.

View File

@@ -91,6 +91,16 @@ type DestinationRate struct {
Rate *TPRate
}
type ApierTPTiming struct {
TPid string // Tariff plan id
TimingId string // Timing id
Years string // semicolon separated list of years this timing is valid on, *all supported
Months string // semicolon separated list of months this timing is valid on, *none and *all supported
MonthDays string // semicolon separated list of month's days this timing is valid on, *none and *all supported
WeekDays string // semicolon separated list of week day names this timing is valid on *none and *all supported
Time string // String representing the time this timing starts on
}
type TPTiming struct {
Id string
Years Years