From e0ad9847c56262e6c387a98ebf1f290c00e6ecb3 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Wed, 27 Mar 2024 15:43:12 +0800 Subject: [PATCH] feat: config build --- pkg/common/config/config.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 46a9f03ea..b042a2d50 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -16,6 +16,8 @@ package config import ( "bytes" + "github.com/openimsdk/tools/db/mongoutil" + "github.com/openimsdk/tools/db/redisutil" "github.com/openimsdk/tools/mq/kafka" "gopkg.in/yaml.v3" "time" @@ -76,6 +78,18 @@ type Mongo struct { MaxRetry int `yaml:"maxRetry"` } +func (m *Mongo) Build() *mongoutil.Config { + return &mongoutil.Config{ + Uri: m.Uri, + Address: m.Address, + Database: m.Database, + Username: m.Username, + Password: m.Password, + MaxPoolSize: m.MaxPoolSize, + MaxRetry: m.MaxRetry, + } +} + type Redis struct { ClusterMode bool `yaml:"clusterMode"` Address []string `yaml:"address"` @@ -86,6 +100,17 @@ type Redis struct { MaxRetry int `yaml:"maxRetry"` } +func (r *Redis) Build() *redisutil.Config { + return &redisutil.Config{ + ClusterMode: r.ClusterMode, + Address: r.Address, + Username: r.Username, + Password: r.Password, + DB: r.DB, + MaxRetry: r.MaxRetry, + } +} + type Kafka struct { kafka.Config LatestMsgToRedis struct {