From ddb126db1709b1c7679b8370b508639991387bf0 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 8 May 2022 16:36:08 -0600 Subject: Move radix config into cfg, use that for integration tests --- srv/src/cmd/mediocre-blog/main.go | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'srv/src/cmd') 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, }) -- cgit v1.2.3