diff --git a/README.md b/README.md index f6967f8..4913319 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ clone the repository, then cd `./steward/cmd` and do `go build -o steward`, and Specify comma separated list for nodes to allow messages from. Use "*" for from all. Value RST will turn off subscriber. -startSubREQTextToConsole value Specify comma separated list for nodes to allow messages from. Use "*" for from all. Value RST will turn off subscriber. - -startSubREQTextToLogFile value + -startSubREQToFileAppend value Specify comma separated list for nodes to allow messages from. Use "*" for from all. Value RST will turn off subscriber. -startSubREQnCliCommand value Specify comma separated list for nodes to allow messages from. Use "*" for from all. Value RST will turn off subscriber. diff --git a/configuration_flags.go b/configuration_flags.go index 7714c0d..50e2972 100644 --- a/configuration_flags.go +++ b/configuration_flags.go @@ -105,7 +105,7 @@ type Configuration struct { // Subscriber for hello messages StartSubREQHello flagNodeSlice // Subscriber for text logging - StartSubREQTextToLogFile flagNodeSlice + StartSubREQToFileAppend flagNodeSlice // Subscriber for writing to file StartSubREQTextToFile flagNodeSlice // Subscriber for Echo Request @@ -145,7 +145,7 @@ func newConfigurationDefaults() Configuration { CentralNodeName: "", StartSubREQErrorLog: flagNodeSlice{Values: []node{}}, StartSubREQHello: flagNodeSlice{OK: true, Values: []node{"*"}}, - StartSubREQTextToLogFile: flagNodeSlice{OK: true, Values: []node{"*"}}, + StartSubREQToFileAppend: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubREQTextToFile: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubREQPing: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubREQPong: flagNodeSlice{OK: true, Values: []node{"*"}}, @@ -188,7 +188,7 @@ func (c *Configuration) CheckFlags() error { flag.Var(&c.StartSubREQErrorLog, "startSubREQErrorLog", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubREQHello, "startSubREQHello", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") - flag.Var(&c.StartSubREQTextToLogFile, "startSubREQTextToLogFile", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") + flag.Var(&c.StartSubREQToFileAppend, "startSubREQToFileAppend", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubREQTextToFile, "startSubREQTextToFile", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubREQPing, "startSubREQPing", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubREQPong, "startSubREQPong", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") diff --git a/etc/config.toml b/etc/config.toml index 549e76e..29d2fa6 100644 --- a/etc/config.toml +++ b/etc/config.toml @@ -45,7 +45,7 @@ SubscribersDataFolder = "./var" OK = true Values = ["*"] -[StartSubREQTextToLogFile] +[StartSubREQToFileAppend] OK = true Values = ["*"] diff --git a/example/toCentral-REQTextToLogFile.json b/example/toCentral-REQTextToLogFile.json index df9bfda..a2ef41d 100644 --- a/example/toCentral-REQTextToLogFile.json +++ b/example/toCentral-REQTextToLogFile.json @@ -5,6 +5,6 @@ "toNode": "central", "data": ["some message sent from a ship for testing\n"], "commandOrEvent":"EventACK", - "method":"REQTextToLogFile" + "method":"REQToFileAppend" } ] \ No newline at end of file diff --git a/example/toShip1-REQCliCommand.json b/example/toShip1-REQCliCommand.json index 2300c26..fbc93c8 100644 --- a/example/toShip1-REQCliCommand.json +++ b/example/toShip1-REQCliCommand.json @@ -5,7 +5,7 @@ "toNode": "ship1", "data": ["bash","-c","sleep 5 & tree ./"], "method":"REQCliCommand", - "replyMethod":"REQTextToLogFile", + "replyMethod":"REQToFileAppend", "timeout":5, "retries":3, "replyTimeout":5, diff --git a/example/toShip1-REQnCliCommand.json b/example/toShip1-REQnCliCommand.json index 6a52cf1..ead7b66 100644 --- a/example/toShip1-REQnCliCommand.json +++ b/example/toShip1-REQnCliCommand.json @@ -4,7 +4,7 @@ "fileExtension":".result", "toNode": "ship1", "data": ["bash","-c","tree ../"], - "replyMethod":"REQTextToLogFile", + "replyMethod":"REQToFileAppend", "method":"REQnCliCommand", "timeout":3, "retries":3, diff --git a/example/toShip2-REQOpCmdStart_REQHttpGet.json b/example/toShip2-REQOpCmdStart_REQHttpGet.json index 7e0531d..8f86a0e 100644 --- a/example/toShip2-REQOpCmdStart_REQHttpGet.json +++ b/example/toShip2-REQOpCmdStart_REQHttpGet.json @@ -12,7 +12,7 @@ "allowedNodes": ["central","node1"] } }, - "replyMethod":"REQTextToLogFile", + "replyMethod":"REQToFileAppend", "timeout":3, "retries":3, "replyTimeout":3, diff --git a/example/toShip2-REQOpCmdStop_REQHttpGet.json b/example/toShip2-REQOpCmdStop_REQHttpGet.json index 3d9c24f..a5487f4 100644 --- a/example/toShip2-REQOpCmdStop_REQHttpGet.json +++ b/example/toShip2-REQOpCmdStop_REQHttpGet.json @@ -13,7 +13,7 @@ "receivingNode": "ship2" } }, - "replyMethod":"REQTextToLogFile", + "replyMethod":"REQToFileAppend", "timeout":3, "retries":3, "replyTimeout":3, diff --git a/example/toShip2-REQOpPs.json b/example/toShip2-REQOpPs.json index d869485..2cbd152 100644 --- a/example/toShip2-REQOpPs.json +++ b/example/toShip2-REQOpPs.json @@ -8,7 +8,7 @@ "operation":{ "opCmd":"ps" }, - "replyMethod":"REQTextToLogFile", + "replyMethod":"REQToFileAppend", "timeout":3, "retries":3, "replyTimeout":3, diff --git a/startup_processes.go b/startup_processes.go index 8830385..d026bc3 100644 --- a/startup_processes.go +++ b/startup_processes.go @@ -23,8 +23,8 @@ func (p process) ProcessesStart() { } // Start a subscriber for textLogging messages - if p.configuration.StartSubREQTextToLogFile.OK { - p.startup.subREQTextToLogFile(p) + if p.configuration.StartSubREQToFileAppend.OK { + p.startup.subREQToFileAppend(p) } // Start a subscriber for text to file messages @@ -235,10 +235,10 @@ func (s startup) subREQTextToFile(p process) { go proc.spawnWorker(p.processes, p.natsConn) } -func (s startup) subREQTextToLogFile(p process) { +func (s startup) subREQToFileAppend(p process) { fmt.Printf("Starting text logging subscriber: %#v\n", p.node) - sub := newSubject(REQTextToLogFile, string(p.node)) - proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQTextToLogFile.Values, nil) + sub := newSubject(REQToFileAppend, string(p.node)) + proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQToFileAppend.Values, nil) // fmt.Printf("*** %#v\n", proc) go proc.spawnWorker(p.processes, p.natsConn) } diff --git a/subscriber_method_types.go b/subscriber_method_types.go index a4737d0..10ddf10 100644 --- a/subscriber_method_types.go +++ b/subscriber_method_types.go @@ -93,7 +93,7 @@ const ( // the receiving end. // The data field is a slice of strings where the values of the // slice will be written to the log file. - REQTextToLogFile Method = "REQTextToLogFile" + REQToFileAppend Method = "REQToFileAppend" // Send text to some host by overwriting the existing content of // the fileoutput to a file. If the file do not exist we create it. // A file with the full subject+hostName will be created on @@ -146,7 +146,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable { REQTextToConsole: methodREQTextToConsole{ commandOrEvent: EventACK, }, - REQTextToLogFile: methodREQTextToLogFile{ + REQToFileAppend: methodREQToFileAppend{ commandOrEvent: EventACK, }, REQTextToFile: methodREQTextToFile{ @@ -335,7 +335,7 @@ func (m methodREQOpCommand) handler(proc process, message Message, nodeName stri // publisher process will have the name of the node to receive the message, // and not just the local node name as with subscriber processes. // receive the message we need to specify - // Process name example: ship2.REQTextToLogFile.EventACK_subscriber + // Process name example: ship2.REQToFileAppend.EventACK_subscriber sub := newSubject(arg.Method, string(arg.RecevingNode)) processName := processNameGet(sub.name(), arg.Kind) @@ -394,7 +394,7 @@ func newReplyMessage(proc process, message Message, outData []byte) { // If no replyMethod is set we default to writing to writing to // a log file. if message.ReplyMethod == "" { - message.ReplyMethod = REQTextToLogFile + message.ReplyMethod = REQToFileAppend } //-- // Create a new message for the reply, and put it on the @@ -420,15 +420,15 @@ func newReplyMessage(proc process, message Message, outData []byte) { //-- } -type methodREQTextToLogFile struct { +type methodREQToFileAppend struct { commandOrEvent CommandOrEvent } -func (m methodREQTextToLogFile) getKind() CommandOrEvent { +func (m methodREQToFileAppend) getKind() CommandOrEvent { return m.commandOrEvent } -func (m methodREQTextToLogFile) handler(proc process, message Message, node string) ([]byte, error) { +func (m methodREQToFileAppend) handler(proc process, message Message, node string) ([]byte, error) { // If it was a request type message we want to check what the initial messages // method, so we can use that in creating the file name to store the data.