Files
chatservice_concept/db/scylla.go
2025-05-18 18:25:17 -04:00

31 lines
603 B
Go

package db
import (
"log/slog"
"os"
"github.com/gocql/gocql"
)
var Session *gocql.Session
func InitScyllaDB() {
cluster := gocql.NewCluster(os.Getenv("SCYLLA_CLUSTER")) // Replace with your ScyllaDB cluster IPs
cluster.Keyspace = os.Getenv("SCYLLA_KEYSPACE") // Replace with your 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()
}
}