Files
tasks/common/persistence/cassandra/helpers.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

44 lines
1.4 KiB
Go

package cassandra
import (
"fmt"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/log/tag"
"github.com/hanzoai/tasks/common/persistence/nosql/nosqlplugin/cassandra/gocql"
)
const cassandraPersistenceName = "cassandra"
// CreateCassandraKeyspace creates the keyspace using this session for given replica count
func CreateCassandraKeyspace(s gocql.Session, keyspace string, replicas int, overwrite bool, logger log.Logger) (err error) {
// if overwrite flag is set, drop the keyspace and create a new one
if overwrite {
err = DropCassandraKeyspace(s, keyspace, logger)
if err != nil {
logger.Error("drop keyspace error", tag.Error(err))
return
}
}
err = s.Query(fmt.Sprintf(`CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {
'class' : 'SimpleStrategy', 'replication_factor' : %d}`, keyspace, replicas)).Exec()
if err != nil {
logger.Error("create keyspace error", tag.Error(err))
return
}
logger.Debug("created keyspace", tag.Value(keyspace))
return
}
// DropCassandraKeyspace drops the given keyspace, if it exists
func DropCassandraKeyspace(s gocql.Session, keyspace string, logger log.Logger) (err error) {
err = s.Query(fmt.Sprintf("DROP KEYSPACE IF EXISTS %s", keyspace)).Exec()
if err != nil {
logger.Error("drop keyspace error", tag.Error(err))
return
}
logger.Debug("dropped keyspace", tag.Value(keyspace))
return
}