func NewFireForgetPublisher(p *LightningPool) *FireForgetPublisher {
	return &FireForgetPublisher{p}
}
NewFireForgetPublisher returns a new instance of FireForgetPublisher.
package rabbitroutine
import (
	"context"
	"fmt"
	"math"
	"time"
	"github.com/pkg/errors"
	"github.com/streadway/amqp"
)
var (
	ErrNotFound = errors.New("rabbitmq entity not found")
	ErrNoRoute = errors.New("queue not bound")
)
type Publisher interface {
	Publish(ctx context.Context, exchange, key string, msg amqp.Publishing) error
}
type EnsurePublisher struct {
	pool *Pool
}
func NewEnsurePublisher(p *Pool) *EnsurePublisher {
	return &EnsurePublisher{pool: p}
}
func (p *EnsurePublisher) Publish(ctx context.Context, exchange, key string, msg amqp.Publishing) error {
	k, err := p.pool.ChannelWithConfirm(ctx)
	if err != nil {
		return errors.Wrap(err, "failed to receive channel for publishing")
	}
	err = p.publish(ctx, k, exchange, key, msg)
	if err == ErrNoRoute {
		p.pool.Release(k)
		return err
	}
	if err != nil {
		_ = k.Close()  
		return err
	}
	p.pool.Release(k)
	return nil
}
func (p *EnsurePublisher) publish(ctx context.Context, k ChannelKeeper, exchange, key string, msg amqp.Publishing) error {
	ch := k.Channel()
	mandatory := true
	immediate := false
	err := ch.Publish(exchange, key, mandatory, immediate, msg)
	if err != nil {
		return errors.Wrap(err, "failed to publish message")
	}
	select {
	case <-ctx.Done():
		return ctx.Err()
	case amqpErr := <-k.Error():
		if amqpErr.Code == amqp.NotFound {
			return ErrNotFound
		}
		return errors.Wrap(amqpErr, "failed to deliver a message")
	case amqpRet := <-k.Return():
		if amqpRet.ReplyCode == amqp.NoRoute {
			<-k.Confirm()
			return ErrNoRoute
		}
		return fmt.Errorf("failed to deliver a message: %s", amqpRet.ReplyText)
	case <-k.Confirm():
		return nil
	}
}
type FireForgetPublisher struct {
	pool *LightningPool
}