mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 18:26:36 +08:00
feat(valkey): migrate redis to valkey and fix updater custom prefix selection
Replace redis:7-alpine with valkey:8.0-alpine and configure MaintNotificationsConfig ModeDisabled to suppress handshake warnings on Valkey. Resolve updater bug by dynamically matching custom repository asset name prefixes like PixezSync.
This commit is contained in:
+14
-14
@@ -47,20 +47,6 @@ database:
|
|||||||
# - host: "replica2.db.internal"
|
# - host: "replica2.db.internal"
|
||||||
# port: 5432
|
# port: 5432
|
||||||
|
|
||||||
# ─── ClickHouse (optional) ──────────────────────────────────────────────────────
|
|
||||||
clickhouse:
|
|
||||||
enabled: false
|
|
||||||
hosts:
|
|
||||||
- "127.0.0.1:9000"
|
|
||||||
username: "default"
|
|
||||||
password: ""
|
|
||||||
database: "wavelet"
|
|
||||||
max_idle_conn: 10
|
|
||||||
max_open_conn: 100
|
|
||||||
conn_max_lifetime: 3600
|
|
||||||
dial_timeout: 5
|
|
||||||
block_buffer_size: 10
|
|
||||||
|
|
||||||
# ─── Redis ──────────────────────────────────────────────────────────────────────
|
# ─── Redis ──────────────────────────────────────────────────────────────────────
|
||||||
# Supports Standalone, Sentinel (HA), and Cluster modes.
|
# Supports Standalone, Sentinel (HA), and Cluster modes.
|
||||||
redis:
|
redis:
|
||||||
@@ -125,3 +111,17 @@ s3:
|
|||||||
local_cache:
|
local_cache:
|
||||||
enabled: false
|
enabled: false
|
||||||
cache_dir: "./s3_cache"
|
cache_dir: "./s3_cache"
|
||||||
|
|
||||||
|
# ─── ClickHouse (optional) ──────────────────────────────────────────────────────
|
||||||
|
clickhouse:
|
||||||
|
enabled: false
|
||||||
|
hosts:
|
||||||
|
- "127.0.0.1:9000"
|
||||||
|
username: "default"
|
||||||
|
password: ""
|
||||||
|
database: "wavelet"
|
||||||
|
max_idle_conn: 10
|
||||||
|
max_open_conn: 100
|
||||||
|
conn_max_lifetime: 3600
|
||||||
|
dial_timeout: 5
|
||||||
|
block_buffer_size: 10
|
||||||
|
|||||||
+4
-4
@@ -41,15 +41,15 @@ services:
|
|||||||
start_period: 10s
|
start_period: 10s
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: valkey/valkey:8.0-alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: ["redis-server", "--appendonly", "yes"]
|
command: ["valkey-server", "--appendonly", "yes"]
|
||||||
ports:
|
ports:
|
||||||
- "${REDIS_PORT:-6379}:6379"
|
- "${REDIS_PORT:-6379}:6379"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/redis_data:/data
|
- ./data/valkey:/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: ["CMD", "valkey-cli", "ping"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|||||||
+2
-2
@@ -79,9 +79,9 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: valkey/valkey:8.0-alpine
|
||||||
container_name: refreshing-redis
|
container_name: refreshing-redis
|
||||||
command: redis-server --requirepass YOUR_REDIS_PASSWORD
|
command: valkey-server --requirepass YOUR_REDIS_PASSWORD
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/alicebob/miniredis/v2"
|
"github.com/alicebob/miniredis/v2"
|
||||||
"github.com/glebarez/sqlite"
|
"github.com/glebarez/sqlite"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
"github.com/redis/go-redis/v9/maintnotifications"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,12 +27,25 @@ func TestMigrateInitializesSQLiteDatabase(t *testing.T) {
|
|||||||
t.Fatalf("gorm.Open(sqlite) error = %v", err)
|
t.Fatalf("gorm.Open(sqlite) error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mr, err := miniredis.Run()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("miniredis.Run() error = %v", err)
|
||||||
|
}
|
||||||
|
redisClient := redis.NewClient(&redis.Options{
|
||||||
|
Addr: mr.Addr(),
|
||||||
|
MaintNotificationsConfig: &maintnotifications.Config{
|
||||||
|
Mode: maintnotifications.ModeDisabled,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
previousDBEnabled := config.Config.Database.Enabled
|
previousDBEnabled := config.Config.Database.Enabled
|
||||||
config.Config.Database.Enabled = false
|
config.Config.Database.Enabled = false
|
||||||
db.SetDB(sqliteDB)
|
db.SetDB(sqliteDB)
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
config.Config.Database.Enabled = previousDBEnabled
|
config.Config.Database.Enabled = previousDBEnabled
|
||||||
db.SetDB(nil)
|
db.SetDB(nil)
|
||||||
|
_ = redisClient.Close()
|
||||||
|
mr.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
Migrate()
|
Migrate()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/Rain-kl/Wavelet/internal/config"
|
"github.com/Rain-kl/Wavelet/internal/config"
|
||||||
"github.com/redis/go-redis/extra/redisotel/v9"
|
"github.com/redis/go-redis/extra/redisotel/v9"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
"github.com/redis/go-redis/v9/maintnotifications"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -45,6 +46,9 @@ func init() {
|
|||||||
MaxRetries: cfg.MaxRetries,
|
MaxRetries: cfg.MaxRetries,
|
||||||
PoolTimeout: time.Duration(cfg.PoolTimeout) * time.Second,
|
PoolTimeout: time.Duration(cfg.PoolTimeout) * time.Second,
|
||||||
ConnMaxIdleTime: time.Duration(cfg.ConnMaxIdleTime) * time.Second,
|
ConnMaxIdleTime: time.Duration(cfg.ConnMaxIdleTime) * time.Second,
|
||||||
|
MaintNotificationsConfig: &maintnotifications.Config{
|
||||||
|
Mode: maintnotifications.ModeDisabled,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
log.Println("[Redis] initialized in Cluster mode")
|
log.Println("[Redis] initialized in Cluster mode")
|
||||||
} else {
|
} else {
|
||||||
@@ -63,6 +67,9 @@ func init() {
|
|||||||
MaxRetries: cfg.MaxRetries,
|
MaxRetries: cfg.MaxRetries,
|
||||||
PoolTimeout: time.Duration(cfg.PoolTimeout) * time.Second,
|
PoolTimeout: time.Duration(cfg.PoolTimeout) * time.Second,
|
||||||
ConnMaxIdleTime: time.Duration(cfg.ConnMaxIdleTime) * time.Second,
|
ConnMaxIdleTime: time.Duration(cfg.ConnMaxIdleTime) * time.Second,
|
||||||
|
MaintNotificationsConfig: &maintnotifications.Config{
|
||||||
|
Mode: maintnotifications.ModeDisabled,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if cfg.MasterName != "" {
|
if cfg.MasterName != "" {
|
||||||
log.Println("[Redis] initialized in Sentinel mode")
|
log.Println("[Redis] initialized in Sentinel mode")
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/alicebob/miniredis/v2"
|
"github.com/alicebob/miniredis/v2"
|
||||||
"github.com/glebarez/sqlite"
|
"github.com/glebarez/sqlite"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
"github.com/redis/go-redis/v9/maintnotifications"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@@ -30,7 +31,12 @@ func setupTaskExecutionTestEnvironment(t *testing.T) func() {
|
|||||||
|
|
||||||
miniRedis, err := miniredis.Run()
|
miniRedis, err := miniredis.Run()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
redisClient := redis.NewClient(&redis.Options{Addr: miniRedis.Addr()})
|
redisClient := redis.NewClient(&redis.Options{
|
||||||
|
Addr: miniRedis.Addr(),
|
||||||
|
MaintNotificationsConfig: &maintnotifications.Config{
|
||||||
|
Mode: maintnotifications.ModeDisabled,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
db.SetDB(sqliteDB)
|
db.SetDB(sqliteDB)
|
||||||
db.Redis = redisClient
|
db.Redis = redisClient
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/alicebob/miniredis/v2"
|
"github.com/alicebob/miniredis/v2"
|
||||||
"github.com/glebarez/sqlite"
|
"github.com/glebarez/sqlite"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
"github.com/redis/go-redis/v9/maintnotifications"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,6 +63,9 @@ func SetupTestEnvironment(t *testing.T) (*gorm.DB, *miniredis.Miniredis, func())
|
|||||||
// Hook up Redis Client to miniredis
|
// Hook up Redis Client to miniredis
|
||||||
redisClient := redis.NewClient(&redis.Options{
|
redisClient := redis.NewClient(&redis.Options{
|
||||||
Addr: mr.Addr(),
|
Addr: mr.Addr(),
|
||||||
|
MaintNotificationsConfig: &maintnotifications.Config{
|
||||||
|
Mode: maintnotifications.ModeDisabled,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
db.Redis = redisClient
|
db.Redis = redisClient
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user