From 13205e445faf25f2612b570f195d1efa42e5ddd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Fri, 22 Mar 2024 23:06:54 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=96=B0=E5=A2=9E=20MQ=20=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 2 ++ config/mq.go | 1 + mq/rabbitmq.go | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/config.yaml b/config.yaml index cd1e111..b5ff71e 100644 --- a/config.yaml +++ b/config.yaml @@ -37,6 +37,8 @@ task: # MQ配置 mq: + # 是否启用 + enable: false # RabbitMQ配置 rabbitmq: host: 10.0.0.247 diff --git a/config/mq.go b/config/mq.go index caa7388..6bdf2f0 100644 --- a/config/mq.go +++ b/config/mq.go @@ -5,6 +5,7 @@ import "fmt" // mq // @description: MQ配置 type mq struct { + Enable bool `json:"enable" yaml:"enable"` // 是否启用 RabbitMQ rabbitMq `json:"rabbitmq" yaml:"rabbitmq"` // RabbitMQ配置 } diff --git a/mq/rabbitmq.go b/mq/rabbitmq.go index 3d4afe4..c5c1b63 100644 --- a/mq/rabbitmq.go +++ b/mq/rabbitmq.go @@ -16,6 +16,10 @@ const exchangeName = "wechat-message" // Init // @description: 初始化MQ func Init() { + if !config.Conf.Mq.Enable { + log.Println("未启用MQ") + return + } // 读取MQ连接配置 mqUrl := config.Conf.Mq.RabbitMQ.GetURL() if mqUrl == "" {