summaryrefslogtreecommitdiff
path: root/srv/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'srv/src/cmd')
-rw-r--r--srv/src/cmd/mediocre-blog/main.go27
1 files changed, 6 insertions, 21 deletions
diff --git a/srv/src/cmd/mediocre-blog/main.go b/srv/src/cmd/mediocre-blog/main.go
index f12f4af..69ee7b6 100644
--- a/srv/src/cmd/mediocre-blog/main.go
+++ b/srv/src/cmd/mediocre-blog/main.go
@@ -8,14 +8,12 @@ import (
"time"
"github.com/mediocregopher/blog.mediocregopher.com/srv/api"
- "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/mediocregopher/blog.mediocregopher.com/srv/chat"
"github.com/mediocregopher/blog.mediocregopher.com/srv/mailinglist"
"github.com/mediocregopher/blog.mediocregopher.com/srv/pow"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
- "github.com/mediocregopher/radix/v4"
"github.com/tilinna/clock"
)
@@ -23,7 +21,7 @@ func main() {
ctx := context.Background()
- cfg := cfg.NewBlogCfg(cfg.Params{})
+ cfg := cfgpkg.NewBlogCfg(cfgpkg.Params{})
var dataDir cfgpkg.DataDir
dataDir.SetupCfg(cfg)
@@ -46,9 +44,10 @@ func main() {
apiParams.SetupCfg(cfg)
ctx = mctx.WithAnnotator(ctx, &apiParams)
- redisProto := cfg.String("redis-proto", "tcp", "Network protocol to connect to redis over, can be tcp or unix")
- redisAddr := cfg.String("redis-addr", "127.0.0.1:6379", "Address redis is expected to listen on")
- redisPoolSize := cfg.Int("redis-pool-size", 5, "Number of connections in the redis pool to keep")
+ var radixClient cfgpkg.RadixClient
+ radixClient.SetupCfg(cfg)
+ defer radixClient.Close()
+ ctx = mctx.WithAnnotator(ctx, &radixClient)
chatGlobalRoomMaxMsgs := cfg.Int("chat-global-room-max-messages", 1000, "Maximum number of messages the global chat room can retain")
chatUserIDCalcSecret := cfg.String("chat-user-id-calc-secret", "", "Secret to use when calculating user ids")
@@ -67,9 +66,6 @@ func main() {
}
ctx = mctx.Annotate(ctx,
- "redisProto", *redisProto,
- "redisAddr", *redisAddr,
- "redisPoolSize", *redisPoolSize,
"chatGlobalRoomMaxMsgs", *chatGlobalRoomMaxMsgs,
)
@@ -103,20 +99,9 @@ func main() {
ml := mailinglist.New(mlParams)
- redis, err := (radix.PoolConfig{
- Size: *redisPoolSize,
- }).New(
- ctx, *redisProto, *redisAddr,
- )
-
- if err != nil {
- logger.Fatal(ctx, "initializing redis pool", err)
- }
- defer redis.Close()
-
chatGlobalRoom, err := chat.NewRoom(ctx, chat.RoomParams{
Logger: logger.WithNamespace("global-chat-room"),
- Redis: redis,
+ Redis: radixClient.Client,
ID: "global",
MaxMessages: *chatGlobalRoomMaxMsgs,
})