mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
aliases config
This commit is contained in:
@@ -198,6 +198,7 @@ type CGRConfig struct {
|
||||
RaterHistoryServer string
|
||||
RaterPubSubServer string
|
||||
RaterUserServer string
|
||||
RaterAliasesServer string
|
||||
BalancerEnabled bool
|
||||
SchedulerEnabled bool
|
||||
CDRSEnabled bool // Enable CDR Server service
|
||||
@@ -219,8 +220,8 @@ type CGRConfig struct {
|
||||
HistoryServerEnabled bool // Starts History as server: <true|false>.
|
||||
HistoryDir string // Location on disk where to store history files.
|
||||
HistorySaveInterval time.Duration // The timout duration between pubsub writes
|
||||
PubSubServer string // Address where to reach the master pubsub server: <internal|x.y.z.y:1234>
|
||||
PubSubServerEnabled bool // Starts PubSub as server: <true|false>.
|
||||
AliasesServerEnabled bool // Starts PubSub as server: <true|false>.
|
||||
UserServerEnabled bool // Starts User as server: <true|false>
|
||||
UserServerIndexes []string // List of user profile field indexes
|
||||
MailerServer string // The server to use when sending emails out
|
||||
@@ -250,6 +251,9 @@ func (self *CGRConfig) checkConfigSanity() error {
|
||||
if self.RaterPubSubServer == utils.INTERNAL && !self.PubSubServerEnabled {
|
||||
return errors.New("PubSub server not enabled but requested by Rater component.")
|
||||
}
|
||||
if self.RaterAliasesServer == utils.INTERNAL && !self.AliasesServerEnabled {
|
||||
return errors.New("Aliases server not enabled but requested by Rater component.")
|
||||
}
|
||||
if self.RaterUserServer == utils.INTERNAL && !self.UserServerEnabled {
|
||||
return errors.New("Users service not enabled but requested by Rater component.")
|
||||
}
|
||||
@@ -425,6 +429,11 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
|
||||
return err
|
||||
}
|
||||
|
||||
jsnAliasesServCfg, err := jsnCfg.AliasesServJsonCfg()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsnUserServCfg, err := jsnCfg.UserServJsonCfg()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -566,6 +575,9 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
|
||||
if jsnRaterCfg.Pubsubs != nil {
|
||||
self.RaterPubSubServer = *jsnRaterCfg.Pubsubs
|
||||
}
|
||||
if jsnRaterCfg.Aliases != nil {
|
||||
self.RaterAliasesServer = *jsnRaterCfg.Aliases
|
||||
}
|
||||
if jsnRaterCfg.Users != nil {
|
||||
self.RaterUserServer = *jsnRaterCfg.Users
|
||||
}
|
||||
@@ -709,6 +721,12 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
|
||||
}
|
||||
}
|
||||
|
||||
if jsnAliasesServCfg != nil {
|
||||
if jsnAliasesServCfg.Enabled != nil {
|
||||
self.AliasesServerEnabled = *jsnAliasesServCfg.Enabled
|
||||
}
|
||||
}
|
||||
|
||||
if jsnUserServCfg != nil {
|
||||
if jsnUserServCfg.Enabled != nil {
|
||||
self.UserServerEnabled = *jsnUserServCfg.Enabled
|
||||
|
||||
@@ -93,6 +93,7 @@ const CGRATES_CFG_JSON = `
|
||||
"historys": "", // address where to reach the history service, empty to disable history functionality: <""|internal|x.y.z.y:1234>
|
||||
"pubsubs": "", // address where to reach the pubusb service, empty to disable pubsub functionality: <""|internal|x.y.z.y:1234>
|
||||
"users": "", // address where to reach the user service, empty to disable user profile functionality: <""|internal|x.y.z.y:1234>
|
||||
"aliases": "", // address where to reach the aliases service, empty to disable aliases functionality: <""|internal|x.y.z.y:1234>
|
||||
},
|
||||
|
||||
|
||||
@@ -254,6 +255,9 @@ const CGRATES_CFG_JSON = `
|
||||
"enabled": false, // starts PubSub service: <true|false>.
|
||||
},
|
||||
|
||||
"aliases": {
|
||||
"enabled": false, // starts Aliases service: <true|false>.
|
||||
},
|
||||
|
||||
"users": {
|
||||
"enabled": false, // starts User service: <true|false>.
|
||||
|
||||
@@ -27,30 +27,31 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
GENERAL_JSN = "general"
|
||||
LISTEN_JSN = "listen"
|
||||
TPDB_JSN = "tariffplan_db"
|
||||
DATADB_JSN = "data_db"
|
||||
STORDB_JSN = "stor_db"
|
||||
BALANCER_JSN = "balancer"
|
||||
RATER_JSN = "rater"
|
||||
SCHEDULER_JSN = "scheduler"
|
||||
CDRS_JSN = "cdrs"
|
||||
MEDIATOR_JSN = "mediator"
|
||||
CDRSTATS_JSN = "cdrstats"
|
||||
CDRE_JSN = "cdre"
|
||||
CDRC_JSN = "cdrc"
|
||||
SMFS_JSN = "sm_freeswitch"
|
||||
SMKAM_JSN = "sm_kamailio"
|
||||
SMOSIPS_JSN = "sm_opensips"
|
||||
SM_JSN = "session_manager"
|
||||
FS_JSN = "freeswitch"
|
||||
KAMAILIO_JSN = "kamailio"
|
||||
OSIPS_JSN = "opensips"
|
||||
HISTSERV_JSN = "historys"
|
||||
PUBSUBSERV_JSN = "pubsubs"
|
||||
USERSERV_JSN = "users"
|
||||
MAILER_JSN = "mailer"
|
||||
GENERAL_JSN = "general"
|
||||
LISTEN_JSN = "listen"
|
||||
TPDB_JSN = "tariffplan_db"
|
||||
DATADB_JSN = "data_db"
|
||||
STORDB_JSN = "stor_db"
|
||||
BALANCER_JSN = "balancer"
|
||||
RATER_JSN = "rater"
|
||||
SCHEDULER_JSN = "scheduler"
|
||||
CDRS_JSN = "cdrs"
|
||||
MEDIATOR_JSN = "mediator"
|
||||
CDRSTATS_JSN = "cdrstats"
|
||||
CDRE_JSN = "cdre"
|
||||
CDRC_JSN = "cdrc"
|
||||
SMFS_JSN = "sm_freeswitch"
|
||||
SMKAM_JSN = "sm_kamailio"
|
||||
SMOSIPS_JSN = "sm_opensips"
|
||||
SM_JSN = "session_manager"
|
||||
FS_JSN = "freeswitch"
|
||||
KAMAILIO_JSN = "kamailio"
|
||||
OSIPS_JSN = "opensips"
|
||||
HISTSERV_JSN = "historys"
|
||||
PUBSUBSERV_JSN = "pubsubs"
|
||||
ALIASESSERV_JSN = "aliases"
|
||||
USERSERV_JSN = "users"
|
||||
MAILER_JSN = "mailer"
|
||||
)
|
||||
|
||||
// Loads the json config out of io.Reader, eg other sources than file, maybe over http
|
||||
@@ -256,6 +257,18 @@ func (self CgrJsonCfg) PubSubServJsonCfg() (*PubSubServJsonCfg, error) {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func (self CgrJsonCfg) AliasesServJsonCfg() (*AliasesServJsonCfg, error) {
|
||||
rawCfg, hasKey := self[ALIASESSERV_JSN]
|
||||
if !hasKey {
|
||||
return nil, nil
|
||||
}
|
||||
cfg := new(AliasesServJsonCfg)
|
||||
if err := json.Unmarshal(*rawCfg, cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func (self CgrJsonCfg) UserServJsonCfg() (*UserServJsonCfg, error) {
|
||||
rawCfg, hasKey := self[USERSERV_JSN]
|
||||
if !hasKey {
|
||||
|
||||
@@ -123,11 +123,11 @@ func TestDfBalancerJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfRaterJsonCfg(t *testing.T) {
|
||||
eCfg := &RaterJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer(""), Cdrstats: utils.StringPointer(""),
|
||||
Historys: utils.StringPointer(""), Pubsubs: utils.StringPointer(""), Users: utils.StringPointer("")}
|
||||
Historys: utils.StringPointer(""), Pubsubs: utils.StringPointer(""), Users: utils.StringPointer(""), Aliases: utils.StringPointer("")}
|
||||
if cfg, err := dfCgrJsonCfg.RaterJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eCfg, cfg) {
|
||||
t.Error("Received: ", cfg)
|
||||
t.Errorf("Received: %+v", cfg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,6 +417,17 @@ func TestDfPubSubServJsonCfg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDfAliasesServJsonCfg(t *testing.T) {
|
||||
eCfg := &AliasesServJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.AliasesServJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eCfg, cfg) {
|
||||
t.Error("Received: ", cfg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDfUserServJsonCfg(t *testing.T) {
|
||||
eCfg := &UserServJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
|
||||
@@ -64,6 +64,7 @@ type RaterJsonCfg struct {
|
||||
Cdrstats *string
|
||||
Historys *string
|
||||
Pubsubs *string
|
||||
Aliases *string
|
||||
Users *string
|
||||
}
|
||||
|
||||
@@ -230,7 +231,12 @@ type PubSubServJsonCfg struct {
|
||||
Enabled *bool
|
||||
}
|
||||
|
||||
// PubSub server config section
|
||||
// Aliases server config section
|
||||
type AliasesServJsonCfg struct {
|
||||
Enabled *bool
|
||||
}
|
||||
|
||||
// Users server config section
|
||||
type UserServJsonCfg struct {
|
||||
Enabled *bool
|
||||
Indexes *[]string
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
// "historys": "", // address where to reach the history service, empty to disable history functionality: <""|internal|x.y.z.y:1234>
|
||||
// "pubsubs": "", // address where to reach the pubusb service, empty to disable pubsub functionality: <""|internal|x.y.z.y:1234>
|
||||
// "users": "", // address where to reach the user service, empty to disable user profile functionality: <""|internal|x.y.z.y:1234>
|
||||
// "aliases": "", // address where to reach the aliases service, empty to disable aliases functionality: <""|internal|x.y.z.y:1234>
|
||||
//},
|
||||
|
||||
|
||||
@@ -238,6 +239,9 @@
|
||||
// "indexes": [], // user profile field indexes
|
||||
//},
|
||||
|
||||
//"aliases": {
|
||||
// "enabled": false, // starts Aliases service: <true|false>.
|
||||
//},
|
||||
|
||||
//"mailer": {
|
||||
// "server": "localhost", // the server to use when sending emails out
|
||||
|
||||
Reference in New Issue
Block a user