From c7c4aefe0d1a37e67b72c3ddc039383c25dd972c Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 20 Nov 2013 14:40:58 +0100 Subject: [PATCH] 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 --- apier/v1/tptimings.go | 16 +++------------- cmd/cgr-engine/cgr-engine.go | 4 ++++ data/pkg/skel/DEBIAN/control | 2 +- utils/apitpdata.go | 10 ++++++++++ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/apier/v1/tptimings.go b/apier/v1/tptimings.go index b5d28e61c..e1f5ac76e 100644 --- a/apier/v1/tptimings.go +++ b/apier/v1/tptimings.go @@ -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 diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 3f6e3b09b..5d9e3e234 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -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 { diff --git a/data/pkg/skel/DEBIAN/control b/data/pkg/skel/DEBIAN/control index 273c256d6..1a0328260 100644 --- a/data/pkg/skel/DEBIAN/control +++ b/data/pkg/skel/DEBIAN/control @@ -6,5 +6,5 @@ Architecture: amd64 Depends: daemontools, daemontools-run Maintainer: DanB 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. diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 35355dbc6..4a7f4c2b6 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -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