Documentation
¶
Overview ¶
Package codegen implements the gotest plugin's code generation logic.
Generates the blueprint_clients.go file that gets added to test packages. This is used internally by the gotest package.
A blueprint_clients.go file is generated for any package where a registry.ServiceRegistry is used. The file adds a static initialization block that registers an instance of the 'real' application client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientBuilder ¶
type ClientBuilder struct { PackageShortName string // The package name to use in the package declaration NamespaceConstructor string // The func that creates the namespace NamespaceName string // The name to use for the namespace OutputDir string // The output directory; should be the same as the package directory Clients []*clientRegistration Imports *gogen.Imports // Manages imports for us }
Used by the gotests plugin to generate the blueprint_clients.go file
func NewClientBuilder ¶
func NewClientBuilder(packageName, packageShortName, namespaceConstructor, namespacePackage, namespaceName, outputDir string) *ClientBuilder
Create a new builder to generate a blueprint_clients.go file.
- outputDir points to an output directory
- packageName should correspond to the correct fully-qualified package name of the outputDir
- packageShortName should correspond to the name to use in the "package" declaration of the file
- namespacePackage is the package to import that contains namespaceConstructor
- namespaceConstructor is of the form shortname.Method - it is the method to call to build the client library
- namespaceName can be any name
func (*ClientBuilder) AddClient ¶
func (b *ClientBuilder) AddClient(registryVar, clientName, nodeToInstantiate string, clientType gocode.TypeName)
Add a client registration to the generated blueprint_clients.go file
- registryVar is a variable name within the output package of a ServiceRegistry[clientType]
- clientName can be any name
- nodeToInstantiate is the node within the namespace to Get to create the client
- clientType is the service interface being created.
func (*ClientBuilder) Build ¶
func (b *ClientBuilder) Build() error
Generate the blueprint_clients.go file.