Compare commits
4 Commits
mongo/v0.0
...
main
Author | SHA1 | Date |
---|---|---|
王性驊 | c03b65c693 | |
王性驊 | 7952af6782 | |
王性驊 | 240027443a | |
王性驊 | 24e302990a |
|
@ -7,7 +7,6 @@ type Conf struct {
|
||||||
User string
|
User string
|
||||||
Password string
|
Password string
|
||||||
Host string
|
Host string
|
||||||
Port string
|
|
||||||
Database string
|
Database string
|
||||||
ReplicaName string
|
ReplicaName string
|
||||||
MaxStaleness time.Duration
|
MaxStaleness time.Duration
|
||||||
|
|
|
@ -15,8 +15,8 @@ type DocumentDBWithCache struct {
|
||||||
Cache cache.Cache
|
Cache cache.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
func MustDocumentDBWithCache(conf *Conf, cacheConf cache.CacheConf, dbOpts []mon.Option, cacheOpts []cache.Option) (DocumentDBWithCacheUseCase, error) {
|
func MustDocumentDBWithCache(conf *Conf, collection string, cacheConf cache.CacheConf, dbOpts []mon.Option, cacheOpts []cache.Option) (DocumentDBWithCacheUseCase, error) {
|
||||||
documentDB, err := NewDocumentDB(conf, dbOpts...)
|
documentDB, err := NewDocumentDB(conf, collection, dbOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to initialize DocumentDB: %w", err)
|
return nil, fmt.Errorf("failed to initialize DocumentDB: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ type DocumentDB struct {
|
||||||
Mon *mon.Model
|
Mon *mon.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error) {
|
func NewDocumentDB(config *Conf, collection string, opts ...mon.Option) (DocumentDBUseCase, error) {
|
||||||
authenticationURI := ""
|
authenticationURI := ""
|
||||||
if config.User != "" {
|
if config.User != "" {
|
||||||
authenticationURI = fmt.Sprintf(
|
authenticationURI = fmt.Sprintf(
|
||||||
|
@ -50,7 +50,7 @@ func NewDocumentDB(config *Conf, opts ...mon.Option) (DocumentDBUseCase, error)
|
||||||
opts = append(opts, intOpt)
|
opts = append(opts, intOpt)
|
||||||
|
|
||||||
logx.Infof("[DocumentDB] Try to connect document db `%s`", printConnectUri)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package invited_code
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultCodeLen = 8
|
DefaultCodeLen = 8
|
||||||
InitAutoId = 10000000
|
InitAutoID = 10000000
|
||||||
)
|
)
|
||||||
|
|
||||||
var ConvertTable = []string{
|
var ConvertTable = []string{
|
||||||
|
|
Loading…
Reference in New Issue