engine.Responder with ProcessCdr method, moved cdrs and mediator to engine

This commit is contained in:
DanB
2014-07-25 17:44:50 +02:00
parent 19e994ca8a
commit e93b8a6c6f
19 changed files with 266 additions and 325 deletions

View File

@@ -1458,7 +1458,6 @@ func TestLocalProcessCdr(t *testing.T) {
t.Error("Unexpected reply received: ", reply)
}
var cdrs []*utils.StoredCdr
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time to CDR to reach db
req := utils.AttrGetCdrs{}
if err := rater.Call("ApierV1.GetCdrs", req, &cdrs); err != nil {
t.Error("Unexpected error: ", err.Error())

41
apier/cdrsv1.go Normal file
View File

@@ -0,0 +1,41 @@
/*
Real-time Charging System for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can Storagetribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITH*out ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package apier
import (
"fmt"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
// Receive CDRs via RPC methods
type CDRSV1 struct {
CdrSrv *engine.CDRS
}
func (cdrsrv *CDRSV1) ProcessCdr(cdr *utils.StoredCdr, reply *string) error {
if cdrsrv.CdrSrv == nil {
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, "CDRS_NOT_RUNNING")
}
if err := cdrsrv.CdrSrv.ProcessCdr(cdr); err != nil {
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
}
*reply = utils.OK
return nil
}

View File

@@ -20,13 +20,13 @@ package apier
import (
"fmt"
"github.com/cgrates/cgrates/mediator"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"time"
)
type MediatorV1 struct {
Medi *mediator.Mediator
Medi *engine.Mediator
}
// Remotely start mediation with specific runid, runs asynchronously, it's status will be displayed in syslog