Files
temporal/schema/embed.go
Vladyslav Simonenko 400e2ad37f Add external payload size and count to Visibility Schema (#9007)
## What changed?
Added TemporalExternalPayloadSizeBytes and TemporalExternalPayloadCount
to Visibility Schema as pre-defined search attribute.

## Why?
We are planning to expose external payload size and count as the search
attributes. They are pre-defined, rather than system, because they won't
be set on every single workflow, but only ones which store large
payloads externally (e.g. in S3).

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
Incorrectly modified schema
2026-01-23 11:42:08 -08:00

67 lines
1.7 KiB
Go

package schema
import (
"embed"
"io/fs"
"path/filepath"
"go.temporal.io/server/common/log"
"go.temporal.io/server/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
}