Files
llink/go/internal/redis.go
T
Arjun PatelandGitHub d262f734f0 Mobile notifications for iOS (#210)
* mobile: wire notification registration and listener

* implement backend components for push notifications

* refactor: agentic comment cleanup

* docs: use proper module name for particle processor

* set required env variables for push notifications

* bump version

* fix: always upsert push token on mobile start

* Revert "fix: always upsert push token on mobile start"

This reverts commit 90ff18a788.

* send push notifications regardless of online status
2026-05-18 12:44:31 -07:00

47 lines
849 B
Go

package internal
import (
"context"
"fmt"
"log/slog"
"os"
"github.com/flowy-live/llink/internal/utils"
"github.com/redis/go-redis/v9"
)
func ConnectAndTestRedis(db int) *redis.Client {
redisHost := utils.MustGetEnv("REDIS_HOST")
if redisHost == "" {
slog.Error("must provide REDIS_HOST")
os.Exit(1)
}
redisAddr := fmt.Sprintf("%s:%s", redisHost, "6379")
rdb := redis.NewClient(&redis.Options{
Addr: redisAddr,
Password: "",
DB: db,
})
err := rdb.Set(context.Background(), "key", "value", 0).Err()
if err != nil {
panic(err)
}
val, err := rdb.Get(context.Background(), "key").Result()
if err != nil {
panic(err)
}
slog.Debug("redis test", "key", val)
if val != "value" {
panic("unexpected value")
}
err = rdb.Del(context.Background(), "key").Err()
if err != nil {
panic(err)
}
return rdb
}