f
This commit is contained in:
parent
bb55154a19
commit
9ef1833073
1 changed files with 17 additions and 2 deletions
|
|
@ -31,10 +31,25 @@ type RabbitMQClient struct {
|
||||||
type MessageHandler func([]byte) error
|
type MessageHandler func([]byte) error
|
||||||
|
|
||||||
func NewRabbitMQClient() (*RabbitMQClient, error) {
|
func NewRabbitMQClient() (*RabbitMQClient, error) {
|
||||||
// Get RabbitMQ URL from environment or use default
|
|
||||||
rabbitmqURL := os.Getenv("RABBITMQ_URL")
|
rabbitmqURL := os.Getenv("RABBITMQ_URL")
|
||||||
if rabbitmqURL == "" {
|
if rabbitmqURL == "" {
|
||||||
rabbitmqURL = "amqp://guest:guest@localhost:5672/"
|
host := os.Getenv("RABBITMQ_HOST")
|
||||||
|
if host == "" {
|
||||||
|
host = "localhost"
|
||||||
|
}
|
||||||
|
port := os.Getenv("RABBITMQ_PORT")
|
||||||
|
if port == "" {
|
||||||
|
port = "5672"
|
||||||
|
}
|
||||||
|
user := os.Getenv("RABBITMQ_USER")
|
||||||
|
if user == "" {
|
||||||
|
user = "guest"
|
||||||
|
}
|
||||||
|
password := os.Getenv("RABBITMQ_PASSWORD")
|
||||||
|
if password == "" {
|
||||||
|
password = "guest"
|
||||||
|
}
|
||||||
|
rabbitmqURL = fmt.Sprintf("amqp://%s:%s@%s:%s/", user, password, host, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to RabbitMQ with retry logic
|
// Connect to RabbitMQ with retry logic
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue