Files
tasks/cmd/tools/gensearchattributehelpers/main.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

63 lines
1.4 KiB
Go

package main
import (
_ "embed"
"flag"
"reflect"
"regexp"
historypb "go.temporal.io/api/history/v1"
"github.com/hanzoai/tasks/cmd/tools/codegen"
)
type (
eventData struct {
AttributesTypeName string
}
searchAttributesHelpersData struct {
Events []eventData
}
)
var (
//go:embed search_attribute_helpers.tmpl
searchAttributeHelpersTemplate string
// Is used to find attribute getters and extract the event type (match[1]).
attributesGetterRegex = regexp.MustCompile("^Get(.+EventAttributes)$")
)
func main() {
outPathFlag := flag.String("out", ".", "path to write generated files")
flag.Parse()
codegen.GenerateTemplateToFile(searchAttributeHelpersTemplate, getSearchAttributesHelpersData(), *outPathFlag, "event")
}
func getSearchAttributesHelpersData() searchAttributesHelpersData {
sahd := searchAttributesHelpersData{}
historyEventT := reflect.TypeOf((*historypb.HistoryEvent)(nil))
for i := 0; i < historyEventT.NumMethod(); i++ {
attributesGetter := historyEventT.Method(i)
matches := attributesGetterRegex.FindStringSubmatch(attributesGetter.Name)
if len(matches) < 2 {
continue
}
if attributesGetter.Type.NumOut() != 1 {
continue
}
if _, found := attributesGetter.Type.Out(0).MethodByName("GetSearchAttributes"); !found {
continue
}
ed := eventData{
AttributesTypeName: matches[1],
}
sahd.Events = append(sahd.Events, ed)
}
return sahd
}