mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Update travis with go 1.11, return error instead of panis ( RSRParsers) and active connection from RALs to StatS
This commit is contained in:
committed by
Dan Christian Bogos
parent
fc8f62ca03
commit
cc23fd4f28
@@ -1,7 +1,7 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.9
|
||||
- 1.11.0
|
||||
|
||||
install:
|
||||
- go get github.com/Masterminds/glide
|
||||
|
||||
@@ -789,7 +789,7 @@ func startSupplierService(internalSupplierSChan chan rpcclient.RpcClientConnecti
|
||||
cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
|
||||
cfg.SupplierSCfg().AttributeSConns, internalAttrSChan, cfg.InternalTtl)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to &s: %s",
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not connect to %s: %s",
|
||||
utils.SupplierS, utils.AttributeS, err.Error()))
|
||||
exitChan <- true
|
||||
return
|
||||
|
||||
@@ -176,6 +176,9 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheS *en
|
||||
if thdS != nil {
|
||||
engine.SetThresholdS(thdS) // temporary architectural fix until we will have separate AccountS
|
||||
}
|
||||
if stats != nil {
|
||||
engine.SetStatS(stats)
|
||||
}
|
||||
if cdrStats != nil { // ToDo: Fix here properly the init of stats
|
||||
responder.CdrStats = cdrStats
|
||||
apierRpcV1.CdrStatsSrv = cdrStats
|
||||
|
||||
@@ -37,8 +37,7 @@ func NewFCTemplateFromFCTemplateJsonCfg(jsnCfg *FcTemplateJsonCfg) (*FCTemplate,
|
||||
}
|
||||
}
|
||||
if jsnCfg.Value != nil {
|
||||
fcTmp.Value, err = NewRSRParsers(*jsnCfg.Value, true)
|
||||
if err != nil {
|
||||
if fcTmp.Value, err = NewRSRParsers(*jsnCfg.Value, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -117,10 +116,9 @@ func FCTemplatesFromFCTemapltesJsonCfg(jsnCfgFlds []*FcTemplateJsonCfg) ([]*FCTe
|
||||
retFields := make([]*FCTemplate, len(jsnCfgFlds))
|
||||
var err error
|
||||
for i, jsnFld := range jsnCfgFlds {
|
||||
retFields[i], err = NewFCTemplateFromFCTemplateJsonCfg(jsnFld)
|
||||
if err != nil {
|
||||
if retFields[i], err = NewFCTemplateFromFCTemplateJsonCfg(jsnFld); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return retFields, err
|
||||
return retFields, nil
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ func (ca *HttpAgentCfg) loadFromJsonCfg(jsnCfg *HttpAgentJsonCfg) (err error) {
|
||||
}
|
||||
}
|
||||
if jsnCfg.Tenant != nil {
|
||||
ca.Tenant = NewRSRParsersMustCompile(*jsnCfg.Tenant, true)
|
||||
if ca.Tenant, err = NewRSRParsers(*jsnCfg.Tenant, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if jsnCfg.Timezone != nil {
|
||||
ca.Timezone = *jsnCfg.Timezone
|
||||
|
||||
@@ -76,7 +76,7 @@ func (self *LoaderDataType) loadFromJsonCfg(jsnCfg *LoaderJsonDataType) (err err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *LoaderSConfig) loadFromJsonCfg(jsnCfg *LoaderJsonCfg) error {
|
||||
func (self *LoaderSConfig) loadFromJsonCfg(jsnCfg *LoaderJsonCfg) (err error) {
|
||||
if jsnCfg == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -87,7 +87,9 @@ func (self *LoaderSConfig) loadFromJsonCfg(jsnCfg *LoaderJsonCfg) error {
|
||||
self.Enabled = *jsnCfg.Enabled
|
||||
}
|
||||
if jsnCfg.Tenant != nil {
|
||||
self.Tenant = NewRSRParsersMustCompile(*jsnCfg.Tenant, true)
|
||||
if self.Tenant, err = NewRSRParsers(*jsnCfg.Tenant, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if jsnCfg.Dry_run != nil {
|
||||
self.DryRun = *jsnCfg.Dry_run
|
||||
|
||||
@@ -130,7 +130,9 @@ func (self *RARequestProcessor) loadFromJsonCfg(jsnCfg *RAReqProcessorJsnCfg) (e
|
||||
self.ContinueOnSuccess = *jsnCfg.Continue_on_success
|
||||
}
|
||||
if jsnCfg.Tenant != nil {
|
||||
self.Tenant = NewRSRParsersMustCompile(*jsnCfg.Tenant, true)
|
||||
if self.Tenant, err = NewRSRParsers(*jsnCfg.Tenant, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if jsnCfg.Timezone != nil {
|
||||
self.Timezone = *jsnCfg.Timezone
|
||||
|
||||
@@ -33,15 +33,15 @@ In a nutshell all the dependencies are installed and used from a folder named *v
|
||||
|
||||
First we have to setup the GO Lang to our OS. Feel free to download
|
||||
the latest GO binary release from https://golang.org/dl/
|
||||
In this Tutorial we are going to install Go 1.10.3.
|
||||
In this Tutorial we are going to install Go 1.11.0.
|
||||
|
||||
::
|
||||
|
||||
cd $HOME && mkdir -p src/go opt && cd src
|
||||
wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
|
||||
tar -xvf go1.10.3.linux-amd64.tar.gz -C $HOME/opt
|
||||
export GOPATH=$HOME/src/go
|
||||
export PATH=$PATH:$HOME/opt/go/bin:$GOPATH/bin
|
||||
rm -rf /usr/local/go
|
||||
cd /tmp
|
||||
wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz
|
||||
sudo tar -xvf go1.11.0.linux-amd64.tar.gz -C /usr/local/
|
||||
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
|
||||
|
||||
3.2.2 Build CGRateS from Source
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -1075,26 +1075,28 @@ func (acc *Account) AsAccountSummary() *AccountSummary {
|
||||
}
|
||||
|
||||
func (acnt *Account) Publish() {
|
||||
if thresholdS == nil {
|
||||
return
|
||||
}
|
||||
acntTnt := utils.NewTenantID(acnt.ID)
|
||||
thEv := &ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.AccountUpdate,
|
||||
utils.EventSource: utils.AccountService,
|
||||
utils.Account: acntTnt.ID,
|
||||
utils.AllowNegative: acnt.AllowNegative,
|
||||
utils.Disabled: acnt.Disabled}}}
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.AccountUpdate,
|
||||
utils.EventSource: utils.AccountService,
|
||||
utils.Account: acntTnt.ID,
|
||||
utils.AllowNegative: acnt.AllowNegative,
|
||||
utils.Disabled: acnt.Disabled}}
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent,
|
||||
thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing account event %+v with ThresholdS.", err.Error(), thEv))
|
||||
if statS != nil {
|
||||
var reply []string
|
||||
go statS.Call(utils.StatSv1ProcessEvent, &StatsArgsProcessEvent{CGREvent: cgrEv}, &reply)
|
||||
}
|
||||
if thresholdS != nil {
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent,
|
||||
&ArgsProcessEvent{CGREvent: cgrEv}, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing account event %+v with ThresholdS.", err.Error(), cgrEv))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -696,31 +696,35 @@ func (b *Balance) AsBalanceSummary(typ string) *BalanceSummary {
|
||||
}
|
||||
|
||||
func (b *Balance) Publish() {
|
||||
if b.account == nil ||
|
||||
thresholdS == nil {
|
||||
if b.account == nil {
|
||||
return
|
||||
}
|
||||
accountId := b.account.ID
|
||||
acntTnt := utils.NewTenantID(accountId)
|
||||
thEv := &ArgsProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.BalanceUpdate,
|
||||
utils.EventSource: utils.AccountService,
|
||||
utils.Account: acntTnt.ID,
|
||||
utils.BalanceID: b.ID,
|
||||
utils.Units: b.Value}}}
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: acntTnt.Tenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
utils.EventType: utils.BalanceUpdate,
|
||||
utils.EventSource: utils.AccountService,
|
||||
utils.Account: acntTnt.ID,
|
||||
utils.BalanceID: b.ID,
|
||||
utils.Units: b.Value}}
|
||||
if !b.ExpirationDate.IsZero() {
|
||||
thEv.Event[utils.ExpiryTime] = b.ExpirationDate.Format(time.RFC3339)
|
||||
cgrEv.Event[utils.ExpiryTime] = b.ExpirationDate.Format(time.RFC3339)
|
||||
}
|
||||
if statS != nil {
|
||||
var reply []string
|
||||
go statS.Call(utils.StatSv1ProcessEvent, &StatsArgsProcessEvent{CGREvent: cgrEv}, &reply)
|
||||
}
|
||||
var tIDs []string
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing balance event %+v with ThresholdS.",
|
||||
err.Error(), thEv))
|
||||
if thresholdS != nil {
|
||||
if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, &ArgsProcessEvent{CGREvent: cgrEv}, &tIDs); err != nil &&
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<AccountS> error: %s processing balance event %+v with ThresholdS.",
|
||||
err.Error(), cgrEv))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ var (
|
||||
debitPeriod = 10 * time.Second
|
||||
globalRoundingDecimals = 6
|
||||
thresholdS rpcclient.RpcClientConnection // used by RALs to communicate with ThresholdS
|
||||
statS rpcclient.RpcClientConnection
|
||||
pubSubServer rpcclient.RpcClientConnection
|
||||
userService rpcclient.RpcClientConnection
|
||||
aliasService rpcclient.RpcClientConnection
|
||||
@@ -76,6 +77,10 @@ func SetThresholdS(thdS rpcclient.RpcClientConnection) {
|
||||
thresholdS = thdS
|
||||
}
|
||||
|
||||
func SetStatS(stsS rpcclient.RpcClientConnection) {
|
||||
statS = stsS
|
||||
}
|
||||
|
||||
// Sets the global rounding method and decimal precision for GetCost method
|
||||
func SetRoundingDecimals(rd int) {
|
||||
globalRoundingDecimals = rd
|
||||
|
||||
@@ -694,7 +694,7 @@ func testCallSyncSessions(t *testing.T) {
|
||||
var numberOfCDR int
|
||||
switch optConf {
|
||||
case utils.Freeswitch:
|
||||
sourceForCDR = utils.MetaSessionS
|
||||
sourceForCDR = "FS_CHANNEL_ANSWER"
|
||||
numberOfCDR = 2
|
||||
case utils.Kamailio:
|
||||
sourceForCDR = utils.MetaSessionS + "_" + utils.KamailioAgent
|
||||
|
||||
@@ -280,7 +280,14 @@ func (smg *SMGeneric) ttlTerminate(s *SMGSession, tmtr *smgSessionTerminator) {
|
||||
}
|
||||
cdr.Usage = s.TotalUsage
|
||||
var reply string
|
||||
smg.cdrsrv.Call("CdrsV1.ProcessCDR", cdr, &reply)
|
||||
cgrEv := &utils.CGREvent{
|
||||
Tenant: s.EventStart.GetStringIgnoreErrors(utils.Tenant),
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: cdr.AsMapStringIface(),
|
||||
}
|
||||
if err = smg.cdrsrv.Call(utils.CdrsV2ProcessCDR, cgrEv, &reply); err != nil {
|
||||
return
|
||||
}
|
||||
if smg.resS != nil && s.ResourceID != "" {
|
||||
var reply string
|
||||
argsRU := utils.ArgRSv1ResourceUsage{
|
||||
|
||||
Reference in New Issue
Block a user