Compare commits

...

3 Commits

Author SHA1 Message Date
王性驊 c03b65c693 feat: update InitAutoId to InitAutoID 2024-12-27 11:44:04 +08:00
王性驊 7952af6782 feat: fix doc-db-port 2024-12-26 23:40:53 +08:00
王性驊 240027443a feat: fix doc-db-port 2024-12-26 14:25:45 +08:00
4 changed files with 6 additions and 7 deletions

View File

@ -7,7 +7,6 @@ type Conf struct {
User string
Password string
Host string
Port string
Database string
ReplicaName string
MaxStaleness time.Duration

View File

@ -15,8 +15,8 @@ type DocumentDBWithCache struct {
Cache cache.Cache
}
func MustDocumentDBWithCache(conf *Conf, cacheConf cache.CacheConf, dbOpts []mon.Option, cacheOpts []cache.Option) (DocumentDBWithCacheUseCase, error) {
documentDB, err := NewDocumentDB(conf, dbOpts...)
func MustDocumentDBWithCache(conf *Conf, collection string, cacheConf cache.CacheConf, dbOpts []mon.Option, cacheOpts []cache.Option) (DocumentDBWithCacheUseCase, error) {
documentDB, err := NewDocumentDB(conf, collection, dbOpts...)
if err != nil {
return nil, fmt.Errorf("failed to initialize DocumentDB: %w", err)
}

View File

@ -20,7 +20,7 @@ type DocumentDB struct {
Mon *mon.Model
}
func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error) {
func NewDocumentDB(config *Conf, collection string, opts ...mon.Option) (DocumentDBUseCase, error) {
authenticationURI := ""
if config.User != "" {
authenticationURI = fmt.Sprintf(
@ -34,7 +34,7 @@ func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error)
connectionStringTemplate,
config.Schema,
authenticationURI,
fmt.Sprintf("%s:%s", config.Host, config.Port),
config.Host,
)
connectUri, _ := url.Parse(connectionURI)
@ -50,7 +50,7 @@ func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error)
opts = append(opts, intOpt)
logx.Infof("[DocumentDB] Try to connect document db `%s`", printConnectUri)
client, err := mon.NewModel(connectionURI, config.Database, config.Database, opts...)
client, err := mon.NewModel(connectionURI, config.Database, collection, opts...)
if err != nil {
return nil, err
}

View File

@ -2,7 +2,7 @@ package invited_code
const (
DefaultCodeLen = 8
InitAutoId = 10000000
InitAutoID = 10000000
)
var ConvertTable = []string{