mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
added initial REQ for GroupCommandsDeleteCommand
This commit is contained in:
parent
a9ae982ed6
commit
7241c65a15
3 changed files with 85 additions and 2 deletions
|
@ -180,6 +180,7 @@ func (p *processes) Start(proc process) {
|
||||||
proc.startup.subREQAclGroupNodesDeleteNode(proc)
|
proc.startup.subREQAclGroupNodesDeleteNode(proc)
|
||||||
proc.startup.subREQAclGroupNodesDeleteGroup(proc)
|
proc.startup.subREQAclGroupNodesDeleteGroup(proc)
|
||||||
proc.startup.subREQAclGroupCommandsAddCommand(proc)
|
proc.startup.subREQAclGroupCommandsAddCommand(proc)
|
||||||
|
proc.startup.subREQAclGroupCommandsDeleteCommand(proc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if proc.configuration.StartSubREQPublicKeysToNode {
|
if proc.configuration.StartSubREQPublicKeysToNode {
|
||||||
|
@ -431,6 +432,13 @@ func (s startup) subREQAclGroupCommandsAddCommand(p process) {
|
||||||
go proc.spawnWorker()
|
go proc.spawnWorker()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s startup) subREQAclGroupCommandsDeleteCommand(p process) {
|
||||||
|
log.Printf("Starting Acl delete command from command group subscriber: %#v\n", p.node)
|
||||||
|
sub := newSubject(REQAclGroupCommandsDeleteCommand, string(p.node))
|
||||||
|
proc := newProcess(p.ctx, s.server, sub, processKindSubscriber, nil)
|
||||||
|
go proc.spawnWorker()
|
||||||
|
}
|
||||||
|
|
||||||
func (s startup) subREQToConsole(p process) {
|
func (s startup) subREQToConsole(p process) {
|
||||||
log.Printf("Starting Text To Console subscriber: %#v\n", p.node)
|
log.Printf("Starting Text To Console subscriber: %#v\n", p.node)
|
||||||
sub := newSubject(REQToConsole, string(p.node))
|
sub := newSubject(REQToConsole, string(p.node))
|
||||||
|
|
|
@ -140,6 +140,8 @@ const (
|
||||||
REQAclGroupNodesDeleteGroup = "REQAclGroupNodesDeleteGroup"
|
REQAclGroupNodesDeleteGroup = "REQAclGroupNodesDeleteGroup"
|
||||||
// REQAclGroupCommandsAddCommand
|
// REQAclGroupCommandsAddCommand
|
||||||
REQAclGroupCommandsAddCommand = "REQAclGroupCommandsAddCommand"
|
REQAclGroupCommandsAddCommand = "REQAclGroupCommandsAddCommand"
|
||||||
|
// REQAclGroupCommandsDeleteCommand
|
||||||
|
REQAclGroupCommandsDeleteCommand = "REQAclGroupCommandsDeleteCommand"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The mapping of all the method constants specified, what type
|
// The mapping of all the method constants specified, what type
|
||||||
|
@ -251,6 +253,9 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
|
||||||
REQAclGroupCommandsAddCommand: methodREQAclGroupCommandsAddCommand{
|
REQAclGroupCommandsAddCommand: methodREQAclGroupCommandsAddCommand{
|
||||||
event: EventACK,
|
event: EventACK,
|
||||||
},
|
},
|
||||||
|
REQAclGroupCommandsDeleteCommand: methodREQAclGroupCommandsDeleteCommand{
|
||||||
|
event: EventACK,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,8 +444,8 @@ func (m methodREQAclGroupCommandsAddCommand) handler(proc process, message Messa
|
||||||
defer proc.processes.wg.Done()
|
defer proc.processes.wg.Done()
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case len(message.MethodArgs) < 1:
|
case len(message.MethodArgs) < 2:
|
||||||
er := fmt.Errorf("error: methodREQAclGroupCommandsAddCommand: got <1 number methodArgs, want 1")
|
er := fmt.Errorf("error: methodREQAclGroupCommandsAddCommand: got <2 number methodArgs, want 1")
|
||||||
proc.errorKernel.errSend(proc, message, er)
|
proc.errorKernel.errSend(proc, message, er)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -496,3 +496,73 @@ func (m methodREQAclGroupCommandsAddCommand) handler(proc process, message Messa
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
|
type methodREQAclGroupCommandsDeleteCommand struct {
|
||||||
|
event Event
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m methodREQAclGroupCommandsDeleteCommand) getKind() Event {
|
||||||
|
return m.event
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m methodREQAclGroupCommandsDeleteCommand) handler(proc process, message Message, node string) ([]byte, error) {
|
||||||
|
inf := fmt.Errorf("<--- methodREQAclGroupCommandsDeleteCommand received from: %v, containing: %v", message.FromNode, message.MethodArgs)
|
||||||
|
proc.errorKernel.logConsoleOnlyIfDebug(inf, proc.configuration)
|
||||||
|
|
||||||
|
proc.processes.wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer proc.processes.wg.Done()
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(message.MethodArgs) < 1:
|
||||||
|
er := fmt.Errorf("error: methodREQAclGroupCommandsDeleteCommand: got <1 number methodArgs, want 1")
|
||||||
|
proc.errorKernel.errSend(proc, message, er)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a context with the timeout specified in message.MethodTimeout.
|
||||||
|
ctx, cancel := getContextForMethodTimeout(proc.ctx, message)
|
||||||
|
|
||||||
|
outCh := make(chan []byte)
|
||||||
|
|
||||||
|
proc.processes.wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer proc.processes.wg.Done()
|
||||||
|
|
||||||
|
cg := message.MethodArgs[0]
|
||||||
|
c := message.MethodArgs[1]
|
||||||
|
|
||||||
|
proc.centralAuth.accessLists.groupCommandsDeleteCommand(commandGroup(cg), command(c))
|
||||||
|
|
||||||
|
outString := fmt.Sprintf("deleted command from commandGroup: commandGroup=%v, command=%v\n", cg, c)
|
||||||
|
out := []byte(outString)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case outCh <- out:
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
|
||||||
|
cancel()
|
||||||
|
er := fmt.Errorf("error: methodREQAclGroupCommandsDeleteCommand: method timed out: %v", message.MethodArgs)
|
||||||
|
proc.errorKernel.errSend(proc, message, er)
|
||||||
|
|
||||||
|
case out := <-outCh:
|
||||||
|
|
||||||
|
// Prepare and queue for sending a new message with the output
|
||||||
|
// of the action executed.
|
||||||
|
newReplyMessage(proc, message, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
}()
|
||||||
|
|
||||||
|
ackMsg := []byte("confirmed from: " + node + ": " + fmt.Sprint(message.ID))
|
||||||
|
return ackMsg, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
Loading…
Reference in a new issue