mirror of
https://github.com/postmannen/ctrl.git
synced 2025-01-18 21:59:30 +00:00
added isReply to message structure
This commit is contained in:
parent
8d0b4420c9
commit
a1fbdffd36
2 changed files with 14 additions and 0 deletions
|
@ -40,6 +40,13 @@ type Message struct {
|
||||||
// shell command to execute in a cli session.
|
// shell command to execute in a cli session.
|
||||||
// TODO:
|
// TODO:
|
||||||
ReplyMethodArgs []string `json:"replyMethodArgs" yaml:"replyMethodArgs"`
|
ReplyMethodArgs []string `json:"replyMethodArgs" yaml:"replyMethodArgs"`
|
||||||
|
// IsReply are used to tell that this is a reply message. By default
|
||||||
|
// the system sends the output of a request method back to the node
|
||||||
|
// the message originated from. If it is a reply method we want the
|
||||||
|
// result of the reply message to be sent to the central server, so
|
||||||
|
// we can use this value if set to swap the toNode, and fromNode
|
||||||
|
// fields.
|
||||||
|
IsReply bool `json:"isReply" yaml:"isReply"`
|
||||||
// From what node the message originated
|
// From what node the message originated
|
||||||
FromNode Node
|
FromNode Node
|
||||||
// ACKTimeout for waiting for an ack message
|
// ACKTimeout for waiting for an ack message
|
||||||
|
|
|
@ -282,6 +282,7 @@ func newReplyMessage(proc process, message Message, outData []byte) {
|
||||||
Method: message.ReplyMethod,
|
Method: message.ReplyMethod,
|
||||||
MethodArgs: message.ReplyMethodArgs,
|
MethodArgs: message.ReplyMethodArgs,
|
||||||
MethodTimeout: message.ReplyMethodTimeout,
|
MethodTimeout: message.ReplyMethodTimeout,
|
||||||
|
IsReply: true,
|
||||||
ACKTimeout: message.ReplyACKTimeout,
|
ACKTimeout: message.ReplyACKTimeout,
|
||||||
Retries: message.ReplyRetries,
|
Retries: message.ReplyRetries,
|
||||||
Directory: message.Directory,
|
Directory: message.Directory,
|
||||||
|
@ -1141,6 +1142,12 @@ func (m methodREQCliCommand) handler(proc process, message Message, node string)
|
||||||
case out := <-outCh:
|
case out := <-outCh:
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
|
// If this is this a reply message swap the toNode and fromNode
|
||||||
|
// fields so the output of the command are sent to central node.
|
||||||
|
if message.IsReply {
|
||||||
|
message.ToNode, message.FromNode = message.FromNode, message.ToNode
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare and queue for sending a new message with the output
|
// Prepare and queue for sending a new message with the output
|
||||||
// of the action executed.
|
// of the action executed.
|
||||||
newReplyMessage(proc, message, out)
|
newReplyMessage(proc, message, out)
|
||||||
|
|
Loading…
Add table
Reference in a new issue