mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-05 06:46:48 +00:00
rename REQTextToFile to REQToFile
This commit is contained in:
parent
dba69fd90c
commit
08f6f21691
7 changed files with 22 additions and 17 deletions
|
@ -107,7 +107,7 @@ type Configuration struct {
|
|||
// Subscriber for text logging
|
||||
StartSubREQToFileAppend flagNodeSlice
|
||||
// Subscriber for writing to file
|
||||
StartSubREQTextToFile flagNodeSlice
|
||||
StartSubREQToFile flagNodeSlice
|
||||
// Subscriber for Echo Request
|
||||
StartSubREQPing flagNodeSlice
|
||||
// Subscriber for Echo Reply
|
||||
|
@ -146,7 +146,7 @@ func newConfigurationDefaults() Configuration {
|
|||
StartSubREQErrorLog: flagNodeSlice{Values: []node{}},
|
||||
StartSubREQHello: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
StartSubREQToFileAppend: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
StartSubREQTextToFile: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
StartSubREQToFile: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
StartSubREQPing: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
StartSubREQPong: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||
|
@ -189,7 +189,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.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.StartSubREQToFile, "startSubREQToFile", "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.")
|
||||
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.")
|
||||
|
|
|
@ -41,7 +41,7 @@ SubscribersDataFolder = "./var"
|
|||
OK = true
|
||||
Values = ["*"]
|
||||
|
||||
[StartSubREQTextToFile]
|
||||
[StartSubREQToFile]
|
||||
OK = true
|
||||
Values = ["*"]
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"toNode": "ship1",
|
||||
"data": ["http://vg.no"],
|
||||
"method":"REQHttpGet",
|
||||
"replyMethod":"REQTextToFile",
|
||||
"replyMethod":"REQToFile",
|
||||
"timeout":5,
|
||||
"retries":3,
|
||||
"methodTimeout": 5
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"toNode": "ship2",
|
||||
"data": ["http://erter.org"],
|
||||
"method":"REQHttpGet",
|
||||
"replyMethod":"REQTextToFile",
|
||||
"replyMethod":"REQToFile",
|
||||
"timeout":5,
|
||||
"retries":3,
|
||||
"methodTimeout": 5
|
||||
|
|
|
@ -257,7 +257,7 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
|
|||
continue
|
||||
case retryAttempts >= message.Retries:
|
||||
// max retries reached
|
||||
er := fmt.Errorf("info: max retries for message reached, breaking out: %v", message)
|
||||
er := fmt.Errorf("info: max retries for message reached, check if node is up and running and if it got a subscriber for the given REQ type, breaking out: %v", message)
|
||||
sendErrorLogMessage(p.toRingbufferCh, message.FromNode, er)
|
||||
return
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ func (p process) ProcessesStart() {
|
|||
}
|
||||
|
||||
// Start a subscriber for text to file messages
|
||||
if p.configuration.StartSubREQTextToFile.OK {
|
||||
p.startup.subREQTextToFile(p)
|
||||
if p.configuration.StartSubREQToFile.OK {
|
||||
p.startup.subREQToFile(p)
|
||||
}
|
||||
|
||||
// Start a subscriber for Hello messages
|
||||
|
@ -227,10 +227,10 @@ func (s startup) subREQHello(p process) {
|
|||
go proc.spawnWorker(p.processes, p.natsConn)
|
||||
}
|
||||
|
||||
func (s startup) subREQTextToFile(p process) {
|
||||
func (s startup) subREQToFile(p process) {
|
||||
fmt.Printf("Starting text to file subscriber: %#v\n", p.node)
|
||||
sub := newSubject(REQTextToFile, string(p.node))
|
||||
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQTextToFile.Values, nil)
|
||||
sub := newSubject(REQToFile, string(p.node))
|
||||
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQToFile.Values, nil)
|
||||
// fmt.Printf("*** %#v\n", proc)
|
||||
go proc.spawnWorker(p.processes, p.natsConn)
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ const (
|
|||
// the receiving end.
|
||||
// The data field is a slice of strings where the values of the
|
||||
// slice will be written to the file.
|
||||
REQTextToFile Method = "REQTextToFile"
|
||||
REQToFile Method = "REQToFile"
|
||||
// Send Hello I'm here message.
|
||||
REQHello Method = "REQHello"
|
||||
// Error log methods to centralError node.
|
||||
|
@ -149,7 +149,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
|
|||
REQToFileAppend: methodREQToFileAppend{
|
||||
commandOrEvent: EventACK,
|
||||
},
|
||||
REQTextToFile: methodREQTextToFile{
|
||||
REQToFile: methodREQToFile{
|
||||
commandOrEvent: EventACK,
|
||||
},
|
||||
REQHello: methodREQHello{
|
||||
|
@ -389,6 +389,11 @@ func (m methodREQOpCommand) handler(proc process, message Message, nodeName stri
|
|||
// Create a new message for the reply containing the output of the
|
||||
// action executed put in outData, and put it on the ringbuffer to
|
||||
// be published.
|
||||
// The method to use for the reply message should initially be
|
||||
// specified within the first message as the replyMethod, and we will
|
||||
// pick up that value here, and use it as the method for the new
|
||||
// request message. If no replyMethod is set we default to the
|
||||
// REQToFileAppend method type.
|
||||
func newReplyMessage(proc process, message Message, outData []byte) {
|
||||
|
||||
// If no replyMethod is set we default to writing to writing to
|
||||
|
@ -481,15 +486,15 @@ func (m methodREQToFileAppend) handler(proc process, message Message, node strin
|
|||
|
||||
// -----
|
||||
|
||||
type methodREQTextToFile struct {
|
||||
type methodREQToFile struct {
|
||||
commandOrEvent CommandOrEvent
|
||||
}
|
||||
|
||||
func (m methodREQTextToFile) getKind() CommandOrEvent {
|
||||
func (m methodREQToFile) getKind() CommandOrEvent {
|
||||
return m.commandOrEvent
|
||||
}
|
||||
|
||||
func (m methodREQTextToFile) handler(proc process, message Message, node string) ([]byte, error) {
|
||||
func (m methodREQToFile) 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.
|
||||
|
|
Loading…
Add table
Reference in a new issue