Skip to content

Commit

Permalink
create config to rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
Prrromanssss committed Feb 13, 2024
1 parent 61681f9 commit 15e1944
Show file tree
Hide file tree
Showing 28 changed files with 8,455 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PORT=YOUR-SITE-PORT
DB_URL=YOUR-DB-CONNECTION-URL
DB_URL=YOUR-DB-CONNECTION-URL
RABBITMQ_URL=YOUR-RABBITMQ-CONNECTION-URL
30 changes: 30 additions & 0 deletions backend/config/rabbitmq_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package config

import (
"log"

"github.com/streadway/amqp"
)

type AMQPConfig struct {
Conn *amqp.Connection
Ch *amqp.Channel
}

func NewConsumerAMQPConfig(amqpUrl string) *AMQPConfig {
conn, err := amqp.Dial(amqpUrl)
if err != nil {
log.Fatalf("Can't connect to RabbitMQ: %v", err)
}

log.Println("Successfully connected to RabbitMQ instance")

ch, err := conn.Channel()
if err != nil {
log.Fatalf("Can't create a channel from RabbitMQ: %v", err)
}
return &AMQPConfig{
Conn: conn,
Ch: ch,
}
}
2 changes: 2 additions & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ require (
require github.com/google/uuid v1.6.0

require github.com/lib/pq v1.10.9

require github.com/streadway/amqp v1.1.0
2 changes: 2 additions & 0 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/streadway/amqp v1.1.0 h1:py12iX8XSyI7aN/3dUT8DFIDJazNJsVJdxNVEpnQTZM=
github.com/streadway/amqp v1.1.0/go.mod h1:WYSrTEYHOXHd0nwFeUXAe2G2hRnQT+deZJJf88uS9Bg=
12 changes: 12 additions & 0 deletions backend/vendor/github.com/streadway/amqp/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions backend/vendor/github.com/streadway/amqp/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions backend/vendor/github.com/streadway/amqp/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions backend/vendor/github.com/streadway/amqp/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions backend/vendor/github.com/streadway/amqp/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions backend/vendor/github.com/streadway/amqp/allocator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 15e1944

Please sign in to comment.