mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
small corrections anc code formatting
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/rif/cgrates/timespans"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
"github.com/rif/cgrates/timespans"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -82,7 +82,7 @@ func CallRater(key *timespans.CallDescriptor) (reply *timespans.CallCost) {
|
||||
time.Sleep(1 * time.Second) // wait one second and retry
|
||||
} else {
|
||||
reply = ×pans.CallCost{}
|
||||
err = client.Call("Storage.GetCost", *key, reply)
|
||||
err = client.Call("Storage.GetCost", *key, reply)
|
||||
if err != nil {
|
||||
log.Printf("Got en error from rater: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"exp/signal"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"exp/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/rif/cgrates/timespans"
|
||||
"github.com/rif/cgrates/timespans"
|
||||
)
|
||||
|
||||
type Responder byte
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/rpc/jsonrpc"
|
||||
"log"
|
||||
"github.com/rif/cgrates/timespans"
|
||||
"log"
|
||||
"net/rpc/jsonrpc"
|
||||
"time"
|
||||
)
|
||||
)
|
||||
|
||||
func main(){
|
||||
func main() {
|
||||
t1 := time.Date(2012, time.February, 02, 17, 30, 0, 0, time.UTC)
|
||||
t2 := time.Date(2012, time.February, 02, 18, 30, 0, 0, time.UTC)
|
||||
cd := timespans.CallDescriptor{CstmId: "vdf", Subject: "rif", DestinationPrefix: "0256", TimeStart: t1, TimeEnd: t2}
|
||||
result := timespans.CallCost{}
|
||||
client, _ := jsonrpc.Dial("tcp", "localhost:5090")
|
||||
runs := int(5 * 1e4);
|
||||
i:= 0
|
||||
runs := int(5 * 1e4)
|
||||
i := 0
|
||||
c := make(chan string)
|
||||
for ; i < runs; i++ {
|
||||
go func(){
|
||||
go func() {
|
||||
var reply string
|
||||
client.Call("Responder.Get", cd, &result)
|
||||
c <- reply
|
||||
}()
|
||||
//time.Sleep(1*time.Second)
|
||||
//time.Sleep(1*time.Second)
|
||||
}
|
||||
for j:=0; j < runs; j++ {
|
||||
for j := 0; j < runs; j++ {
|
||||
<-c
|
||||
}
|
||||
log.Println(result)
|
||||
log.Println(i)
|
||||
client.Close()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,8 +56,9 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) {
|
||||
ts1 := &TimeSpan{TimeStart: cd.TimeStart, TimeEnd: cd.TimeEnd}
|
||||
ts1.ActivationPeriod = cd.ActivationPeriods[0]
|
||||
|
||||
// split on activation periods
|
||||
timespans = append(timespans, ts1)
|
||||
afterStart, afterEnd := false, false
|
||||
afterStart, afterEnd := false, false //optimization for multiple activation periods
|
||||
for _, ap := range cd.ActivationPeriods {
|
||||
if !afterStart && !afterEnd && ap.ActivationTime.Before(cd.TimeStart) {
|
||||
ts1.ActivationPeriod = ap
|
||||
@@ -74,7 +75,7 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// split on price intervals
|
||||
for i := 0; i < len(timespans); i++ {
|
||||
for _, interval := range timespans[i].ActivationPeriod.Intervals {
|
||||
newTs := timespans[i].SplitByInterval(interval)
|
||||
@@ -88,7 +89,7 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) {
|
||||
}
|
||||
|
||||
func (cd *CallDescriptor) RestoreFromStorage(sg StorageGetter) (destPrefix string, err error) {
|
||||
cd.ActivationPeriods = make([]*ActivationPeriod, 2)
|
||||
cd.ActivationPeriods = make([]*ActivationPeriod, 0)
|
||||
base := fmt.Sprintf("%s:%s:", cd.CstmId, cd.Subject)
|
||||
destPrefix = cd.DestinationPrefix
|
||||
key := base + destPrefix
|
||||
|
||||
Reference in New Issue
Block a user