mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
actions sorters
This commit is contained in:
@@ -27,21 +27,25 @@ import (
|
||||
"log"
|
||||
"runtime"
|
||||
"time"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
raterAddress = flag.String("rateraddr", "127.0.0.1:2000", "Rater server address (localhost:2000)")
|
||||
jsonRpcAddress = flag.String("jsonrpcaddr", "127.0.0.1:2001", "Json RPC server address (localhost:2001)")
|
||||
httpApiAddress = flag.String("httpapiaddr", "127.0.0.1:8000", "Http API server address (localhost:2002)")
|
||||
freeswitchsrv = flag.String("freeswitchsrv", "localhost:8021", "freeswitch address host:port")
|
||||
freeswitchpass = flag.String("freeswitchpass", "ClueCon", "freeswitch address host:port")
|
||||
bal *balancer.Balancer
|
||||
raterAddress = flag.String("rateraddr", "127.0.0.1:2000", "Rater server address (localhost:2000)")
|
||||
jsonRpcAddress = flag.String("jsonrpcaddr", "127.0.0.1:2001", "Json RPC server address (localhost:2001)")
|
||||
httpApiAddress = flag.String("httpapiaddr", "127.0.0.1:8000", "Http API server address (localhost:2002)")
|
||||
freeswitchsrv = flag.String("freeswitchsrv", "localhost:8021", "freeswitch address host:port")
|
||||
freeswitchpass = flag.String("freeswitchpass", "ClueCon", "freeswitch address host:port")
|
||||
bal *balancer.Balancer
|
||||
balancerRWMutex sync.RWMutex
|
||||
)
|
||||
|
||||
/*
|
||||
The function that gets the information from the raters using balancer.
|
||||
*/
|
||||
func GetCallCost(key *timespans.CallDescriptor, method string) (reply *timespans.CallCost) {
|
||||
balancerRWMutex.RLock()
|
||||
defer balancerRWMutex
|
||||
err := errors.New("") //not nil value
|
||||
for err != nil {
|
||||
client := bal.Balance()
|
||||
|
||||
@@ -40,25 +40,8 @@ var (
|
||||
s = scheduler{}
|
||||
)
|
||||
|
||||
/*
|
||||
Structure to store action timings according to next activation time.
|
||||
*/
|
||||
type actiontimingqueue []*timespans.ActionTiming
|
||||
|
||||
func (atq actiontimingqueue) Len() int {
|
||||
return len(atq)
|
||||
}
|
||||
|
||||
func (atq actiontimingqueue) Swap(i, j int) {
|
||||
atq[i], atq[j] = atq[j], atq[i]
|
||||
}
|
||||
|
||||
func (atq actiontimingqueue) Less(j, i int) bool {
|
||||
return atq[j].GetNextStartTime().Before(atq[i].GetNextStartTime())
|
||||
}
|
||||
|
||||
type scheduler struct {
|
||||
queue actiontimingqueue
|
||||
queue timespans.ActionTimingPriotityList
|
||||
}
|
||||
|
||||
func (s scheduler) loop() {
|
||||
@@ -110,7 +93,7 @@ func loadActionTimings() {
|
||||
log.Fatalf("Cannot get action timings:", err)
|
||||
}
|
||||
// recreate the queue
|
||||
s.queue = actiontimingqueue{}
|
||||
s.queue = timespans.ActionTimingPriotityList{}
|
||||
for _, at := range actionTimings {
|
||||
if at.IsOneTimeRun() {
|
||||
log.Print("Executing: ", at)
|
||||
|
||||
Reference in New Issue
Block a user