func dispatch(e env.Vars, r coelho.Rabbit, rk string) { lines := make(chan amqp.Delivery, r.QoS) // set the right routing key // monitor go func() { for { log.Infof("message buffer:%v, used:%v", cap(lines), len(lines)) //dev time.Sleep(30 * time.Second) } }() // Subscribe go func() { for { r.Subscribe(ctx, r.Redial(ctx, e.RabbitMqAddres), lines, rk, &read) } done() }() // process bunchedLines := coelho.Bunch(ctx, lines, 100, 100) go ack(os.Stdout, bunchedLines) <-ctx.Done() }