Documentation ¶
Overview ¶
starcgen is a tool to generate specialized type assertion shims to be used in Apache Beam Go SDK pipelines instead of the default reflection shim. This is done through static analysis of go sources for the package in question.
The generated type assertion shims have much better performance than the default reflection based shims used by beam. Reflection is convenient for development, but is an unnecessary expense on pipeline performance.
Using This Tool ¶
This tool is intended for use with `go generate`. The recommended convention putting the types and functions used in a separate package from pipeline construction. Then, the tool can be used as follows:
//go:generate go install github.com/apache/beam/sdks/v2/go/cmd/starcgen //go:generate starcgen --package=<mypackagename> //go:generate go fmt
This will generate registrations and shim types for all types and functions in the package, in a file `<mypackagename>.shims.go`.
Alternatively, it's possible to specify the specific input files and identifiers within the package for generation.
//go:generate go install github.com/apache/beam/sdks/v2/go/cmd/starcgen //go:generate starcgen --package=<mypackagename> --inputs=foo.go --identifiers=myFn,myStructFn --output=custom.shims.go //go:generate go fmt