func (dq *deleteQueue) deleteFromPending() {
	dq.Lock()
	defer dq.Unlock()
	n := len(dq.entries)
	if n > awsBatchSizeLimit {
		n = awsBatchSizeLimit
	}
	fails, err := dq.deleteBatch(dq.entries[:n])
	if err != nil {
		dq.svc.Logger("Error deleting batch: %s", err)
		return
	}
	dq.entries = dq.entries[n:]
	if len(fails) > 0 {
		dq.entries = append(dq.entries, fails...)
	}
}
deleteFromPending prepares a batch of messages and deletes them
package sqsconsumer
import (
	"sync"
	"time"
	"github.com/aws/aws-sdk-go/service/sqs"
	"golang.org/x/net/context"
)
type deleteQueue struct {
	queue chan *sqs.Message
	sync.Mutex
	entries []*sqs.DeleteMessageBatchRequestEntry
	svc                 *SQSService
	drainTimeout        time.Duration
	accumulationTimeout time.Duration
}
func NewBatchDeleter(ctx context.Context, wg *sync.WaitGroup, s *SQSService, every, drainTimeout time.Duration) chan<- *sqs.Message {
	dq := &deleteQueue{
		svc:                 s,
		accumulationTimeout: every,
		drainTimeout:        drainTimeout,
		queue:               make(chan *sqs.Message),
	}
	wg.Add(1)
	go dq.start(ctx, wg)
	return dq.queue
}
func (dq *deleteQueue) addToPendingDeletes(msg *sqs.Message) {
	dq.Lock()
	defer dq.Unlock()
	for _, e := range dq.entries {
		if *msg.MessageId == *e.Id {
			return
		}
	}
	dq.entries = append(dq.entries, &sqs.DeleteMessageBatchRequestEntry{
		Id:            msg.MessageId,
		ReceiptHandle: msg.ReceiptHandle,
	})
}
func (dq *deleteQueue) deleteBatch(msgs []*sqs.DeleteMessageBatchRequestEntry) ([]*sqs.DeleteMessageBatchRequestEntry, error) {
	req := &sqs.DeleteMessageBatchInput{
		QueueUrl: dq.svc.URL,
		Entries:  msgs,
	}
	resp, err := dq.svc.Svc.DeleteMessageBatch(req)
	if err != nil {
		dq.svc.Logger("Error deleting messages: %s", err)
		return nil, err
	}
	var failed []*sqs.DeleteMessageBatchRequestEntry
	for _, f := range resp.Failed {
		for _, m := range msgs {
			if *m.Id == *f.Id {
				failed = append(failed, m)
				break
			}
		}
	}
	return failed, nil
}