From e76fe0fead4f3fbf3d97fc4e43cb2dcf66327a6b Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Thu, 1 Dec 2022 17:57:17 +0100 Subject: [PATCH] fix --- rabbitmq/connect.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rabbitmq/connect.go b/rabbitmq/connect.go index e69de29..b3fa520 100644 --- a/rabbitmq/connect.go +++ b/rabbitmq/connect.go @@ -0,0 +1,26 @@ +package rabbitmq + +import ( + "log" + + "github.com/streadway/amqp" +) + +func Open(url string) (*amqp.Connection, *amqp.Channel, error) { + conn, err := amqp.Dial(url) + if err != nil { + return nil, nil, err + } + + ch, err := conn.Channel() + if err != nil { + log.Printf("Failed to open a channel: %v\n", err) + return nil, nil, err + } + + return conn, ch, nil +} + +func Close(conn *amqp.Connection) { + conn.Close() +}