You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: rabbit.go
    path of file: ./repos/plumber/vendor/github.com/batchcorp/rabbit
    
    the code of the file until where you have to start completion: // Package rabbit is a simple streadway/amqp wrapper library that comes with:
//
// * Auto-reconnect support
//
// * Context support
//
// * Helpers for consuming once or forever and publishing
//
// The library is used internally at https://batch.sh where it powers most of
// the platform's backend services.
//
// For an example, refer to the README.md.
package rabbit


    
func (r *Rabbit) ConsumeOnce(ctx context.Context, runFunc func(msg amqp.Delivery) error) error {
	if r.shutdown {
		return ErrShutdown
	}

	if r.Options.Mode == Producer {
		return errors.New("unable to ConsumeOnce - library is configured in Producer mode")
	}

	if ctx == nil {
		ctx = context.Background()
	}

	r.log.Debug("waiting for a single message from rabbit ...")

	select {
	case msg := <-r.delivery():
		if err := runFunc(msg); err != nil {
			return err
		}
	case <-ctx.Done():
		r.log.Warn("stopped via context")
		return nil
	case <-r.ctx.Done():
		r.log.Warn("stopped via Stop()")
		return nil
	}

	r.log.Debug("ConsumeOnce finished - exiting")

	return nil
}