fix: align IDMaker with semantic structure and cleanup interface (by AI)
This commit is contained in:
parent
4e8637cf40
commit
918d561b24
12
DB.go
12
DB.go
@ -159,7 +159,7 @@ func (dbInfo *Config) ConfigureBy(setting string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if sslCa != "" && sslCert != "" && sslKey != "" {
|
if sslCa != "" && sslCert != "" && sslKey != "" {
|
||||||
sslName := id.MakeID(12)
|
sslName := id.Get12BytesUltraPerSecond()
|
||||||
dbInfo.SSL = sslName
|
dbInfo.SSL = sslName
|
||||||
decryptedCa, _ := confAes.DecryptBytes([]byte(sslCa))
|
decryptedCa, _ := confAes.DecryptBytes([]byte(sslCa))
|
||||||
decryptedCert, _ := confAes.DecryptBytes([]byte(sslCert))
|
decryptedCert, _ := confAes.DecryptBytes([]byte(sslCert))
|
||||||
@ -280,22 +280,16 @@ func (db *DB) NextVersion(table string) int64 {
|
|||||||
return atomic.AddInt64(v.(*int64), 1)
|
return atomic.AddInt64(v.(*int64), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
type idMaker interface {
|
|
||||||
Get(size int) string
|
|
||||||
GetForMysql(size int) string
|
|
||||||
GetForPostgreSQL(size int) string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DB) NextID(table string) string {
|
func (db *DB) NextID(table string) string {
|
||||||
ts := db.getTable(table)
|
ts := db.getTable(table)
|
||||||
if ts.IdField == "" || ts.IdSize == 0 {
|
if ts.IdField == "" || ts.IdSize == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var maker idMaker
|
var maker *id.IDMaker
|
||||||
if db.Config.Redis != "" {
|
if db.Config.Redis != "" {
|
||||||
if v, ok := globalIdMakers.Load(db.Config.Redis); ok {
|
if v, ok := globalIdMakers.Load(db.Config.Redis); ok {
|
||||||
maker = v.(idMaker)
|
maker = v.(*id.IDMaker)
|
||||||
} else {
|
} else {
|
||||||
r := redis.GetRedis(db.Config.Redis, db.logger.logger)
|
r := redis.GetRedis(db.Config.Redis, db.logger.logger)
|
||||||
if r != nil {
|
if r != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user