Skip to content

Commit

Permalink
feat: custom Redis server addr (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn authored Sep 2, 2023
1 parent 9c0fd4d commit eb2a683
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/handler/redis_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func RedisHandler(conn redcon.Conn, cmd redcon.Command) {
}
}

func StartRedisServer() error {
err := redcon.ListenAndServe(":6380",
func StartRedisServer(addr string) error {
err := redcon.ListenAndServe(addr,
RedisHandler,
func(conn redcon.Conn) bool { return true },
func(conn redcon.Conn, err error) {},
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/redis_server_call_by_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (

func mustStartServer() {
redisServerOnce.Do(func() {
go func() { _ = handler.StartRedisServer() }()
go func() { _ = handler.StartRedisServer(":6380") }()
time.Sleep(100 * time.Millisecond)
})
}
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func main() {
finderType := flag.Int("type", 0, "which finder to use Polygon(0) or Fuzzy(1)")
dataPath := flag.String("path", "", "custom data")
httpAddr := flag.String("http-addr", "localhost:8080", "HTTP Host&Port")
redisAddr := flag.String("redis-addr", "localhost:6380", "Redis Server Host&Port")
prometheusHostPorts := flag.String("prometheus-host-port", "localhost:8090", "Prometheus Host&Port")
prometheusPath := flag.String("prometheus-path", "/hertz", "Prometheus Path")
prometheusEnableGoCollector := flag.Bool("prometheus-enable-go-coll", true, "Enable Go Collector")
Expand Down Expand Up @@ -84,7 +85,7 @@ func main() {

g.Go(h.Run)

g.Go(handler.StartRedisServer)
g.Go(func() error { return handler.StartRedisServer(*redisAddr) })

panic(g.Wait())
}

0 comments on commit eb2a683

Please sign in to comment.