Package shimx specifies the templates for generating type assertion shims for Apache Beam Go SDK pipelines.
In particular, the shims are used by the Beam Go SDK to avoid reflection at runtime, which is the default mode of operation. The shims are specialized for the code in question, using type assertion to convert arguments as required, and invoke the user code.
Similar shims are required for emitters, and iterators in order to propagate values out of, and in to user functions respectively without reflection overhead.
Registering user types is required to support user types as PCollection types, while registering functions is required to avoid possibly expensive function resolution at worker start up, which defaults to using DWARF Symbol tables.
The generator largely relies on basic types and strings to ensure that it's usable by dynamic processes via reflection, or by any static analysis approach that is used in the future.
var ( ExecImport = "github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec" TypexImport = "github.com/apache/beam/sdks/go/pkg/beam/core/typex" ReflectxImport = "github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx" RuntimeImport = "github.com/apache/beam/sdks/go/pkg/beam/core/runtime" )
Beam imports that the generated code requires.
File writes go code to the given writer.
FuncName returns a compilable Go identifier for a function, given valid type names as generated by Name. See https://golang.org/ref/spec#Identifiers for details.
Name creates a capitalized identifier from a type string. The identifier follows the rules of go identifiers and should be compileable. See https://golang.org/ref/spec#Identifiers for details.
Emitter represents an emitter shim to be generated.
Func represents a type assertion shim for function invocation to be generated.
Input represents an iterator shim to be generated.
Top is the top level inputs into the template file for generating shims.
Wrap represents a type assertion shim for Structural DoFn method invocation to be generated.