mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
67 lines
1.7 KiB
Go
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
|
|
}
|