func (q *Queue) Fix(name string, when time.Time, later bool) error {
	q.lock.Lock()
	defer q.lock.Unlock()
	defer q.rouse()
	it, ok := q.items[name]
	if !ok {
		return errors.New("not found")
	}
	log := logrus.WithFields(logrus.Fields{
		"group": name,
		"when":  when,
	})
	if when.Before(it.when) {
		log = log.WithField("reduced minutes", it.when.Sub(when).Round(time.Second).Minutes())
	} else if later && !when.Equal(it.when) {
		log = log.WithField("delayed minutes", when.Sub(it.when).Round(time.Second).Minutes())
	} else {
		return nil
	}
	it.when = when
	heap.Fix(&q.queue, it.index)
	log.Info("Fixed names")
	return nil
}
Fix the next time to send the group to receivers.

If later is set then it will move out the next update time, otherwise
it will only reduce it.
package util
import (
	"container/heap"
	"context"
	"errors"
	"fmt"
	"sync"
	"time"
	"github.com/sirupsen/logrus"
)
type Queue struct {
	queue  priorityQueue
	items  map[string]*item
	lock   sync.RWMutex
	signal chan struct{}
}
func (q *Queue) Init(names []string, when time.Time) {
	n := len(names)
	found := make(map[string]bool, n)
	q.lock.Lock()
	defer q.lock.Unlock()
	defer q.rouse()
	if q.signal == nil {
		q.signal = make(chan struct{})
	}
	if q.items == nil {
		q.items = make(map[string]*item, n)
	}
	if q.queue == nil {
		q.queue = make(priorityQueue, 0, n)
	}
	items := q.items
	for _, name := range names {
		found[name] = true
		if _, ok := items[name]; ok {
			continue
		}
		it := &item{
			name:  name,
			when:  when,
			index: len(q.queue),
		}
		heap.Push(&q.queue, it)
		items[name] = it
		logrus.WithFields(logrus.Fields{
			"when": when,
			"name": name,
		}).Info("Adding name to queue")
	}
	for name, it := range items {
		if found[name] {
			continue
		}
		logrus.WithField("name", name).Info("Removing name from queue")
		heap.Remove(&q.queue, it.index)
		delete(q.items, name)
	}
}
func (q *Queue) FixAll(whens map[string]time.Time, later bool) error {
	q.lock.Lock()
	defer q.lock.Unlock()
	var missing []string
	defer q.rouse()
	reduced := map[string]time.Time{}
	fixed := map[string]time.Time{}
	for name, when := range whens {
		it, ok := q.items[name]
		if !ok {
			missing = append(missing, name)
			continue
		}
		if when.Before(it.when) {
			reduced[name] = when
		} else if later && !when.Equal(it.when) {
			fixed[name] = when
		} else {
			continue
		}
		it.when = when
	}
	var log logrus.FieldLogger = logrus.New()
	var any bool
	if n := len(reduced); n > 0 {
		log = log.WithField("reduced", n)
		any = true
	}
	if n := len(fixed); n > 0 {
		log = log.WithField("fixed", n)
		any = true
	}
	heap.Init(&q.queue)
	if len(missing) > 0 {
		return fmt.Errorf("not found: %v", missing)
	}
	if any {
		log.Info("Fixed all names")
	}
	return nil
}