From 4a7f1fff4342213ab0eeee51d0a3f15e261c6cd7 Mon Sep 17 00:00:00 2001 From: postmannen Date: Sun, 4 Apr 2021 11:19:17 +0200 Subject: [PATCH] CLI to Cli --- configuration_flags.go | 6 +++--- etc/config.toml | 2 +- example/toShip1-CLICommandRequest1.json | 2 +- startup_processes.go | 8 ++++---- subscriber_method_types.go | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/configuration_flags.go b/configuration_flags.go index 3df71fb..20137e6 100644 --- a/configuration_flags.go +++ b/configuration_flags.go @@ -108,7 +108,7 @@ type Configuration struct { // Subscriber for Echo Reply StartSubEchoReply flagNodeSlice // Subscriber for CLICommandRequest - StartSubREQCLICommand flagNodeSlice + StartSubREQCliCommand flagNodeSlice // Subscriber for CLICommandRequestNOSEQ StartSubCLICommandRequestNOSEQ flagNodeSlice // Subscriber for CLICommandReply @@ -137,7 +137,7 @@ func newConfigurationDefaults() Configuration { StartSubTextLogging: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubEchoRequest: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubEchoReply: flagNodeSlice{OK: true, Values: []node{"*"}}, - StartSubREQCLICommand: flagNodeSlice{OK: true, Values: []node{"*"}}, + StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubCLICommandRequestNOSEQ: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubCLICommandReply: flagNodeSlice{OK: true, Values: []node{"*"}}, } @@ -176,7 +176,7 @@ func (c *Configuration) CheckFlags() error { flag.Var(&c.StartSubTextLogging, "startSubTextLogging", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubEchoRequest, "startSubEchoRequest", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubEchoReply, "startSubEchoReply", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") - flag.Var(&c.StartSubREQCLICommand, "startSubREQCLICommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") + flag.Var(&c.StartSubREQCliCommand, "startSubREQCliCommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubCLICommandRequestNOSEQ, "startSubCLICommandRequestNOSEQ", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.") flag.Var(&c.StartSubCLICommandReply, "startSubCLICommandReply", "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 f24ada0..e7088ce 100644 --- a/etc/config.toml +++ b/etc/config.toml @@ -29,7 +29,7 @@ SubscribersDataFolder = "./data" OK = true Values = ["*"] -[StartSubREQCLICommand] +[StartSubREQCliCommand] OK = true Values = ["*"] diff --git a/example/toShip1-CLICommandRequest1.json b/example/toShip1-CLICommandRequest1.json index 4ce7ddd..4a6a30c 100644 --- a/example/toShip1-CLICommandRequest1.json +++ b/example/toShip1-CLICommandRequest1.json @@ -3,7 +3,7 @@ "label":"cli-command-executed-result", "toNode": "ship1", "data": ["bash","-c","sleep 3 & tree ./"], - "method":"REQCLICommand", + "method":"REQCliCommand", "timeout":10, "retries":3, "methodTimeout": 4 diff --git a/startup_processes.go b/startup_processes.go index 28942df..a3c8b7c 100644 --- a/startup_processes.go +++ b/startup_processes.go @@ -95,12 +95,12 @@ func (s *server) ProcessesStart() { } } - // Start a subscriber for REQCLICommand messages - if s.configuration.StartSubREQCLICommand.OK { + // Start a subscriber for REQCliCommand messages + if s.configuration.StartSubREQCliCommand.OK { { fmt.Printf("Starting CLICommand Request subscriber: %#v\n", s.nodeName) - sub := newSubject(REQCLICommand, s.nodeName) - proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQCLICommand.Values, nil) + sub := newSubject(REQCliCommand, s.nodeName) + proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQCliCommand.Values, nil) go proc.spawnWorker(s) } } diff --git a/subscriber_method_types.go b/subscriber_method_types.go index eefd98a..b9253d5 100644 --- a/subscriber_method_types.go +++ b/subscriber_method_types.go @@ -60,7 +60,7 @@ const ( // as a new message. // The data field is a slice of strings where the first string // value should be the command, and the following the arguments. - REQCLICommand Method = "REQCLICommand" + REQCliCommand Method = "REQCliCommand" // Execute a CLI command in for example bash or cmd. // This is an event type, where a message will be sent to a // node with the command to execute and an ACK will be replied @@ -116,7 +116,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable { REQOpCommand: methodREQOpCommand{ commandOrEvent: CommandACK, }, - REQCLICommand: methodREQCLICommand{ + REQCliCommand: methodREQCliCommand{ commandOrEvent: CommandACK, }, CLICommandRequestNOSEQ: methodCLICommandRequestNOSEQ{ @@ -391,18 +391,18 @@ func (m methodEchoReply) handler(proc process, message Message, node string) ([] // --- -type methodREQCLICommand struct { +type methodREQCliCommand struct { commandOrEvent CommandOrEvent } -func (m methodREQCLICommand) getKind() CommandOrEvent { +func (m methodREQCliCommand) getKind() CommandOrEvent { return m.commandOrEvent } // handler to run a CLI command with timeout context. The handler will // return the output of the command run back to the calling publisher // as a new message. -func (m methodREQCLICommand) handler(proc process, message Message, node string) ([]byte, error) { +func (m methodREQCliCommand) handler(proc process, message Message, node string) ([]byte, error) { log.Printf("<--- CLICommandREQUEST received from: %v, containing: %v", message.FromNode, message.Data) // Execute the CLI command in it's own go routine, so we are able