diff --git a/sqs/sqs.go b/sqs/sqs.go index 0d0259ff033a771a50034fe9cca477a5cc87eb3d..c1d86191627ad38134c3740e32c5370d5af4026f 100644 --- a/sqs/sqs.go +++ b/sqs/sqs.go @@ -6,10 +6,12 @@ import ( "context" "encoding/json" "fmt" - "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/utils" "io" + "sync" "time" + "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/utils" + "github.com/google/uuid" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/s3" @@ -108,7 +110,10 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre func SendSQSMessage(msgr Messenger, objectToSend interface{}, currentRequestID *string, sqsType string, isDebug bool) error { if isDebug { + var wg sync.WaitGroup + wg.Add(1) go func() { + defer wg.Done() if msgr.DelaySeconds != nil { delay := *msgr.DelaySeconds time.Sleep(time.Second * time.Duration(delay)) @@ -118,6 +123,7 @@ func SendSQSMessage(msgr Messenger, objectToSend interface{}, currentRequestID * Post("http://127.0.0.1:3000/sqs/" + sqsType) }() time.Sleep(time.Second * 1) + wg.Wait() return nil }