Support unix domain sockets in redis clients, too.

This commit is contained in:
Sascha L. Teichmann
2017-03-05 14:38:30 +01:00
parent ba2dd15280
commit e68e762322
4 changed files with 30 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import (
"log"
"os"
"runtime/pprof"
"strings"
"bitbucket.org/s_l_teichmann/mtsatellite/common"
)
@ -84,11 +85,16 @@ func main() {
colors.TransparentDim = common.Clamp32f(
float32(transparentDim/100.0), 0.0, 100.0)
address := fmt.Sprintf("%s:%d", host, port)
var proto, address string
if strings.ContainsRune(host, '/') {
proto, address = "unix", host
} else {
proto, address = "tcp", fmt.Sprintf("%s:%d", host, port)
}
var client *common.RedisClient
if client, err = common.NewRedisClient("tcp", address); err != nil {
if client, err = common.NewRedisClient(proto, address); err != nil {
log.Fatalf("Cannot connect to '%s': %s", address, err)
}
defer client.Close()