server: implement scylladb

This commit is contained in:
2026-05-14 00:21:44 +00:00
parent 4be223d1b7
commit d059dc0032
5 changed files with 86 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
package db
import (
"log/slog"
"os"
"github.com/gocql/gocql"
)
var Session *gocql.Session
func InitScyllaDB() {
cluster := gocql.NewCluster(os.Getenv("SCYLLA_CLUSTER"))
cluster.Keyspace = os.Getenv("SCYLLA_KEYSPACE")
cluster.Consistency = gocql.Quorum
session, err := cluster.CreateSession()
if err != nil {
slog.Error("Failed to connect to ScyllaDB", "error", err)
os.Exit(1)
}
Session = session
slog.Info("Connected to ScyllaDB")
}
func CloseScyllaDB() {
if Session != nil {
Session.Close()
}
}