1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-03-05 06:46:48 +00:00

flag for sayhello publisher

This commit is contained in:
postmannen 2021-03-26 10:25:56 +01:00
parent b4a883bb4e
commit 8d245f372e
3 changed files with 7 additions and 7 deletions

View file

@ -91,7 +91,7 @@ type Configuration struct {
// default amount of retries that will be done before a message is thrown away, and out of the system // default amount of retries that will be done before a message is thrown away, and out of the system
DefaultMessageRetries int DefaultMessageRetries int
// Make the current node send hello messages to central at given interval in seconds // Make the current node send hello messages to central at given interval in seconds
PublisherServiceSayhello int StartPubSayHello int
// 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
@ -131,7 +131,7 @@ func newConfigurationDefaults() Configuration {
PromHostAndPort: "", PromHostAndPort: "",
DefaultMessageTimeout: 10, DefaultMessageTimeout: 10,
DefaultMessageRetries: 1, DefaultMessageRetries: 1,
PublisherServiceSayhello: 30, StartPubSayHello: 30,
SubscribersDataFolder: "./data", SubscribersDataFolder: "./data",
CentralNodeName: "", CentralNodeName: "",
StartSubErrorLog: flagNodeSlice{Values: []node{}}, StartSubErrorLog: flagNodeSlice{Values: []node{}},
@ -172,7 +172,7 @@ func (c *Configuration) CheckFlags() error {
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.IntVar(&c.PublisherServiceSayhello, "publisherServiceSayhello", fc.PublisherServiceSayhello, "Make the current node send hello messages to central at given interval in seconds") flag.IntVar(&c.StartPubSayHello, "startPubSayHello", fc.StartPubSayHello, "Make the current node send hello messages to central at given interval in seconds")
flag.Var(&c.StartSubErrorLog, "startSubErrorLog", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubErrorLog, "startSubErrorLog", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
flag.Var(&c.StartSubSayHello, "startSubSayHello", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubSayHello, "startSubSayHello", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")

View file

@ -6,7 +6,7 @@ DefaultMessageTimeout = 5
NodeName = "central" NodeName = "central"
ProfilingPort = "" ProfilingPort = ""
PromHostAndPort = "" PromHostAndPort = ""
PublisherServiceSayhello = 30 StartPubSayhello = 0
SubscribersDataFolder = "./data" SubscribersDataFolder = "./data"
[StartSubCLICommand] [StartSubCLICommand]

View file

@ -131,13 +131,13 @@ func (s *server) ProcessesStart() {
// Define a process of kind publisher with subject for SayHello to central, // Define a process of kind publisher with subject for SayHello to central,
// and register a procFunc with the process that will handle the actual // and register a procFunc with the process that will handle the actual
// sending of say hello. // sending of say hello.
if s.configuration.PublisherServiceSayhello != 0 { if s.configuration.StartPubSayHello != 0 {
fmt.Printf("Starting SayHello Publisher: %#v\n", s.nodeName) fmt.Printf("Starting SayHello Publisher: %#v\n", s.nodeName)
sub := newSubject(SayHello, EventNACK, s.configuration.CentralNodeName) 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 procFunc to be used for the process.
proc.procFunc = procFunc( proc.procFunc = procFunc(
func() error { func() error {
for { for {
@ -158,7 +158,7 @@ func (s *server) ProcessesStart() {
log.Printf("error: ProcessesStart: %v\n", err) log.Printf("error: ProcessesStart: %v\n", err)
} }
proc.newMessagesCh <- []subjectAndMessage{sam} proc.newMessagesCh <- []subjectAndMessage{sam}
time.Sleep(time.Second * time.Duration(s.configuration.PublisherServiceSayhello)) time.Sleep(time.Second * time.Duration(s.configuration.StartPubSayHello))
} }
}) })
go proc.spawnWorker(s) go proc.spawnWorker(s)