mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-05 14:56:49 +00:00
fixed error in centralNodeName implementation
This commit is contained in:
parent
18f6f2a6f1
commit
78a2b2bc56
4 changed files with 8 additions and 5 deletions
|
@ -32,7 +32,7 @@ type Configuration struct {
|
||||||
// Publisher data folder
|
// Publisher data folder
|
||||||
SubscribersDataFolder string
|
SubscribersDataFolder string
|
||||||
// central node to receive messages published from nodes
|
// central node to receive messages published from nodes
|
||||||
centralNodeName string
|
CentralNodeName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfiguration() *Configuration {
|
func NewConfiguration() *Configuration {
|
||||||
|
@ -40,6 +40,7 @@ func NewConfiguration() *Configuration {
|
||||||
return &c
|
return &c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default configuration
|
||||||
func newConfigurationDefaults() Configuration {
|
func newConfigurationDefaults() Configuration {
|
||||||
c := Configuration{
|
c := Configuration{
|
||||||
ConfigFolder: "./etc",
|
ConfigFolder: "./etc",
|
||||||
|
@ -51,7 +52,7 @@ func newConfigurationDefaults() Configuration {
|
||||||
DefaultMessageRetries: 1,
|
DefaultMessageRetries: 1,
|
||||||
PublisherServiceSayhello: 30,
|
PublisherServiceSayhello: 30,
|
||||||
SubscribersDataFolder: "./data",
|
SubscribersDataFolder: "./data",
|
||||||
centralNodeName: "",
|
CentralNodeName: "",
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,7 @@ func (c *Configuration) CheckFlags() {
|
||||||
flag.IntVar(&c.DefaultMessageRetries, "defaultMessageRetries", fc.DefaultMessageRetries, "default amount of retries that will be done before a message is thrown away, and out of the system")
|
flag.IntVar(&c.DefaultMessageRetries, "defaultMessageRetries", fc.DefaultMessageRetries, "default amount of retries that will be done before a message is thrown away, and out of the system")
|
||||||
flag.IntVar(&c.PublisherServiceSayhello, "publisherServiceSayhello", fc.PublisherServiceSayhello, "Make the current node send hello messages to central at given interval in seconds")
|
flag.IntVar(&c.PublisherServiceSayhello, "publisherServiceSayhello", fc.PublisherServiceSayhello, "Make the current node send hello messages to central at given interval in seconds")
|
||||||
flag.StringVar(&c.SubscribersDataFolder, "subscribersDataFolder", fc.SubscribersDataFolder, "The data folder where subscribers are allowed to write their data if needed")
|
flag.StringVar(&c.SubscribersDataFolder, "subscribersDataFolder", fc.SubscribersDataFolder, "The data folder where subscribers are allowed to write their data if needed")
|
||||||
flag.StringVar(&c.centralNodeName, "centralNodeName", fc.centralNodeName, "The name of the central node to receive messages published by this node")
|
flag.StringVar(&c.CentralNodeName, "centralNodeName", fc.CentralNodeName, "The name of the central node to receive messages published by this node")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
BrokerAddress = "0"
|
BrokerAddress = "0"
|
||||||
CentralErrorLogger = true
|
CentralErrorLogger = true
|
||||||
|
CentralNodeName = "central"
|
||||||
ConfigFolder = "./etc"
|
ConfigFolder = "./etc"
|
||||||
DefaultMessageRetries = 3
|
DefaultMessageRetries = 3
|
||||||
DefaultMessageTimeout = 5
|
DefaultMessageTimeout = 5
|
||||||
|
|
|
@ -73,7 +73,7 @@ func (s *server) ProcessesStart() {
|
||||||
fmt.Printf("Starting SayHello Publisher: %#v\n", s.nodeName)
|
fmt.Printf("Starting SayHello Publisher: %#v\n", s.nodeName)
|
||||||
|
|
||||||
// TODO: Replace "central" name with variable below.
|
// TODO: Replace "central" name with variable below.
|
||||||
sub := newSubject(SayHello, EventNACK, "central")
|
sub := newSubject(SayHello, EventNACK, s.configuration.CentralNodeName)
|
||||||
proc := newProcess(s.processes, s.newMessagesCh, s.configuration, sub, s.errorKernel.errorCh, processKindPublisher, []node{}, nil)
|
proc := newProcess(s.processes, s.newMessagesCh, s.configuration, sub, s.errorKernel.errorCh, processKindPublisher, []node{}, nil)
|
||||||
|
|
||||||
// Define the procFun to be used for the process.
|
// Define the procFun to be used for the process.
|
||||||
|
|
|
@ -100,7 +100,8 @@ func NewServer(c *Configuration) (*server, error) {
|
||||||
log.Printf("info: Creating subscribers data folder at %v\n", c.SubscribersDataFolder)
|
log.Printf("info: Creating subscribers data folder at %v\n", c.SubscribersDataFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.configuration.centralNodeName == "" {
|
// The node name of the central server have to be set.
|
||||||
|
if s.configuration.CentralNodeName == "" {
|
||||||
return nil, fmt.Errorf("error: the centralNodeName config option or flag cannot be empty")
|
return nil, fmt.Errorf("error: the centralNodeName config option or flag cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue