Adding some comments and inlining the init of bufPool

This commit is contained in:
Lucas Rouckhout
2023-02-06 18:29:41 +01:00
parent fb9d8562e7
commit 9cb745132b

View File

@@ -11,13 +11,9 @@ import (
amqp "github.com/rabbitmq/amqp091-go" amqp "github.com/rabbitmq/amqp091-go"
) )
var bufPool sync.Pool var bufPool sync.Pool = sync.Pool{
func init() {
bufPool = sync.Pool{
New: func() interface{} { return new(bytes.Buffer) }, New: func() interface{} { return new(bytes.Buffer) },
} }
}
func (svc *LndhubService) StartRabbitMqPublisher(ctx context.Context) error { func (svc *LndhubService) StartRabbitMqPublisher(ctx context.Context) error {
conn, err := amqp.Dial(svc.Config.RabbitMQUri) conn, err := amqp.Dial(svc.Config.RabbitMQUri)
@@ -33,7 +29,8 @@ func (svc *LndhubService) StartRabbitMqPublisher(ctx context.Context) error {
defer ch.Close() defer ch.Close()
err = ch.ExchangeDeclare( err = ch.ExchangeDeclare(
//TODO: review exchange config // TODO: review the whole exchange setup. For the time being we simply declare a single exchange and start pushing to it.
// Towards the future however this might become a more involved setup.
svc.Config.RabbitMQInvoiceExchange, svc.Config.RabbitMQInvoiceExchange,
// topic is a type of exchange that allows routing messages to different queue's bases on a routing key // topic is a type of exchange that allows routing messages to different queue's bases on a routing key
"topic", "topic",