Documentation ¶
Overview ¶
Package ir provides the basic interfaces for Blueprint's Internal Representation (IR) and for subsequently generating application artifacts such as code and container images.
An application's IR representation is produced by constructing and then building a wiring spec using methods from the wiring package and from wiring extensions provided by plugins.
Index ¶
- func CleanName(name string) string
- func Filter[T any](nodes []IRNode) []T
- func Is[T any](nodeType any) bool
- func PrettyPrintNamespace(instanceName string, namespaceType string, argNodes []IRNode, ...) string
- func RegisterDefaultNamespace[T IRNode](name string, buildFunc func(outputDir string, nodes []IRNode) error)
- type ApplicationNode
- type ArtifactGenerator
- type BuildContext
- type IRConfig
- type IRMetadata
- type IRNode
- type IRValue
- type VisitTracker
- type VisitTrackerImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanName ¶
Returns name with only alphanumeric characters and all other symbols converted to underscores.
CleanName is primarily used by plugins to convert user-defined service names into names that are valid as e.g. environment variables, command line arguments, etc.
func PrettyPrintNamespace ¶
Types ¶
type ApplicationNode ¶
type ApplicationNode struct { IRNode ArtifactGenerator ApplicationName string Children []IRNode }
The IR Node that represents the whole application. Building a wiring spec will return an ApplicationNode. An ApplicationNode can be built with the GenerateArtifacts method.
func (*ApplicationNode) GenerateArtifacts ¶
func (app *ApplicationNode) GenerateArtifacts(dir string) error
func (*ApplicationNode) Name ¶
func (node *ApplicationNode) Name() string
type ArtifactGenerator ¶
type ArtifactGenerator interface { // Generate all artifacts for this node to the specified dir on the local filesystem. GenerateArtifacts(dir string) error }
Most IRNodes can generate code artifacts but they do so in the context of some BuildContext. A few IRNodes, however, can generate artifacts independent of any external context. Those IRNodes implement the ArtifactGenerator interface. Typically these are namespace nodes such as golang processes, linux containers, or docker deployments.
type BuildContext ¶
type BuildContext interface { VisitTracker ImplementsBuildContext() }
All artifact generation occurs in the context of some BuildContext.
Plugins that control the artifact generation process should implement this interface.
type IRConfig ¶
type IRConfig interface { IRNode Optional() bool // At various points during the build process, an IRConfig node might have a concrete value // set, or it might be left unbound. HasValue() bool // Returns the current value of the config node if it has been set. Config values // are always strings. Value() string ImplementsIRConfig() }
IRConfig is an IR node that represents a configured or configurable variable. In a generated application, IRConfig nodes typically map down to things like environment variables or command line arguments, and can be passed all the way into specific application-level instances. IRConfig is also used for addressing.
type IRMetadata ¶
type IRMetadata interface { IRNode ImplementsIRMetadata() }
Metadata is an IR node that exists in the IR of an application but does not build any artifacts or provide configuration or anything like that.
type IRNode ¶
All nodes implement the IRNode interface
func FilterNodes ¶
Returns a slice containing only nodes of type T
type VisitTracker ¶
type VisitTracker interface { // Returns false on the first invocation of name; true on subsequent invocations Visited(name string) bool }
A Blueprint application can potentially have multiple IR node instances spread across the application that generate the same code.
Visit tracker is a utility method used during artifact generation to prevent nodes from unnecessarily generating the same artifact repeatedly, when once will suffice.
type VisitTrackerImpl ¶
type VisitTrackerImpl struct {
// contains filtered or unexported fields
}
Basic implementation of the VisitTracker interface
func (*VisitTrackerImpl) Visited ¶
func (tracker *VisitTrackerImpl) Visited(name string) bool