github.com/wfusion/gofusion@v1.1.14/common/infra/watermill/message/router/middleware/instant_ack.go (about)

     1  package middleware
     2  
     3  import (
     4  	"github.com/wfusion/gofusion/common/infra/watermill/message"
     5  )
     6  
     7  // InstantAck makes the handler instantly acknowledge the incoming message, regardless of any errors.
     8  // It may be used to gain throughput, but at a cost:
     9  // If you had exactly-once delivery, you may expect at-least-once instead.
    10  // If you had ordered messages, the ordering might be broken.
    11  func InstantAck(h message.HandlerFunc) message.HandlerFunc {
    12  	return func(message *message.Message) ([]*message.Message, error) {
    13  		message.Ack()
    14  		return h(message)
    15  	}
    16  }