Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e184fff689 | |||
| 33d1b2e0ee | |||
| 433cd1f8bc |
2
cache/redis/redis.go
vendored
2
cache/redis/redis.go
vendored
@@ -59,6 +59,6 @@ func New(dsn string, hashRadix string) *RedisClient {
|
||||
|
||||
func Hash(s string) int {
|
||||
h := fnv.New32a()
|
||||
h.Write([]byte(s))
|
||||
h.Write([]byte(strings.ToLower(s)))
|
||||
return int(h.Sum32()) % vars.RedisShardings
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/env"
|
||||
"git.apinb.com/bsm-sdk/core/print"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
@@ -56,6 +57,12 @@ func NotNil(values ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
func PrintInfo(port int) {
|
||||
print.Info("[BSM - %s] Service Name: %s", vars.ServiceKey, vars.ServiceKey)
|
||||
print.Info("[BSM - %s] Runtime Mode: %s", vars.ServiceKey, env.Runtime.Mode)
|
||||
print.Info("[BSM - %s] Listen Addr: %s:%d", vars.ServiceKey, utils.GetLocationIP(), port)
|
||||
}
|
||||
|
||||
func CheckPort(port int) int {
|
||||
if port <= 0 || port >= 65535 {
|
||||
r := rand.New(rand.NewPCG(1000, uint64(time.Now().UnixNano())))
|
||||
|
||||
@@ -8,6 +8,20 @@ import (
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
func SetOptions(options *types.SqlOptions) *types.SqlOptions {
|
||||
if options == nil {
|
||||
options = &types.SqlOptions{
|
||||
MaxIdleConns: vars.SqlOptionMaxIdleConns,
|
||||
MaxOpenConns: vars.SqlOptionMaxIdleConns,
|
||||
ConnMaxLifetime: vars.SqlOptionConnMaxLifetime,
|
||||
LogStdout: false,
|
||||
Debug: false,
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
// new grom db.
|
||||
func NewPostgreSql(dsn string, options *types.SqlOptions) (*gorm.DB, error) {
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user