feat: add MQ_HOST var

pull/21533/head
ziqiang 11 months ago
parent 037bfaa0c3
commit dcd7d09c59

@ -500,4 +500,5 @@ QUEUE_MONITOR_ALERT_EMAILS=
QUEUE_MONITOR_INTERVAL=30 QUEUE_MONITOR_INTERVAL=30
ZZ_DIFY_STARTED_URL=http://127.0.0.1:8077/ps/api/u/difyStarted ZZ_DIFY_STARTED_URL=http://192.168.1.117:8077/ps/api/u/difyStarted
MQ_HOST=192.168.1.4

@ -25,6 +25,7 @@ from .vdb.elasticsearch_config import ElasticsearchConfig
from .vdb.huawei_cloud_config import HuaweiCloudConfig from .vdb.huawei_cloud_config import HuaweiCloudConfig
from .vdb.lindorm_config import LindormConfig from .vdb.lindorm_config import LindormConfig
from .vdb.milvus_config import MilvusConfig from .vdb.milvus_config import MilvusConfig
from .vdb.mq_config import MqInfo
from .vdb.myscale_config import MyScaleConfig from .vdb.myscale_config import MyScaleConfig
from .vdb.oceanbase_config import OceanBaseVectorConfig from .vdb.oceanbase_config import OceanBaseVectorConfig
from .vdb.opengauss_config import OpenGaussConfig from .vdb.opengauss_config import OpenGaussConfig
@ -301,6 +302,7 @@ class MiddlewareConfig(
HuaweiCloudConfig, HuaweiCloudConfig,
MilvusConfig, MilvusConfig,
MyScaleConfig, MyScaleConfig,
MqInfo,
OpenSearchConfig, OpenSearchConfig,
OracleConfig, OracleConfig,
PGVectorConfig, PGVectorConfig,

@ -0,0 +1,14 @@
from pydantic import Field
from pydantic_settings import BaseSettings
class MqInfo(BaseSettings):
"""
Packaging build information
"""
MQ_HOST: str = Field(
description="Rabbit Mq host",
default="127.0.0.1",
)

@ -7,6 +7,8 @@ from typing import Any, Optional
import pika import pika
from pika.exceptions import AMQPChannelError, AMQPConnectionError, StreamLostError from pika.exceptions import AMQPChannelError, AMQPConnectionError, StreamLostError
from configs import dify_config
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class RabbitMQClient: class RabbitMQClient:
@ -26,12 +28,13 @@ class RabbitMQClient:
def _get_connection_params(self) -> pika.ConnectionParameters: def _get_connection_params(self) -> pika.ConnectionParameters:
"""获取RabbitMQ连接参数""" """获取RabbitMQ连接参数"""
RABBITMQ_CONFIG = { RABBITMQ_CONFIG = {
'host': '127.0.0.1', 'host': dify_config.MQ_HOST,
'port': 5672, 'port': 5672,
'username': 'apitable', 'username': 'apitable',
'password': 'apitable@com', 'password': 'apitable@com',
'virtual_host': '/' 'virtual_host': '/'
} }
print('MQ_HOST:' + RABBITMQ_CONFIG['host'])
print('virtual_host:' + RABBITMQ_CONFIG['virtual_host']) print('virtual_host:' + RABBITMQ_CONFIG['virtual_host'])
return pika.ConnectionParameters( return pika.ConnectionParameters(
host=RABBITMQ_CONFIG['host'], host=RABBITMQ_CONFIG['host'],

Loading…
Cancel
Save