mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 08:40:18 +01:00
Use db client factory in seeder.
This commit is contained in:
parent
34d01762f0
commit
4f7fedf0b9
@ -56,7 +56,7 @@ func createTiles(
|
||||
}
|
||||
|
||||
func createBaseLevel(
|
||||
dbcc dbClientCreator,
|
||||
dbcc common.DBClientCreator,
|
||||
xMin, yMin, zMin, xMax, yMax, zMax int,
|
||||
transparent bool, transparentDim float32,
|
||||
colorsFile string, bg color.RGBA, outDir string,
|
||||
|
@ -68,7 +68,7 @@ func main() {
|
||||
|
||||
bg := common.ParseColorDefault(bgColor, common.BackgroundColor)
|
||||
|
||||
dbcc := createDBClientCreator(host, port)
|
||||
dbcc := common.CreateDBClientCreator(host, port)
|
||||
|
||||
if !skipBaseLevel {
|
||||
td := common.Clamp32f(float32(transparentDim/100.0), 0.0, 1.0)
|
||||
|
33
common/clientfactory.go
Normal file
33
common/clientfactory.go
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2022 by Sascha L. Teichmann
|
||||
// Use of this source code is governed by the MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DBClientCreator func() (DBClient, error)
|
||||
|
||||
func CreateDBClientCreator(host string, port int) DBClientCreator {
|
||||
|
||||
var address string
|
||||
if strings.ContainsRune(host, '/') {
|
||||
address = host
|
||||
} else {
|
||||
address = fmt.Sprintf("%s:%d", host, port)
|
||||
}
|
||||
|
||||
var proto string
|
||||
if strings.ContainsRune(address, '/') {
|
||||
proto = "unix"
|
||||
} else {
|
||||
proto = "tcp"
|
||||
}
|
||||
|
||||
return func() (DBClient, error) {
|
||||
return NewRedisClient(proto, address)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user