func (pub *Publisher) PublishWithRetry(letter *models.Letter) {
	for i := letter.RetryCount + 1; i > 0; i-- {
		chanHost, err := pub.ChannelPool.GetChannel()
		if err != nil {
			time.Sleep(pub.sleepOnErrorInterval * time.Millisecond)
			continue  
		}
		err = pub.simplePublish(chanHost.Channel, letter)
		if err != nil {
			pub.handleErrorAndChannel(err, letter, chanHost)
			continue  
		}
		pub.sendToNotifications(letter, err)
		pub.ChannelPool.ReturnChannel(chanHost, false)
		break  
	}
}
PublishWithRetry sends a single message to the address on the letter with retry capabilities.
Subscribe to Notifications to see success and errors.
RetryCount is based on the letter property. Zero means it will try once.
package publisher
import (
	"sync"
	"sync/atomic"
	"time"
	"github.com/houseofcat/turbocookedrabbit/v1/pkg/models"
	"github.com/houseofcat/turbocookedrabbit/v1/pkg/pools"
	"github.com/streadway/amqp"
)
type Publisher struct {
	Config                   *models.RabbitSeasoning
	ChannelPool              *pools.ChannelPool
	letters                  chan *models.Letter
	letterCount              uint64
	letterBuffer             uint64
	maxOverBuffer            uint64
	autoStop                 chan bool
	notifications            chan *models.Notification
	autoStarted              bool
	autoPublishGroup         *sync.WaitGroup
	sleepOnIdleInterval      time.Duration
	sleepOnQueueFullInterval time.Duration
	sleepOnErrorInterval     time.Duration
	pubLock                  *sync.Mutex
	pubRWLock                *sync.RWMutex
}
func NewPublisher(
	config *models.RabbitSeasoning,
	chanPool *pools.ChannelPool,
	connPool *pools.ConnectionPool) (*Publisher, error) {
	if chanPool == nil {
		var err error
		chanPool, err = pools.NewChannelPool(config.PoolConfig, connPool, true)
		if err != nil {
			return nil, err
		}
	}
	return &Publisher{
		Config:                   config,
		ChannelPool:              chanPool,
		letters:                  make(chan *models.Letter, config.PublisherConfig.LetterBuffer),
		letterBuffer:             config.PublisherConfig.LetterBuffer,
		maxOverBuffer:            config.PublisherConfig.MaxOverBuffer,
		autoStop:                 make(chan bool, 1),
		autoPublishGroup:         &sync.WaitGroup{},
		notifications:            make(chan *models.Notification, config.PublisherConfig.NotificationBuffer),
		sleepOnIdleInterval:      time.Duration(config.PublisherConfig.SleepOnIdleInterval) * time.Millisecond,
		sleepOnQueueFullInterval: time.Duration(config.PublisherConfig.SleepOnQueueFullInterval) * time.Millisecond,
		sleepOnErrorInterval:     time.Duration(config.PublisherConfig.SleepOnErrorInterval) * time.Millisecond,
		pubLock:                  &sync.Mutex{},
		pubRWLock:                &sync.RWMutex{},
		autoStarted:              false,
	}, nil
}
func (pub *Publisher) Publish(letter *models.Letter) {
	chanHost, err := pub.ChannelPool.GetChannel()
	if err != nil {
		pub.sendToNotifications(letter, err)
		return  
	}
	err = pub.simplePublish(chanHost.Channel, letter)
	if err != nil {
		pub.handleErrorAndChannel(err, letter, chanHost)
	} else {
		pub.sendToNotifications(letter, err)
		pub.ChannelPool.ReturnChannel(chanHost, false)
	}
}