1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

removed debug printing

This commit is contained in:
postmannen 2021-11-22 08:25:50 +01:00
parent 3b37df638d
commit 38e286ab7d
3 changed files with 0 additions and 32 deletions

View file

@ -328,12 +328,8 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na
// the value of the previous message's RelayFromNode field, so we
// also can send the a copy of the reply back to where it originated.
//fmt.Printf("\n *** DEBUG: process.subscriberHandler: message.previousMessage: %#v \n\n", message.PreviousMessage)
if message.PreviousMessage != nil && message.PreviousMessage.RelayOriginalViaNode != "" {
//fmt.Printf("\n *** DEBUG: process.subscriberHandler: got match on if sentence \n\n")
// make a copy of the message
msgCopy := message
msgCopy.ToNode = msgCopy.PreviousMessage.RelayFromNode

View file

@ -712,7 +712,6 @@ func (m methodREQCopyFileFrom) handler(proc process, message Message, node strin
// Read the file, and put the result on the out channel to be sent when done reading.
proc.processes.wg.Add(1)
go func() {
fmt.Printf(" * DEBUG: beginning of read file go routine\n")
defer proc.processes.wg.Done()
const natsMaxMsgSize = 1000000
@ -736,21 +735,16 @@ func (m methodREQCopyFileFrom) handler(proc process, message Message, node strin
return
}
fmt.Printf(" * DEBUG: before io.ReadAll\n")
b, err := io.ReadAll(fh)
if err != nil {
errCh <- fmt.Errorf("error: methodREQCopyFile: failed to read file: %v, %v", SrcFilePath, err)
return
}
fmt.Printf(" * DEBUG: after io.ReadAll: b contains: %v\n", string(b))
select {
case outCh <- b:
fmt.Printf(" * DEBUG: after io.ReadAll: outCh <- b\n")
case <-ctx.Done():
fmt.Printf(" * DEBUG: after io.ReadAll: ctx.Done\n")
return
}
}()
@ -761,20 +755,15 @@ func (m methodREQCopyFileFrom) handler(proc process, message Message, node strin
// kill all started go routines started by this message.
select {
case <-ctx.Done():
fmt.Printf(" ** DEBUG: got ctx.Done\n")
er := fmt.Errorf("error: methodREQCopyFile: got <-ctx.Done(): %v", message.MethodArgs)
sendErrorLogMessage(proc.configuration, proc.processes.metrics, proc.toRingbufferCh, proc.node, er)
return
case er := <-errCh:
fmt.Printf(" ** DEBUG: received on errCh: <-errCh\n")
sendErrorLogMessage(proc.configuration, proc.processes.metrics, proc.toRingbufferCh, proc.node, er)
return
case out := <-outCh:
fmt.Printf(" ** DEBUG: got data on out channel: case out:=<-outCh\n")
dstDir := filepath.Dir(DstFilePath)
dstFile := filepath.Base(DstFilePath)
@ -800,8 +789,6 @@ func (m methodREQCopyFileFrom) handler(proc process, message Message, node strin
log.Printf("%v\n", er)
}
fmt.Printf(" ** DEBUG: sending SAM: %#v\n", sam)
proc.toRingbufferCh <- []subjectAndMessage{sam}
// TODO: Should we also send a reply message with the result back
@ -810,8 +797,6 @@ func (m methodREQCopyFileFrom) handler(proc process, message Message, node strin
replyData := fmt.Sprintf("info: succesfully read the file %v, and sent the content to %v\n", SrcFilePath, DstNode)
newReplyMessage(proc, message, []byte(replyData))
fmt.Printf(" ** DEBUG: sent reply message\n")
}
}()
@ -902,8 +887,6 @@ func (m methodREQCopyFileTo) handler(proc process, message Message, node string)
// Wait for messages received from the inner go routine.
select {
case <-ctx.Done():
fmt.Printf(" ** DEBUG: got ctx.Done\n")
er := fmt.Errorf("error: methodREQCopyFileTo: got <-ctx.Done(): %v", message.MethodArgs)
sendErrorLogMessage(proc.configuration, proc.processes.metrics, proc.toRingbufferCh, proc.node, er)
return
@ -1633,15 +1616,10 @@ func (m methodREQRelayInitial) getKind() CommandOrEvent {
// Handler to relay messages via a host.
func (m methodREQRelayInitial) handler(proc process, message Message, node string) ([]byte, error) {
// relay the message to the actual host here.
fmt.Printf("********** DEBUG Method RelayInitial 1 ***********\n %#v\n************************\n", message)
message.ToNode = message.RelayOriginalViaNode
message.FromNode = Node(node)
message.Method = REQRelay
fmt.Printf("********** DEBUG Method RelayInitial2 ***********\n %#v\n************************\n", message)
sam, err := newSubjectAndMessage(message)
if err != nil {
er := fmt.Errorf("error: newSubjectAndMessage : %v, message: %v", err, message)
@ -1670,14 +1648,10 @@ func (m methodREQRelay) getKind() CommandOrEvent {
func (m methodREQRelay) handler(proc process, message Message, node string) ([]byte, error) {
// relay the message here to the actual host here.
fmt.Printf("********** DEBUG Method Relay 1 ***********\n %#v\n************************\n", message)
message.ToNode = message.RelayToNode
message.FromNode = Node(node)
message.Method = message.RelayOriginalMethod
fmt.Printf("********** DEBUG Method Relay 2 ***********\n %#v\n************************\n", message)
sam, err := newSubjectAndMessage(message)
if err != nil {
er := fmt.Errorf("error: newSubjectAndMessage : %v, message: %v", err, message)

View file

@ -426,8 +426,6 @@ func (s *server) routeMessagesToProcess(dbFileName string) {
// Check if it is a relay message
if m.RelayViaNode != "" && m.RelayViaNode != Node(s.nodeName) {
fmt.Printf("\n********** DEBUG routeMessagesToProcess ***********\n %#v\n************************\n\n", m)
// Keep the original values.
m.RelayFromNode = m.FromNode
m.RelayToNode = m.ToNode