Go fmt on sources

This commit is contained in:
DanB
2013-04-07 12:13:26 +02:00
parent e95939e4ea
commit f70cecaa17
3 changed files with 45 additions and 46 deletions

View File

@@ -23,11 +23,11 @@ import (
"flag"
"fmt"
"github.com/cgrates/cgrates/balancer2go"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/mediator"
"github.com/cgrates/cgrates/rater"
"github.com/cgrates/cgrates/scheduler"
"github.com/cgrates/cgrates/sessionmanager"
"github.com/cgrates/cgrates/config"
"io"
"net"
"net/rpc"
@@ -58,7 +58,7 @@ var (
exitChan = make(chan bool)
sm sessionmanager.SessionManager
cfg *config.CGRConfig
err error
err error
)
func listenToRPCRequests(rpcResponder interface{}, rpcAddress string, rpc_encoding string) {
@@ -123,9 +123,9 @@ func startMediator(responder *rater.Responder, loggerDb rater.DataStorage) {
// exitChan <- true
//}
m, err := mediator.NewMediator(connector, loggerDb, cfg.MediatorSkipDB, cfg.MediatorCDROutPath, cfg.MediatorPseudoprepaid,
m, err := mediator.NewMediator(connector, loggerDb, cfg.MediatorSkipDB, cfg.MediatorCDROutPath, cfg.MediatorPseudoprepaid,
cfg.FreeswitchDirectionIdx, cfg.FreeswitchTORIdx, cfg.FreeswitchTenantIdx, cfg.FreeswitchSubjectIdx, cfg.FreeswitchAccountIdx,
cfg.FreeswitchDestIdx, cfg.FreeswitchTimeStartIdx, cfg.FreeswitchDurationIdx, cfg.FreeswitchUUIDIdx)
cfg.FreeswitchDestIdx, cfg.FreeswitchTimeStartIdx, cfg.FreeswitchDurationIdx, cfg.FreeswitchUUIDIdx)
if err != nil {
rater.Logger.Crit(fmt.Sprintf("Mediator config parsing error: %v", err))
exitChan <- true
@@ -156,7 +156,7 @@ func startSessionManager(responder *rater.Responder, loggerDb rater.DataStorage)
case FS:
dp, _ := time.ParseDuration(fmt.Sprintf("%vs", cfg.SMDebitPeriod))
sm = sessionmanager.NewFSSessionManager(loggerDb, connector, dp)
errConn := sm.Connect(cfg )
errConn := sm.Connect(cfg)
if errConn != nil {
rater.Logger.Err(fmt.Sprintf("<SessionManager> error: %s!", errConn))
}
@@ -248,7 +248,7 @@ func main() {
}
runtime.GOMAXPROCS(runtime.NumCPU())
cfg, err = config.NewCGRConfig( cfgPath )
cfg, err = config.NewCGRConfig(cfgPath)
if err != nil {
rater.Logger.Crit(fmt.Sprintf("Could not parse config: %s exiting!", err))
return

View File

@@ -38,53 +38,53 @@ const (
// Holds system configuration, defaults are overwritten with values from config file if found
type CGRConfig struct {
DataDBType string
DataDBHost string // The host to connect to. Values that start with / are for UNIX domain sockets.
DataDBPort string // The port to bind to.
DataDBName string // The name of the database to connect to.
DataDBUser string // The user to sign in as.
DataDBPass string // The user's password.
LogDBType string // Should reflect the database type used to store logs
LogDBHost string // The host to connect to. Values that start with / are for UNIX domain sockets.
LogDBPort string // The port to bind to.
LogDBName string // The name of the database to connect to.
LogDBUser string // The user to sign in as.
LogDBPass string // The user's password.
DataDBType string
DataDBHost string // The host to connect to. Values that start with / are for UNIX domain sockets.
DataDBPort string // The port to bind to.
DataDBName string // The name of the database to connect to.
DataDBUser string // The user to sign in as.
DataDBPass string // The user's password.
LogDBType string // Should reflect the database type used to store logs
LogDBHost string // The host to connect to. Values that start with / are for UNIX domain sockets.
LogDBPort string // The port to bind to.
LogDBName string // The name of the database to connect to.
LogDBUser string // The user to sign in as.
LogDBPass string // The user's password.
RaterEnabled bool // start standalone server (no balancer)
RaterBalancer string // balancer address host:port
RaterListen string // listening address host:port
RaterRPCEncoding string // use JSON for RPC encoding
RaterRPCEncoding string // use JSON for RPC encoding
BalancerEnabled bool
BalancerListen string // Json RPC server address
BalancerRPCEncoding string // use JSON for RPC encoding
BalancerRPCEncoding string // use JSON for RPC encoding
SchedulerEnabled bool
SMEnabled bool
SMSwitchType string
SMSwitchType string
SMRater string // address where to access rater. Can be internal, direct rater address or the address of a balancer
SMDebitPeriod int // the period to be debited in advanced during a call (in seconds)
SMRPCEncoding string // use JSON for RPC encoding
SMDefaultTOR string // set default type of record label to 0
SMDefaultTenant string // set default tenant to 0
SMDefaultSubject string // set default rating subject to 0
SMDebitPeriod int // the period to be debited in advanced during a call (in seconds)
SMRPCEncoding string // use JSON for RPC encoding
SMDefaultTOR string // set default type of record label to 0
SMDefaultTenant string // set default tenant to 0
SMDefaultSubject string // set default rating subject to 0
MediatorEnabled bool
MediatorCDRPath string // Freeswitch Master CSV CDR path.
MediatorCDROutPath string // Freeswitch Master CSV CDR output path.
MediatorCDRPath string // Freeswitch Master CSV CDR path.
MediatorCDROutPath string // Freeswitch Master CSV CDR output path.
MediatorRater string // address where to access rater. Can be internal, direct rater address or the address of a balancer
MediatorRPCEncoding string // use JSON for RPC encoding
MediatorRPCEncoding string // use JSON for RPC encoding
MediatorSkipDB bool
MediatorPseudoprepaid bool
MediatorPseudoprepaid bool
FreeswitchServer string // freeswitch address host:port
FreeswitchPass string // FS socket password
FreeswitchDirectionIdx string
FreeswitchTORIdx string
FreeswitchTenantIdx string
FreeswitchSubjectIdx string
FreeswitchAccountIdx string
FreeswitchDestIdx string
FreeswitchTimeStartIdx string
FreeswitchDurationIdx string
FreeswitchUUIDIdx string
FreeswitchReconnects int
FreeswitchDirectionIdx string
FreeswitchTORIdx string
FreeswitchTenantIdx string
FreeswitchSubjectIdx string
FreeswitchAccountIdx string
FreeswitchDestIdx string
FreeswitchTimeStartIdx string
FreeswitchDurationIdx string
FreeswitchUUIDIdx string
FreeswitchReconnects int // number of times to attempt reconnect after connect fails
}
// Instantiate a new CGRConfig setting defaults or reading from file

View File

@@ -25,7 +25,7 @@ import (
func TestConfig(t *testing.T) {
cfgPth := "test_data.txt"
cfg, err := NewCGRConfig( &cfgPth )
cfg, err := NewCGRConfig(&cfgPth)
if err != nil {
t.Log(fmt.Sprintf("Could not parse config: %s!", err))
t.FailNow()
@@ -79,15 +79,14 @@ func TestConfig(t *testing.T) {
func TestParamOverwrite(t *testing.T) {
cfgPth := "test_data.txt"
cfg, err := NewCGRConfig( &cfgPth )
cfg, err := NewCGRConfig(&cfgPth)
if err != nil {
t.Log(fmt.Sprintf("Could not parse config: %s!", err))
t.FailNow()
}
if cfg.FreeswitchReconnects != 5 { // one default which is not overwritten in test data
t.Errorf("FreeswitchReconnects set == %d, expect 5",cfg.FreeswitchReconnects)
if cfg.FreeswitchReconnects != 5 { // one default which is not overwritten in test data
t.Errorf("FreeswitchReconnects set == %d, expect 5", cfg.FreeswitchReconnects)
} else if cfg.SchedulerEnabled != true { // one parameter which should be overwritten in test data
t.Errorf("scheduler_enabled set == %d, expect true",cfg.SchedulerEnabled)
t.Errorf("scheduler_enabled set == %d, expect true", cfg.SchedulerEnabled)
}
}