func (p *Pool) new(ctx context.Context) (ChannelKeeper, error) {
	ch, err := p.conn.Channel(ctx)
	if err != nil {
		return ChannelKeeper{}, errors.Wrap(err, "failed to receive channel from connection")
	}
	errorCh := ch.NotifyClose(make(chan *amqp.Error, 1))
	err = ch.Confirm(false)
	if err != nil {
		_ = ch.Close()  
		return ChannelKeeper{}, errors.Wrap(err, "failed to setup confirm mode for channel")
	}
	confirmCh := ch.NotifyPublish(make(chan amqp.Confirmation, 1))
	returnCh := ch.NotifyReturn(make(chan amqp.Return, 1))
	return ChannelKeeper{ch, errorCh, confirmCh, returnCh}, nil
}
new returns a ChannelKeeper with new amqp.Channel into confirm mode.
package rabbitroutine
import (
	"context"
	"sync"
	"github.com/pkg/errors"
	"github.com/streadway/amqp"
)
type ChannelKeeper struct {
	msgCh     *amqp.Channel
	errorCh   chan *amqp.Error
	confirmCh chan amqp.Confirmation
	returnCh  chan amqp.Return
}
func (k *ChannelKeeper) Channel() *amqp.Channel {
	return k.msgCh
}
func (k *ChannelKeeper) Error() <-chan *amqp.Error {
	return k.errorCh
}
func (k *ChannelKeeper) Confirm() <-chan amqp.Confirmation {
	return k.confirmCh
}
func (k *ChannelKeeper) Return() <-chan amqp.Return {
	return k.returnCh
}
func (k *ChannelKeeper) Close() error {
	return k.msgCh.Close()
}
type Pool struct {
	conn *Connector
	mx   sync.Mutex
	set  []ChannelKeeper
}
func NewPool(conn *Connector) *Pool {
	return &Pool{
		conn: conn,
	}
}
func (p *Pool) ChannelWithConfirm(ctx context.Context) (ChannelKeeper, error) {
	var (
		k   ChannelKeeper
		err error
	)
	p.mx.Lock()
	last := len(p.set) - 1
	if last >= 0 {
		k = p.set[last]
		p.set = p.set[:last]
	}
	p.mx.Unlock()
	if last < 0 {
		k, err = p.new(ctx)
		if err != nil {
			return k, errors.Wrap(err, "failed to create new")
		}
	}
	return k, nil
}
func (p *Pool) Release(k ChannelKeeper) {
	p.mx.Lock()
	p.set = append(p.set, k)
	p.mx.Unlock()
}