1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-01-18 21:59:30 +00:00

fixed calling executeHandler() for startup folder messages

This commit is contained in:
postmannen 2022-06-20 13:34:20 +02:00
parent 2d76e06274
commit c8e5dd6904
2 changed files with 84 additions and 72 deletions

View file

@ -38,6 +38,7 @@ func (s *server) readStartupFolder() {
}
for _, filePath := range filePaths {
fmt.Printf("DEBUGDEBUGDEBUGDEBUGDEBUGDEBUGDEBUG: %v\n", filePath)
// Read the content of each file.
readBytes, err := func(filePath string) ([]byte, error) {
@ -107,12 +108,16 @@ func (s *server) readStartupFolder() {
continue
}
_, err = mh.handler(p, sams[i].Message, s.nodeName)
if err != nil {
er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
p.errorKernel.errSend(p, sams[i].Message, er)
continue
}
p.handler = mh.handler
//_, err = mh.handler(p, sams[i].Message, s.nodeName)
//if err != nil {
// er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
// p.errorKernel.errSend(p, sams[i].Message, er)
// continue
//}
executeHandler(p, sams[i].Message, s.nodeName)
}
}

View file

@ -578,6 +578,29 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
// verified, and if OK the handler is called.
func (p process) callHandler(message Message, thisNode string) []byte {
//out := []byte{}
// Call the handler if ACL/signature checking returns true.
// If the handler is to be called in a scheduled manner, we we take care of that too.
go func() {
switch p.verifySigOrAclFlag(message) {
case true:
executeHandler(p, message, thisNode)
case false:
// ACL/Signature checking failed.
er := fmt.Errorf("error: subscriberHandler: ACL were verified not-OK, doing nothing")
p.errorKernel.errSend(p, message, er)
log.Printf("%v\n", er)
}
}()
return []byte{}
}
// executeHandler will call the handler for the Request type defined in the message.
func executeHandler(p process, message Message, thisNode string) {
var err error
// Check if it is a message to run scheduled.
@ -596,12 +619,6 @@ func (p process) callHandler(message Message, thisNode string) []byte {
runAsScheduled = true
}
// Call the handler if ACL/signature checking returns true.
// If the handler is to be called in a scheduled manner, we we take care of that too.
go func() {
switch p.verifySigOrAclFlag(message) {
case true:
// Either ACL were verified OK, or ACL/Signature check was not enabled, so we call the handler.
er := fmt.Errorf("info: subscriberHandler: Either ACL were verified OK, or ACL/Signature check was not enabled, so we call the handler: %v", true)
p.errorKernel.logConsoleOnlyIfDebug(er, p.configuration)
@ -668,16 +685,6 @@ func (p process) callHandler(message Message, thisNode string) []byte {
}
}
}
case false:
// ACL/Signature checking failed.
er := fmt.Errorf("error: subscriberHandler: ACL were verified not-OK, doing nothing")
p.errorKernel.errSend(p, message, er)
log.Printf("%v\n", er)
}
}()
return []byte{}
}
// verifySigOrAclFlag will do signature and/or acl checking based on which of