Ejemplo n.º 1
0
func queueCurrSize(key string, q mq.Queue) (int, error) {
	i, err := q.Info()
	if err != nil {
		return 0, err
	}

	return i.Size, err
}
Ejemplo n.º 2
0
func FlatLoad(q *mq.Queue, msgsPerSecond int) {
	msgs := make([]string, 0, msgsPerSecond)
	count := 0
	for {
		go func() {
			for x := 0; x < msgsPerSecond; x++ {
				msgs = append(msgs, fmt.Sprintf("%d", count+x))
			}
			s := time.Now()
			_, err := q.PushStrings(msgs...)
			d := time.Since(s)
			if err != nil {
				log.Fatal(err)
			}
			fmt.Println(d)
			msgs = msgs[:0]
		}()
		count += msgsPerSecond
		time.Sleep(time.Second)
	}
}