mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-05 06:46:48 +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
|
||||
SubscribersDataFolder string
|
||||
// central node to receive messages published from nodes
|
||||
centralNodeName string
|
||||
CentralNodeName string
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
|
@ -40,6 +40,7 @@ func NewConfiguration() *Configuration {
|
|||
return &c
|
||||
}
|
||||
|
||||
// Default configuration
|
||||
func newConfigurationDefaults() Configuration {
|
||||
c := Configuration{
|
||||
ConfigFolder: "./etc",
|
||||
|
@ -51,7 +52,7 @@ func newConfigurationDefaults() Configuration {
|
|||
DefaultMessageRetries: 1,
|
||||
PublisherServiceSayhello: 30,
|
||||
SubscribersDataFolder: "./data",
|
||||
centralNodeName: "",
|
||||
CentralNodeName: "",
|
||||
}
|
||||
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.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.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()
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
BrokerAddress = "0"
|
||||
CentralErrorLogger = true
|
||||
CentralNodeName = "central"
|
||||
ConfigFolder = "./etc"
|
||||
DefaultMessageRetries = 3
|
||||
DefaultMessageTimeout = 5
|
||||
|
|
|
@ -73,7 +73,7 @@ func (s *server) ProcessesStart() {
|
|||
fmt.Printf("Starting SayHello Publisher: %#v\n", s.nodeName)
|
||||
|
||||
// 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)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue