Started with db abstraction in seeder.

This commit is contained in:
Sascha L. Teichmann
2022-02-27 21:02:16 +01:00
parent 481cf6e517
commit 34d01762f0
4 changed files with 18 additions and 22 deletions

View File

@ -10,7 +10,6 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"bitbucket.org/s_l_teichmann/mtsatellite/common"
@ -57,7 +56,7 @@ func createTiles(
}
func createBaseLevel(
address string,
dbcc dbClientCreator,
xMin, yMin, zMin, xMax, yMax, zMax int,
transparent bool, transparentDim float32,
colorsFile string, bg color.RGBA, outDir string,
@ -79,17 +78,10 @@ func createBaseLevel(
jobs := make(chan blockPos)
var done sync.WaitGroup
var proto string
if strings.ContainsRune(address, '/') {
proto = "unix"
} else {
proto = "tcp"
}
for i := 0; i < numWorkers; i++ {
var client *common.RedisClient
var client common.DBClient
if client, err = common.NewRedisClient(proto, address); err != nil {
if client, err = dbcc(); err != nil {
return
}
done.Add(1)

View File

@ -6,9 +6,7 @@ package main
import (
"flag"
"fmt"
"log"
"strings"
"bitbucket.org/s_l_teichmann/mtsatellite/common"
)
@ -70,16 +68,12 @@ func main() {
bg := common.ParseColorDefault(bgColor, common.BackgroundColor)
dbcc := createDBClientCreator(host, port)
if !skipBaseLevel {
td := common.Clamp32f(float32(transparentDim/100.0), 0.0, 1.0)
var address string
if strings.ContainsRune(host, '/') {
address = host
} else {
address = fmt.Sprintf("%s:%d", host, port)
}
if err := createBaseLevel(
address,
dbcc,
xMin, yMin, zMin, xMax, yMax, zMax,
transparent, td,
colorsFile, bg,