mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
renamed message timeout field to ACKTimeout
This commit is contained in:
parent
aa1fbbeb3b
commit
8efecdb18e
14 changed files with 31 additions and 31 deletions
16
README.md
16
README.md
|
@ -11,7 +11,7 @@ Command And Control anything like Servers, Containers, VM's or other by creating
|
|||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
"timeout":10,
|
||||
"ACKTimeout":10,
|
||||
"retries":3,
|
||||
"methodTimeout": 4
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ method
|
|||
// you can override it setting your own here.
|
||||
replyMethod
|
||||
// Initial message Reply ACK wait timeout
|
||||
timeout
|
||||
ACKTimeout
|
||||
// Normal Resend retries
|
||||
retries
|
||||
// The ACK timeout of the new message created via a request event.
|
||||
|
@ -357,7 +357,7 @@ Example JSON for appending a message of type command into the `socket` file
|
|||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
"timeout":10,
|
||||
"ACKTimeout":10,
|
||||
"retries":3,
|
||||
"methodTimeout": 4
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ To specify more messages at once do
|
|||
"toNode": "ship1",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
"timeout":10,
|
||||
"ACKTimeout":10,
|
||||
"retries":3,
|
||||
"methodTimeout": 4
|
||||
},
|
||||
|
@ -382,7 +382,7 @@ To specify more messages at once do
|
|||
"toNode": "ship2",
|
||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
"timeout":10,
|
||||
"ACKTimeout":10,
|
||||
"retries":3,
|
||||
"methodTimeout": 4
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ To send a Op Command message for process listing with custom timeout and amount
|
|||
"operation":{
|
||||
"opCmd":"ps"
|
||||
},
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"replyTimeout":3,
|
||||
"replyRetries":3,
|
||||
|
@ -429,7 +429,7 @@ To send and Op Command to stop a subscriber on a node
|
|||
"receivingNode": "ship2"
|
||||
}
|
||||
},
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"replyTimeout":3,
|
||||
"replyRetries":3,
|
||||
|
@ -455,7 +455,7 @@ To send and Op Command to start a subscriber on a node
|
|||
"allowedNodes": ["central","node1"]
|
||||
}
|
||||
},
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"replyTimeout":3,
|
||||
"replyRetries":3,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"data": ["bash","-c","sleep 5 & tree ./"],
|
||||
"method":"REQCliCommand",
|
||||
"replyMethod":"REQToFileAppend",
|
||||
"timeout":5,
|
||||
"ACKTimeout":5,
|
||||
"retries":3,
|
||||
"replyTimeout":5,
|
||||
"replyRetries":3,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"data": ["http://vg.no"],
|
||||
"method":"REQHttpGet",
|
||||
"replyMethod":"REQToFile",
|
||||
"timeout":5,
|
||||
"ACKTimeout":5,
|
||||
"retries":3,
|
||||
"methodTimeout": 5
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"toNode": "ship1",
|
||||
"data": [""],
|
||||
"method":"REQPing",
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"methodTimeout": 10
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"data": ["bash","-c","tree ../"],
|
||||
"replyMethod":"REQToFileAppend",
|
||||
"method":"REQnCliCommand",
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"methodTimeout": 10
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"data": ["http://erter.org"],
|
||||
"method":"REQHttpGet",
|
||||
"replyMethod":"REQToFile",
|
||||
"timeout":5,
|
||||
"ACKTimeout":5,
|
||||
"retries":3,
|
||||
"methodTimeout": 5
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
}
|
||||
},
|
||||
"replyMethod":"REQToFileAppend",
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"replyTimeout":3,
|
||||
"replyRetries":3,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
},
|
||||
"replyMethod":"REQToFileAppend",
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"replyTimeout":3,
|
||||
"replyRetries":3,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"opCmd":"ps"
|
||||
},
|
||||
"replyMethod":"REQToFileAppend",
|
||||
"timeout":3,
|
||||
"ACKTimeout":3,
|
||||
"retries":3,
|
||||
"replyTimeout":3,
|
||||
"replyRetries":3,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"toNode": "ship2",
|
||||
"data": ["./test.log"],
|
||||
"method":"REQTailFile",
|
||||
"timeout":5,
|
||||
"ACKTimeout":5,
|
||||
"retries":3,
|
||||
"methodTimeout": 200
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ type Message struct {
|
|||
ReplyMethod Method `json:"replyMethod" yaml:"replyMethod"`
|
||||
// From what node the message originated
|
||||
FromNode node
|
||||
// Normal Reply wait timeout
|
||||
Timeout int `json:"timeout" yaml:"timeout"`
|
||||
// Normal Resend retries
|
||||
// ACKTimeout for waiting for an ack message
|
||||
ACKTimeout int `json:"ACKTimeout" yaml:"ACKTimeout"`
|
||||
// Resend retries
|
||||
Retries int `json:"retries" yaml:"retries"`
|
||||
// The timeout of the new message created via a request event.
|
||||
// The ACK timeout of the new message created via a request event.
|
||||
ReplyTimeout int `json:"replyTimeout" yaml:"replyTimeout"`
|
||||
// The retries of the new message created via a request event.
|
||||
ReplyRetries int `json:"replyRetries" yaml:"replyRetries"`
|
||||
|
|
|
@ -240,17 +240,17 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
|
|||
// reply, and if it is not we don't wait here at all.
|
||||
// fmt.Printf("info: messageDeliverNats: preparing to send message: %v\n", message)
|
||||
if p.subject.CommandOrEvent == CommandACK || p.subject.CommandOrEvent == EventACK {
|
||||
// Wait up until timeout specified for a reply,
|
||||
// Wait up until ACKTimeout specified for a reply,
|
||||
// continue and resend if noo reply received,
|
||||
// or exit if max retries for the message reached.
|
||||
msgReply, err := subReply.NextMsg(time.Second * time.Duration(message.Timeout))
|
||||
msgReply, err := subReply.NextMsg(time.Second * time.Duration(message.ACKTimeout))
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subReply.NextMsg failed for node=%v, subject=%v: %v", p.node, p.subject.name(), err)
|
||||
sendErrorLogMessage(p.toRingbufferCh, message.FromNode, er)
|
||||
|
||||
// did not receive a reply, decide what to do..
|
||||
retryAttempts++
|
||||
fmt.Printf("Retry attempts:%v, retries: %v, timeout: %v\n", retryAttempts, message.Retries, message.Timeout)
|
||||
fmt.Printf("Retry attempts:%v, retries: %v, ACKTimeout: %v\n", retryAttempts, message.Retries, message.ACKTimeout)
|
||||
switch {
|
||||
case message.Retries == 0:
|
||||
// 0 indicates unlimited retries
|
||||
|
|
|
@ -124,8 +124,8 @@ func (r *ringBuffer) fillBuffer(inCh chan subjectAndMessage, samValueBucket stri
|
|||
}
|
||||
|
||||
// Check if message values for timers override default values
|
||||
if v.Message.Timeout < 1 {
|
||||
v.Message.Timeout = defaultMessageTimeout
|
||||
if v.Message.ACKTimeout < 1 {
|
||||
v.Message.ACKTimeout = defaultMessageTimeout
|
||||
}
|
||||
if v.Message.Retries < 1 {
|
||||
v.Message.Retries = defaultMessageRetries
|
||||
|
|
|
@ -405,11 +405,11 @@ func newReplyMessage(proc process, message Message, outData []byte) {
|
|||
// Create a new message for the reply, and put it on the
|
||||
// ringbuffer to be published.
|
||||
newMsg := Message{
|
||||
ToNode: message.FromNode,
|
||||
Data: []string{string(outData)},
|
||||
Method: message.ReplyMethod,
|
||||
Timeout: message.ReplyTimeout,
|
||||
Retries: message.ReplyRetries,
|
||||
ToNode: message.FromNode,
|
||||
Data: []string{string(outData)},
|
||||
Method: message.ReplyMethod,
|
||||
ACKTimeout: message.ReplyTimeout,
|
||||
Retries: message.ReplyRetries,
|
||||
|
||||
// Put in a copy of the initial request message, so we can use it's properties if
|
||||
// needed to for example create the file structure naming on the subscriber.
|
||||
|
|
Loading…
Reference in a new issue