mirror of
https://github.com/postmannen/ctrl.git
synced 2025-01-05 20:09:16 +00:00
fixed calling executeHandler() for startup folder messages
This commit is contained in:
parent
2d76e06274
commit
c8e5dd6904
2 changed files with 84 additions and 72 deletions
|
@ -38,6 +38,7 @@ func (s *server) readStartupFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, filePath := range filePaths {
|
for _, filePath := range filePaths {
|
||||||
|
fmt.Printf("DEBUGDEBUGDEBUGDEBUGDEBUGDEBUGDEBUG: %v\n", filePath)
|
||||||
|
|
||||||
// Read the content of each file.
|
// Read the content of each file.
|
||||||
readBytes, err := func(filePath string) ([]byte, error) {
|
readBytes, err := func(filePath string) ([]byte, error) {
|
||||||
|
@ -107,12 +108,16 @@ func (s *server) readStartupFolder() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = mh.handler(p, sams[i].Message, s.nodeName)
|
p.handler = mh.handler
|
||||||
if err != nil {
|
|
||||||
er := fmt.Errorf("error: subscriberHandler: handler method failed: %v", err)
|
//_, err = mh.handler(p, sams[i].Message, s.nodeName)
|
||||||
p.errorKernel.errSend(p, sams[i].Message, er)
|
//if err != nil {
|
||||||
continue
|
// 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
39
process.go
39
process.go
|
@ -578,6 +578,29 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
||||||
// verified, and if OK the handler is called.
|
// verified, and if OK the handler is called.
|
||||||
func (p process) callHandler(message Message, thisNode string) []byte {
|
func (p process) callHandler(message Message, thisNode string) []byte {
|
||||||
//out := []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
|
var err error
|
||||||
|
|
||||||
// Check if it is a message to run scheduled.
|
// Check if it is a message to run scheduled.
|
||||||
|
@ -596,12 +619,6 @@ func (p process) callHandler(message Message, thisNode string) []byte {
|
||||||
runAsScheduled = true
|
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.
|
// 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)
|
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)
|
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
|
// verifySigOrAclFlag will do signature and/or acl checking based on which of
|
||||||
|
|
Loading…
Reference in a new issue