Mediator refactoring to support CDR as imput instead of csv row - adding separation of names and indexes, StartTime->AnswerTime, adding reqtype=rated

This commit is contained in:
DanB
2013-06-06 12:37:36 +02:00
parent fbbb26fab3
commit a75c2e7324
27 changed files with 523 additions and 461 deletions

View File

@@ -50,8 +50,6 @@ const (
ANSWER = "CHANNEL_ANSWER"
HANGUP = "CHANNEL_HANGUP_COMPLETE"
PARK = "CHANNEL_PARK"
REQTYPE_PREPAID = "prepaid"
REQTYPE_POSTPAID = "postpaid"
AUTH_OK = "+AUTH_OK"
DISCONNECT = "+SWITCH DISCONNECT"
INSUFFICIENT_FUNDS = "-INSUFFICIENT_FUNDS"

View File

@@ -24,6 +24,7 @@ import (
"fmt"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/rater"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/fsock"
"log/syslog"
"net"
@@ -145,7 +146,7 @@ func (sm *FSSessionManager) OnChannelPark(ev Event) {
startTime = time.Now()
}
// if there is no account configured leave the call alone
if strings.TrimSpace(ev.GetReqType()) != REQTYPE_PREPAID {
if strings.TrimSpace(ev.GetReqType()) != utils.PREPAID {
return
}
if ev.MissingParameter() {
@@ -194,7 +195,7 @@ func (sm *FSSessionManager) OnChannelHangupComplete(ev Event) {
return
}
defer s.Close() // Stop loop and save the costs deducted so far to database
if ev.GetReqType() == REQTYPE_POSTPAID {
if ev.GetReqType() == utils.POSTPAID {
startTime, err := ev.GetStartTime(START_TIME)
if err != nil {
rater.Logger.Crit("Error parsing postpaid call start time from event")

View File

@@ -21,8 +21,8 @@ package sessionmanager
import (
"fmt"
"github.com/cgrates/cgrates/rater"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/fsock"
"strings"
"time"
)
@@ -38,8 +38,8 @@ type Session struct {
// Creates a new session and starts the debit loop
func NewSession(ev Event, sm SessionManager) (s *Session) {
// Ignore calls which have nothing to do with CGRateS
if strings.TrimSpace(ev.GetReqType()) == "" {
// SesionManager only handles prepaid and postpaid calls
if ev.GetReqType() != utils.PREPAID && ev.GetReqType() != utils.POSTPAID {
return
}
// Make sure cgr_type is enforced even if not set by FreeSWITCH
@@ -68,9 +68,9 @@ func NewSession(ev Event, sm SessionManager) (s *Session) {
sm.DisconnectSession(s, MISSING_PARAMETER)
} else {
switch ev.GetReqType() {
case REQTYPE_PREPAID:
case utils.PREPAID:
go s.startDebitLoop()
case REQTYPE_POSTPAID:
case utils.POSTPAID:
// do not loop, make only one debit at hangup
}
}

View File

@@ -21,7 +21,6 @@ package sessionmanager
import (
"github.com/cgrates/cgrates/config"
"testing"
// "time"
)
var (
@@ -55,61 +54,7 @@ var (
### Test data, not for production usage
[global]
datadb_type = test #
datadb_host = test # The host to connect to. Values that start with / are for UNIX domain sockets.
datadb_port = test # The port to bind to.
datadb_name = test # The name of the database to connect to.
datadb_user = test # The user to sign in as.
datadb_passwd = test # The user's password.root
logdb_type = test #
logdb_host = test # The host to connect to. Values that start with / are for UNIX domain sockets.
logdb_port = test # The port to bind to.
logdb_name = test # The name of the database to connect to.
logdb_user = test # The user to sign in as.
logdb_passwd = test # The user's password.root
[balancer]
enabled = true # Start balancer server
listen = test # Balancer listen interface
rpc_encoding = test # use JSON for RPC encoding
[rater]
enabled = true
listen = test # listening address host:port, internal for internal communication only
balancer = test # if defined it will register to balancer as worker
rpc_encoding = test # use JSON for RPC encoding
[mediator]
enabled = true
cdr_in_dir = test # Freeswitch Master CSV CDR path.
cdr_out_dir = test
rater = test #address where to access rater. Can be internal, direct rater address or the address of a balancer
rpc_encoding = test # use JSON for RPC encoding
skipdb = true
pseudoprepaid = true
[scheduler]
enabled = true
[session_manager]
enabled = true
switch_type = test
rater = test #address where to access rater. Can be internal, direct rater address or the address of a balancer
debit_interval = 11
rpc_encoding = test # use JSON for RPC encoding
[freeswitch]
server = test # freeswitch address host:port
passwd = test # freeswitch address host:port
direction_index = test
tor_index = test
tenant_index = test
subject_index = test
account_index = test
destination_index = test
time_start_index = test
duration_index = test
uuid_index = test
default_reqtype=
`)
)