Remove rabbit conn from service object

This commit is contained in:
Lucas Rouckhout
2023-02-18 15:47:05 +01:00
parent 9691ae2cfc
commit 5758b39c0d
2 changed files with 2 additions and 5 deletions

View File

@@ -19,12 +19,12 @@ func (svc *LndhubService) StartRabbitMqPublisher(ctx context.Context) error {
// It is recommended that, when possible, publishers and consumers // It is recommended that, when possible, publishers and consumers
// use separate connections so that consumers are isolated from potential // use separate connections so that consumers are isolated from potential
// flow control messures that may be applied to publishing connections. // flow control messures that may be applied to publishing connections.
// We therefore start a single publishing connection here. // We therefore start a single publishing connection here instead of storing
// one on the service object.
conn, err := amqp.Dial(svc.Config.RabbitMQUri) conn, err := amqp.Dial(svc.Config.RabbitMQUri)
if err != nil { if err != nil {
return err return err
} }
svc.RabbitMqConn = conn
ch, err := conn.Channel() ch, err := conn.Channel()
if err != nil { if err != nil {

View File

@@ -12,8 +12,6 @@ import (
"github.com/uptrace/bun" "github.com/uptrace/bun"
"github.com/ziflex/lecho/v3" "github.com/ziflex/lecho/v3"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
amqp "github.com/rabbitmq/amqp091-go"
) )
const alphaNumBytes = random.Alphanumeric const alphaNumBytes = random.Alphanumeric
@@ -25,7 +23,6 @@ type LndhubService struct {
Logger *lecho.Logger Logger *lecho.Logger
IdentityPubkey string IdentityPubkey string
InvoicePubSub *Pubsub InvoicePubSub *Pubsub
RabbitMqConn *amqp.Connection
} }
func (svc *LndhubService) GenerateToken(ctx context.Context, login, password, inRefreshToken string) (accessToken, refreshToken string, err error) { func (svc *LndhubService) GenerateToken(ctx context.Context, login, password, inRefreshToken string) (accessToken, refreshToken string, err error) {