mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
methodArgs replaces data as an arg field for methods
This commit is contained in:
parent
903383a529
commit
d653e94ee2
2 changed files with 18 additions and 8 deletions
|
@ -26,10 +26,20 @@ type Message struct {
|
|||
Data []string `json:"data" yaml:"data"`
|
||||
// Method, what request type to use, like REQCliCommand, REQHttpGet..
|
||||
Method Method `json:"method" yaml:"method"`
|
||||
// Additional arguments that might be needed when executing the
|
||||
// method. Can be f.ex. an ip address if it is a tcp sender, or the
|
||||
// shell command to execute in a cli session.
|
||||
// TODO:
|
||||
MethodArgs []string `json:"methodArgs" yaml:"methodArgs"`
|
||||
// ReplyMethod, is the method to use for the reply message.
|
||||
// By default the reply method will be set to log to file, but
|
||||
// you can override it setting your own here.
|
||||
ReplyMethod Method `json:"replyMethod" yaml:"replyMethod"`
|
||||
// Additional arguments that might be needed when executing the reply
|
||||
// method. Can be f.ex. an ip address if it is a tcp sender, or the
|
||||
// shell command to execute in a cli session.
|
||||
// TODO:
|
||||
ReplyMethodArgs []string `json:"replyMethodArgs" yaml:"replyMethodArgs"`
|
||||
// From what node the message originated
|
||||
FromNode Node
|
||||
// ACKTimeout for waiting for an ack message
|
||||
|
|
16
requests.go
16
requests.go
|
@ -858,8 +858,8 @@ func (m methodREQCliCommand) handler(proc process, message Message, node string)
|
|||
go func() {
|
||||
defer proc.processes.wg.Done()
|
||||
|
||||
c := message.Data[0]
|
||||
a := message.Data[1:]
|
||||
c := message.MethodArgs[0]
|
||||
a := message.MethodArgs[1:]
|
||||
|
||||
ctx, cancel := context.WithTimeout(proc.ctx, time.Second*time.Duration(message.MethodTimeout))
|
||||
|
||||
|
@ -938,8 +938,8 @@ func (m methodREQnCliCommand) handler(proc process, message Message, node string
|
|||
go func() {
|
||||
defer proc.processes.wg.Done()
|
||||
|
||||
c := message.Data[0]
|
||||
a := message.Data[1:]
|
||||
c := message.MethodArgs[0]
|
||||
a := message.MethodArgs[1:]
|
||||
|
||||
ctx, cancel := context.WithTimeout(proc.ctx, time.Second*time.Duration(message.MethodTimeout))
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ func (m methodREQHttpGet) handler(proc process, message Message, node string) ([
|
|||
go func() {
|
||||
defer proc.processes.wg.Done()
|
||||
|
||||
url := message.Data[0]
|
||||
url := message.MethodArgs[0]
|
||||
|
||||
client := http.Client{
|
||||
Timeout: time.Second * 5,
|
||||
|
@ -1119,7 +1119,7 @@ func (m methodREQTailFile) handler(proc process, message Message, node string) (
|
|||
go func() {
|
||||
defer proc.processes.wg.Done()
|
||||
|
||||
fp := message.Data[0]
|
||||
fp := message.MethodArgs[0]
|
||||
|
||||
var ctx context.Context
|
||||
var cancel context.CancelFunc
|
||||
|
@ -1205,8 +1205,8 @@ func (m methodREQnCliCommandCont) handler(proc process, message Message, node st
|
|||
go func() {
|
||||
defer proc.processes.wg.Done()
|
||||
|
||||
c := message.Data[0]
|
||||
a := message.Data[1:]
|
||||
c := message.MethodArgs[0]
|
||||
a := message.MethodArgs[1:]
|
||||
|
||||
ctx, cancel := context.WithTimeout(proc.ctx, time.Second*time.Duration(message.MethodTimeout))
|
||||
|
||||
|
|
Loading…
Reference in a new issue