1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-04-09 10:24:17 +00:00

Renamed CLICommandRequest to StartSubREQCLICommand

This commit is contained in:
postmannen 2021-04-04 11:09:02 +02:00
parent 32c70dbc59
commit 3fbc333b81
5 changed files with 17 additions and 17 deletions

View file

@ -108,7 +108,7 @@ type Configuration struct {
// Subscriber for Echo Reply
StartSubEchoReply flagNodeSlice
// Subscriber for CLICommandRequest
StartSubCLICommandRequest 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{"*"}},
StartSubCLICommandRequest: 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.StartSubCLICommandRequest, "startSubCLICommandRequest", "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.")

View file

@ -13,10 +13,6 @@ SubscribersDataFolder = "./data"
OK = true
Values = ["*"]
[StartSubCLICommandRequest]
OK = true
Values = ["*"]
[StartSubCLICommandRequestNOSEQ]
OK = true
Values = ["*"]
@ -33,6 +29,10 @@ SubscribersDataFolder = "./data"
OK = true
Values = ["*"]
[StartSubREQCLICommand]
OK = true
Values = ["*"]
[StartSubSayHello]
OK = true
Values = ["*"]

View file

@ -3,7 +3,7 @@
"label":"cli-command-executed-result",
"toNode": "ship1",
"data": ["bash","-c","sleep 3 & tree ./"],
"method":"CLICommandRequest",
"method":"REQCLICommand",
"timeout":10,
"retries":3,
"methodTimeout": 4

View file

@ -95,12 +95,12 @@ func (s *server) ProcessesStart() {
}
}
// Start a subscriber for CLICommandRequest messages
if s.configuration.StartSubCLICommandRequest.OK {
// Start a subscriber for REQCLICommand messages
if s.configuration.StartSubREQCLICommand.OK {
{
fmt.Printf("Starting CLICommand Request subscriber: %#v\n", s.nodeName)
sub := newSubject(CLICommandRequest, s.nodeName)
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubCLICommandRequest.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)
}
}

View file

@ -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.
CLICommandRequest Method = "CLICommandRequest"
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,
},
CLICommandRequest: methodCLICommandRequest{
REQCLICommand: methodREQCLICommand{
commandOrEvent: CommandACK,
},
CLICommandRequestNOSEQ: methodCLICommandRequestNOSEQ{
@ -391,18 +391,18 @@ func (m methodEchoReply) handler(proc process, message Message, node string) ([]
// ---
type methodCLICommandRequest struct {
type methodREQCLICommand struct {
commandOrEvent CommandOrEvent
}
func (m methodCLICommandRequest) 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 methodCLICommandRequest) 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