1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

Renamed CLICommandRequestNOSEQ to REQnCliCommand

This commit is contained in:
postmannen 2021-04-05 06:54:18 +02:00
parent 4a7f1fff43
commit debd146f28
7 changed files with 38 additions and 37 deletions

View file

@ -96,6 +96,7 @@ type Configuration struct {
SubscribersDataFolder string
// central node to receive messages published from nodes
CentralNodeName string
// Start the central error logger.
// Takes a comma separated string of nodes to receive from or "*" for all nodes.
StartSubErrorLog flagNodeSlice
@ -109,8 +110,8 @@ type Configuration struct {
StartSubEchoReply flagNodeSlice
// Subscriber for CLICommandRequest
StartSubREQCliCommand flagNodeSlice
// Subscriber for CLICommandRequestNOSEQ
StartSubCLICommandRequestNOSEQ flagNodeSlice
// Subscriber for REQnCliCommand
StartSubREQnCliCommand flagNodeSlice
// Subscriber for CLICommandReply
StartSubCLICommandReply flagNodeSlice
}
@ -123,23 +124,23 @@ func NewConfiguration() *Configuration {
// Default configuration
func newConfigurationDefaults() Configuration {
c := Configuration{
ConfigFolder: "./etc",
BrokerAddress: "127.0.0.1:4222",
ProfilingPort: "",
PromHostAndPort: "",
DefaultMessageTimeout: 10,
DefaultMessageRetries: 1,
StartPubSayHello: 30,
SubscribersDataFolder: "./data",
CentralNodeName: "",
StartSubErrorLog: flagNodeSlice{Values: []node{}},
StartSubSayHello: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubTextLogging: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubEchoRequest: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubEchoReply: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubCLICommandRequestNOSEQ: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubCLICommandReply: flagNodeSlice{OK: true, Values: []node{"*"}},
ConfigFolder: "./etc",
BrokerAddress: "127.0.0.1:4222",
ProfilingPort: "",
PromHostAndPort: "",
DefaultMessageTimeout: 10,
DefaultMessageRetries: 1,
StartPubSayHello: 30,
SubscribersDataFolder: "./data",
CentralNodeName: "",
StartSubErrorLog: flagNodeSlice{Values: []node{}},
StartSubSayHello: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubTextLogging: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubEchoRequest: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubEchoReply: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubREQnCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
StartSubCLICommandReply: flagNodeSlice{OK: true, Values: []node{"*"}},
}
return c
}
@ -177,7 +178,7 @@ func (c *Configuration) CheckFlags() error {
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.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.StartSubREQnCliCommand, "startSubREQnCliCommand", "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.")
flag.Parse()

View file

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

View file

@ -3,9 +3,9 @@
"toNode": "ship1",
"data": ["bash","-c","tree ../"],
"method":"CLICommandRequestNOSEQ",
"timeout":10,
"method":"REQnCliCommand",
"timeout":3,
"retries":3,
"methodTimeout": 0
"methodTimeout": 10
}
]

View file

@ -105,12 +105,12 @@ func (s *server) ProcessesStart() {
}
}
// Start a subscriber for CLICommandRequestNOSEQ messages
if s.configuration.StartSubCLICommandRequestNOSEQ.OK {
// Start a subscriber for Not In Order Cli Command Request messages
if s.configuration.StartSubREQnCliCommand.OK {
{
fmt.Printf("Starting CLICommand NOSEQ Request subscriber: %#v\n", s.nodeName)
sub := newSubject(CLICommandRequestNOSEQ, s.nodeName)
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubCLICommandRequestNOSEQ.Values, nil)
fmt.Printf("Starting CLICommand Not Sequential Request subscriber: %#v\n", s.nodeName)
sub := newSubject(REQnCliCommand, s.nodeName)
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQnCliCommand.Values, nil)
go proc.spawnWorker(s)
}
}

View file

@ -72,7 +72,7 @@ const (
// done. No order are preserved.
// The data field is a slice of strings where the first string
// value should be the command, and the following the arguments.
CLICommandRequestNOSEQ Method = "CLICommandRequestNOSEQ"
REQnCliCommand Method = "REQnCliCommand"
// Will generate a reply for a CLICommandRequest.
// This type is normally not used by the user when creating
// a message. It is used in creating the reply message with
@ -119,7 +119,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
REQCliCommand: methodREQCliCommand{
commandOrEvent: CommandACK,
},
CLICommandRequestNOSEQ: methodCLICommandRequestNOSEQ{
REQnCliCommand: methodREQnCliCommand{
commandOrEvent: CommandACK,
},
CLICommandReply: methodCLICommandReply{
@ -447,11 +447,11 @@ func (m methodREQCliCommand) handler(proc process, message Message, node string)
// --- methodCLICommandRequestNOSEQ
type methodCLICommandRequestNOSEQ struct {
type methodREQnCliCommand struct {
commandOrEvent CommandOrEvent
}
func (m methodCLICommandRequestNOSEQ) getKind() CommandOrEvent {
func (m methodREQnCliCommand) getKind() CommandOrEvent {
return m.commandOrEvent
}
@ -461,7 +461,7 @@ func (m methodCLICommandRequestNOSEQ) getKind() CommandOrEvent {
// The NOSEQ method will process messages as they are recived,
// and the reply back will be sent as soon as the process is
// done. No order are preserved.
func (m methodCLICommandRequestNOSEQ) handler(proc process, message Message, node string) ([]byte, error) {
func (m methodREQnCliCommand) handler(proc process, message Message, node string) ([]byte, error) {
log.Printf("<--- CLICommand REQUEST received from: %v, containing: %v", message.FromNode, message.Data)
// Execute the CLI command in it's own go routine, so we are able