Files
tasks/schema/embed.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

67 lines
1.7 KiB
Go

package schema
import (
"embed"
"io/fs"
"path/filepath"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/log/tag"
)
//go:embed *
var assets embed.FS
// Assets returns a file system with the contents of the schema directory
func Assets() fs.FS {
return assets
}
// PathsByDir returns a list of paths to directories within the schema subdirectory that have versioned schemas in them
func PathsByDir(dbSubDir string) []string {
logger := log.NewCLILogger()
efs := Assets()
dirs := make([]string, 0)
err := fs.WalkDir(efs, dbSubDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
if d.Name() == "versioned" {
dirs = append(dirs, filepath.ToSlash(filepath.Dir(path)))
return fs.SkipDir
}
}
return nil
})
if err != nil {
logger.Error("error walking embedded schema file system tree, could not generate valid paths", tag.Error(err))
}
return dirs
}
func PathsByDB(dbName string) []string {
if dbName == "sql" {
return append(PathsByDir("mysql"), PathsByDir("postgresql")...)
}
return PathsByDir(dbName)
}
// ElasticsearchClusterSettings returns the embedded cluster settings for Elasticsearch v7
func ElasticsearchClusterSettings() (string, error) {
data, err := assets.ReadFile("elasticsearch/visibility/cluster_settings_v7.json")
if err != nil {
return "", err
}
return string(data), nil
}
// ElasticsearchIndexTemplate returns the embedded index template for Elasticsearch v7 (latest version)
func ElasticsearchIndexTemplate() (string, error) {
data, err := assets.ReadFile("elasticsearch/visibility/versioned/v14/index_template_v7.json")
if err != nil {
return "", err
}
return string(data), nil
}