Updates on loader, adding users for data reloading

This commit is contained in:
DanB
2018-04-29 19:53:25 +02:00
parent 84e8fc1336
commit ed332afc8e
3 changed files with 26 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"log"
"path"
"strings"
"time"
"github.com/cgrates/cgrates/config"
@@ -292,7 +293,8 @@ func main() {
if cacheS, err = rpcclient.NewRpcClient("tcp",
ldrCfg.LoaderCgrConfig.CachesConns[0].Address, 3, 3,
time.Duration(1*time.Second), time.Duration(5*time.Minute),
*rpcEncoding, nil, false); err != nil {
strings.TrimPrefix(ldrCfg.LoaderCgrConfig.CachesConns[0].Transport, utils.Meta),
nil, false); err != nil {
log.Fatalf("Could not connect to CacheS: %s", err.Error())
return
}
@@ -308,7 +310,7 @@ func main() {
} else {
if userS, err = rpcclient.NewRpcClient("tcp", *usersAddress, 3, 3,
time.Duration(1*time.Second), time.Duration(5*time.Minute),
*rpcEncoding, nil, false); err != nil {
strings.TrimPrefix(*rpcEncoding, utils.Meta), nil, false); err != nil {
log.Fatalf("Could not connect to UserS API: %s", err.Error())
return
}
@@ -340,6 +342,11 @@ func main() {
ralsIDs, _ = tpReader.GetLoadedIds(utils.REVERSE_ALIASES_PREFIX)
}
aps, _ := tpReader.GetLoadedIds(utils.ACTION_PLAN_PREFIX)
// for users reloading
var userIds []string
if userS != nil {
userIds, _ = tpReader.GetLoadedIds(utils.USERS_PREFIX)
}
// release the reader with it's structures
tpReader.Init()
@@ -381,6 +388,16 @@ func main() {
}
}
if userS != nil && len(userIds) > 0 {
if *verbose {
log.Print("Reloading Users data")
}
var reply string
if err := userS.Call("UsersV1.ReloadUsers", "", &reply); err != nil {
log.Printf("WARNING: Failed reloading users data, error: %s\n", err.Error())
}
}
}
} else {

View File

@@ -611,14 +611,15 @@ const CGRATES_CFG_JSON = `
"tax_exemption_code_list": "", // template extracting tax exemption code list out of StoredCdr; <$RSRFields>
},
"loader": {
"tpid": "",
"data_path": "",
"runid": "",
"disable_reverse": false,
"caches_conns":[
"loader": { // loader for tariff plans out of .csv files
"tpid": "", // tariff plan identificator
"data_path": "", // path towards tariff plan files
"disable_reverse": false, // disable reverse computing
"caches_conns":[ // addresses towards cacheS components for reloads
{"address": "127.0.0.1:2012", "transport": "*json"}
],
},
}`

View File

@@ -383,7 +383,6 @@ func testCallCheckResourceAllocation(t *testing.T) {
t.Errorf("Resources: %+v", utils.ToJSON(rs))
}
for _, r := range *rs {
utils.Logger.Debug(fmt.Sprintf("Resource : %+v\n", r))
if r.ID == "ResGroup1" &&
(len(r.Usages) != 1 || len(r.TTLIdx) != 1) {
t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))