2026-06-26 17:56:30 +08:00

26 lines
789 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package app
import (
"context"
"strings"
"hyapp/pkg/userleaderboard"
"hyapp/services/activity-service/internal/config"
)
func openUserLeaderboardStore(ctx context.Context, cfg config.UserLeaderboardWorkerConfig) (*userleaderboard.Store, func() error, error) {
if !cfg.Enabled {
return nil, nil, nil
}
redisAddr := strings.TrimSpace(cfg.RedisAddr)
if redisAddr == "" {
return nil, nil, userleaderboard.ErrNotConfigured
}
client, err := userleaderboard.NewRedisClient(ctx, redisAddr, cfg.RedisPassword, cfg.RedisDB)
if err != nil {
return nil, nil, err
}
// activity-service 只负责把 wallet_outbox 已提交事实投影成 Redis 读模型key 命名由共享包和配置共同约束。
return userleaderboard.NewStore(client, cfg.KeyPrefix), client.Close, nil
}