expr

package
v1.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package expr contains the data structure and associated logic that are built by the DSL. These data structures are leveraged by the code generation package to produce the software architecture model and views.

The expression data structures implement interfaces defined by the Goa eval package. The corresponding methods (EvalName, Prepare, Validate, Finalize etc.) are invoked by the eval package when evaluating the DSL.

Index

Constants

This section is empty.

Variables

View Source
var ComponentTags = []string{"Element", "Component"}

ComponentTags lists the tags that are added to all components.

View Source
var ContainerInstanceTags = []string{"Container Instance"}

ContainerInstanceTags list the tags that are automatically added to all container instances.

View Source
var ContainerTags = []string{"Element", "Container"}

ContainerTags lists the tags that are added to all containers.

View Source
var DeploymentNodeTags = []string{"Element", "Deployment Node"}

DeploymentNodeTags list the tags that are automatically added to all deployment nodes.

View Source
var InfrastructureNodeTags = []string{"Element", "Infrastructure Node"}

InfrastructureNodeTags list the tags that are automatically added to all infrastructure nodes.

View Source
var PersonTags = []string{"Element", "Person"}

PersonTags list the tags that are automatically added to all people.

View Source
var Registry = make(map[string]any)

Registry captures all the elements, people and relationships.

View Source
var RelationshipTags = []string{"Relationship", "Asynchronous", "Synchronous"}

RelationshipTags lists the tags that are added to all relationships.

View Source
var Root = &Design{Model: &Model{}, Views: &Views{}}

Root is the design root expression.

View Source
var SoftwareSystemTags = []string{"Element", "Software System"}

SoftwareSystemTags lists the tags that are added to all software systems.

Functions

func Identify

func Identify(element any)

Identify sets the ID field of the given element or relationship and registers it with the global registry. The algorithm first compute a unique moniker for the element or relatioship (based on names and parent scope ID) then hashes and base36 encodes the result.

func Iterate added in v1.5.0

func Iterate(visitor func(elem any))

Iterate iterates through all elements, people and relationships in the registry in a consistent order.

func IterateRelationships added in v1.5.0

func IterateRelationships(visitor func(r *Relationship))

IterateRelationships iterates through all relationships in the registry in a consistent order.

Types

type AnimationStep added in v1.5.0

type AnimationStep struct {
	Elements        []ElementHolder
	RelationshipIDs []string
	Order           int
	View            View
}

AnimationStep represents an animation step.

func (*AnimationStep) Add added in v1.5.0

func (l *AnimationStep) Add(eh ElementHolder)

Add adds the given elements to the animation step.

func (*AnimationStep) EvalName added in v1.5.0

func (*AnimationStep) EvalName() string

EvalName returns the generic expression name used in error messages.

type AutoLayout added in v1.0.4

type AutoLayout struct {
	Implementation ImplementationKind
	RankDirection  RankDirectionKind
	RankSep        *int
	NodeSep        *int
	EdgeSep        *int
	Vertices       *bool
}

AutoLayout describes an automatic layout.

func (*AutoLayout) EvalName added in v1.0.4

func (*AutoLayout) EvalName() string

EvalName returns the generic expression name used in error messages.

type BorderKind

type BorderKind int

BorderKind is the enum used to represent element border styles.

const (
	BorderUndefined BorderKind = iota
	BorderSolid
	BorderDashed
	BorderDotted
)

func (BorderKind) Name added in v1.9.1

func (b BorderKind) Name() string

Name returns the name of the border kind.

type Component

type Component struct {
	*Element
	Container *Container
}

Component represents a component.

func (*Component) EvalName

func (c *Component) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*Component) Finalize

func (c *Component) Finalize()

Finalize adds the 'Component' tag ands finalizes relationships.

type ComponentView

type ComponentView struct {
	*ViewProps
	ContainerBoundariesVisible *bool
	ContainerID                string
}

ComponentView describes a component view for a specific container.

func (*ComponentView) AddAnimationStep added in v1.5.0

func (cv *ComponentView) AddAnimationStep(s *AnimationStep) error

AddAnimationStep adds the given animation step to the view.

func (*ComponentView) AddElements

func (cv *ComponentView) AddElements(ehs ...ElementHolder) error

AddElements adds the given elements to the view if not already present.

type Components

type Components []*Component

Components is a slice of components that can be easily converted into a slice of ElementHolder.

func (Components) Elements

func (cs Components) Elements() []ElementHolder

Elements returns a slice of ElementHolder that contains the elements of c.

type Container

type Container struct {
	*Element
	Components Components
	System     *SoftwareSystem
}

Container represents a container.

func (*Container) AddComponent

func (c *Container) AddComponent(cmp *Component) *Component

AddComponent adds the given component to the container. If there is already a component with the given name then AddComponent merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,

AddComponent returns the new or merged component.

func (*Container) Component

func (c *Container) Component(name string) *Component

Component returns the component with the given name if any, nil otherwise.

func (*Container) EvalName

func (c *Container) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*Container) Finalize

func (c *Container) Finalize()

Finalize adds the 'Container' tag ands finalizes relationships.

type ContainerInstance

type ContainerInstance struct {
	// cheating a bit: a ContainerInstance does not have a name,
	// description, technology or URL.
	*Element
	Parent       *DeploymentNode
	Container    *Container
	HealthChecks []*HealthCheck
	ContainerID  string
	InstanceID   int
	Environment  string
}

ContainerInstance describes an instance of a container.

func (*ContainerInstance) EvalName

func (ci *ContainerInstance) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*ContainerInstance) Finalize

func (ci *ContainerInstance) Finalize()

Finalize adds the "Container Instance" tag if not present.

type ContainerInstances added in v1.5.0

type ContainerInstances []*ContainerInstance

ContainerInstances is a slice of container instances that can be converted into a slice of ElementHolder.

func (ContainerInstances) Elements added in v1.5.0

func (ci ContainerInstances) Elements() []ElementHolder

Elements returns a slice of ElementHolder that contains the elements of ci.

type ContainerView

type ContainerView struct {
	*ViewProps
	SystemBoundariesVisible *bool
	SoftwareSystemID        string
	AddInfluencers          bool
}

ContainerView describes a container view for a specific software system.

func (*ContainerView) AddAnimationStep added in v1.5.0

func (cv *ContainerView) AddAnimationStep(s *AnimationStep) error

AddAnimationStep adds the given animation step to the view.

func (*ContainerView) AddElements

func (cv *ContainerView) AddElements(ehs ...ElementHolder) error

AddElements adds the given elements to the view if not already present.

type Containers

type Containers []*Container

Containers is a slice of containers that can be easily converted into a slice of ElementHolder.

func (Containers) Elements

func (c Containers) Elements() []ElementHolder

Elements returns a slice of ElementHolder that contains the elements of c.

type ContextView

type ContextView struct {
	*ViewProps
	EnterpriseBoundaryVisible *bool
	SoftwareSystemID          string
}

ContextView describes a system context view.

func (*ContextView) AddAnimationStep added in v1.5.0

func (cv *ContextView) AddAnimationStep(s *AnimationStep) error

AddAnimationStep adds the given animation step to the view.

func (*ContextView) AddElements

func (cv *ContextView) AddElements(ehs ...ElementHolder) error

AddElements adds the given elements to the view if not already present.

type DeploymentEnvironment

type DeploymentEnvironment struct {
	// Name of environment.
	Name string
}

DeploymentEnvironment provides context to the other deployment expressions.

func (*DeploymentEnvironment) EvalName

func (d *DeploymentEnvironment) EvalName() string

EvalName returns the generic expression name used in error messages.

type DeploymentNode

type DeploymentNode struct {
	*Element
	Parent              *DeploymentNode
	Children            []*DeploymentNode
	InfrastructureNodes []*InfrastructureNode
	ContainerInstances  []*ContainerInstance
	Instances           *string
	Environment         string
}

DeploymentNode describes a single deployment node.

func (*DeploymentNode) AddChild

func (d *DeploymentNode) AddChild(n *DeploymentNode) *DeploymentNode

AddChild adds the given child deployment node to the parent. If there is already a deployment node with the given name then AddChild merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,
  • merges any new child deployment node into the existing children,
  • merges any new container instance or infrastructure nodes into existing ones.

AddChild returns the new or merged deployment node.

func (*DeploymentNode) AddContainerInstance

func (d *DeploymentNode) AddContainerInstance(ci *ContainerInstance) *ContainerInstance

AddContainerInstance adds the given container instance to the deployment node. If there is already a container instance with the given container and instance ID then AddContainerInstance merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,
  • merges any new health check into the existing health checks.

AddContainerInstance returns the new or merged container instance.

func (*DeploymentNode) AddInfrastructureNode

func (d *DeploymentNode) AddInfrastructureNode(n *InfrastructureNode) *InfrastructureNode

AddInfrastructureNode adds the given infrastructure node to the deployment node. If there is already an infrastructure node with the given name then AddInfrastructureNode merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties.

AddInfrastructureNode returns the new or merged infrastructure node.

func (*DeploymentNode) Child

func (d *DeploymentNode) Child(name string) *DeploymentNode

Child returns the child deployment node with the given name if any, nil otherwise.

func (*DeploymentNode) ContainerInstanceByID added in v1.7.4

func (d *DeploymentNode) ContainerInstanceByID(containerID string, instanceID int) *ContainerInstance

ContainerInstanceByID returns the container instance for the given container with the given instance ID if any, nil otherwise.

func (*DeploymentNode) ContainerInstanceByName added in v1.7.4

func (d *DeploymentNode) ContainerInstanceByName(name string, instanceID int) *ContainerInstance

ContainerInstanceByName returns the container instance for the given container with the given name if any, nil otherwise.

Note that in theory there could be be multiple containers with the given name coming from different software systems in a single deployment node. In practice the likelyhood of this happening seems pretty slim so we'll keep it simple for now...

func (*DeploymentNode) EvalName

func (d *DeploymentNode) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*DeploymentNode) Finalize

func (d *DeploymentNode) Finalize()

Finalize adds the 'Deployment Node' tag ands finalizes relationships.

func (*DeploymentNode) InfrastructureNode

func (d *DeploymentNode) InfrastructureNode(name string) *InfrastructureNode

InfrastructureNode returns the infrastructure node with the given name if any, nil otherwise.

type DeploymentView

type DeploymentView struct {
	*ViewProps
	SoftwareSystemID string
	Environment      string
}

DeploymentView describes a deployment view.

func (*DeploymentView) AddAnimationStep added in v1.5.0

func (dv *DeploymentView) AddAnimationStep(s *AnimationStep) error

AddAnimationStep adds the given animation step to the view.

func (*DeploymentView) AddElements

func (dv *DeploymentView) AddElements(ehs ...ElementHolder) error

AddElements adds the given elements to the view if not already present.

type Design added in v1.5.0

type Design struct {
	Name        string
	Description string
	Version     string
	Model       *Model
	Views       *Views
}

Design contains the AST generated from the DSL.

func (*Design) DependsOn added in v1.5.0

func (*Design) DependsOn() []eval.Root

DependsOn tells the eval engine to run the goa DSL first.

func (*Design) DeploymentNode added in v1.5.0

func (d *Design) DeploymentNode(env, name string) *DeploymentNode

DeploymentNode returns the deployment node with the given name in the given environment if any, nil otherwise.

func (*Design) EvalName added in v1.5.0

func (*Design) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*Design) Packages added in v1.5.0

func (*Design) Packages() []string

Packages returns the import path to the Go packages that make up the DSL. This is used to skip frames that point to files in these packages when computing the location of errors.

func (*Design) Person added in v1.5.0

func (d *Design) Person(name string) *Person

Person returns the person with the given name if any, nil otherwise.

func (*Design) SoftwareSystem added in v1.5.0

func (d *Design) SoftwareSystem(name string) *SoftwareSystem

SoftwareSystem returns the software system with the given name if any, nil otherwise.

func (*Design) WalkSets added in v1.5.0

func (d *Design) WalkSets(walk eval.SetWalker)

WalkSets iterates over the elements and views. Elements DSL cannot be executed on init because all elements must first be loaded and their IDs captured in the registry before relationships can be built with DSL.

type DynamicView

type DynamicView struct {
	*ViewProps
	ElementID string
}

DynamicView describes a dynamic view for a specified scope.

type Element

type Element struct {
	ID            string
	Name          string
	Description   string
	Technology    string
	Tags          string
	URL           string
	Properties    map[string]string
	Relationships []*Relationship
	DSLFunc       func()
}

Element describes an element.

func (*Element) DSL

func (e *Element) DSL() func()

DSL returns the attached DSL.

func (*Element) Finalize

func (e *Element) Finalize()

Finalize finalizes the relationships.

func (*Element) GetElement

func (e *Element) GetElement() *Element

GetElement returns the underlying element.

func (*Element) MergeTags

func (e *Element) MergeTags(tags ...string)

MergeTags adds the given tags. It skips tags already present in e.Tags.

func (*Element) PrefixTags added in v1.5.0

func (e *Element) PrefixTags(tags ...string)

PrefixTags adds the given tags to the beginning of the comma separated list.

type ElementHolder

type ElementHolder interface {
	GetElement() *Element
}

ElementHolder provides access to the underlying element.

func Parent added in v1.5.0

func Parent(eh ElementHolder) ElementHolder

Parent returns the parent scope for the given element, nil if eh is a Person or SoftwareSystem.

type ElementStyle

type ElementStyle struct {
	Tag         string
	Shape       ShapeKind
	Icon        string
	Background  string
	Color       string
	Stroke      string
	Width       *int
	Height      *int
	FontSize    *int
	Metadata    *bool
	Description *bool
	Opacity     *int
	Border      BorderKind
}

ElementStyle defines an element style.

func (*ElementStyle) EvalName

func (es *ElementStyle) EvalName() string

EvalName returns the generic expression name used in error messages.

type ElementView

type ElementView struct {
	Element        *Element
	NoRelationship bool
	X              *int
	Y              *int
}

ElementView describes an instance of a model element (Person, Software System, Container or Component) in a View.

func (*ElementView) EvalName

func (*ElementView) EvalName() string

EvalName returns the generic expression name used in error messages.

type FilteredView

type FilteredView struct {
	Title       string
	Description string
	Key         string `json:"key"`
	BaseKey     string
	Exclude     bool
	FilterTags  []string
}

FilteredView describes a filtered view on top of a specified view.

func (*FilteredView) EvalName

func (fv *FilteredView) EvalName() string

EvalName returns the generic expression name used in error messages.

type HealthCheck

type HealthCheck struct {
	Name     string
	URL      string
	Interval int
	Timeout  int
	Headers  map[string]string
}

HealthCheck is a HTTP-based health check.

func (*HealthCheck) EvalName

func (hc *HealthCheck) EvalName() string

EvalName returns the generic expression name used in error messages.

type ImplementationKind added in v1.9.1

type ImplementationKind int

ImplementationKind is the enum for possible automatic layout implementations

const (
	ImplementationUndefined ImplementationKind = iota
	ImplementationGraphviz
	ImplementationDagre
)

type InfrastructureNode

type InfrastructureNode struct {
	*Element
	Parent      *DeploymentNode
	Environment string
}

InfrastructureNode describes an infrastructure node.

func (*InfrastructureNode) EvalName

func (i *InfrastructureNode) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*InfrastructureNode) Finalize

func (i *InfrastructureNode) Finalize()

Finalize adds the 'Infrastructure Node' tag ands finalizes relationships.

type InfrastructureNodes added in v1.5.0

type InfrastructureNodes []*InfrastructureNode

InfrastructureNodes is a slice of infrastructure nodes that can be converted into a slice of ElementHolder.

func (InfrastructureNodes) Elements added in v1.5.0

func (inf InfrastructureNodes) Elements() []ElementHolder

Elements returns a slice of ElementHolder that contains the elements of inf.

type InteractionStyleKind

type InteractionStyleKind int

InteractionStyleKind is the enum for possible interaction styles.

const (
	// InteractionUndefined means no interaction style specified in design.
	InteractionUndefined InteractionStyleKind = iota
	// InteractionSynchronous describes a synchronous interaction.
	InteractionSynchronous
	// InteractionAsynchronous describes an asynchronous interaction.
	InteractionAsynchronous
)

type LandscapeView

type LandscapeView struct {
	*ViewProps
	EnterpriseBoundaryVisible *bool
}

LandscapeView describes a system landscape view.

func (*LandscapeView) AddAnimationStep added in v1.5.0

func (cv *LandscapeView) AddAnimationStep(s *AnimationStep) error

AddAnimationStep adds the given animation step to the view.

func (*LandscapeView) AddElements

func (cv *LandscapeView) AddElements(ehs ...ElementHolder) error

AddElements adds the given elements to the view if not already present.

type LocationKind

type LocationKind int

LocationKind is the enum for possible locations.

const (
	// LocationUndefined means no location specified in design.
	LocationUndefined LocationKind = iota
	// LocationInternal defines an element internal to the enterprise.
	LocationInternal
	// LocationExternal defines an element external to the enterprise.
	LocationExternal
)

type Model

type Model struct {
	Enterprise              string
	People                  People
	Systems                 SoftwareSystems
	DeploymentNodes         []*DeploymentNode
	AddImpliedRelationships bool
}

Model describes a software architecture model.

func (*Model) AddDeploymentNode

func (m *Model) AddDeploymentNode(d *DeploymentNode) *DeploymentNode

AddDeploymentNode adds the given deployment node to the model. If there is already a deployment node with the given name then AddDeploymentNode merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,
  • merges any new relationship into the existing relationships,
  • merges any new child deployment node into the existing children,
  • merges any new container instance or infrastructure nodes into existing ones.

AddDeploymentNode returns the new or merged deployment node.

func (*Model) AddPerson

func (m *Model) AddPerson(p *Person) *Person

AddPerson adds the given person to the model. If there is already a person with the given name then AddPerson merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,
  • merges any new relationship into the existing relationships.

AddPerson returns the new or merged person.

func (*Model) AddSystem

func (m *Model) AddSystem(s *SoftwareSystem) *SoftwareSystem

AddSystem adds the given software system to the model. If there is already a software system with the given name then AddSystem merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,
  • merges any new relationship into the existing relationships,
  • merges any new container into the existing containers.

AddSystem returns the new or merged software system.

func (*Model) DeploymentNode

func (m *Model) DeploymentNode(env, name string) *DeploymentNode

DeploymentNode returns the deployment node with the given name if any, nil otherwise.

func (*Model) EvalName

func (*Model) EvalName() string

EvalName is the qualified name of the DSL expression.

func (*Model) Finalize

func (m *Model) Finalize()

Finalize adds all implied relationships if needed.

func (*Model) FindElement

func (m *Model) FindElement(scope ElementHolder, path string) (eh ElementHolder, err error)

FindElement finds the element with the given path in the given scope. The path must be one of:

  • "<Person>", "<SoftwareSystem>", "<SoftwareSystem>/<Container>" or "<SoftwareSystem>/<Container>/<Component>"
  • "<Container>" (if container is a child of the software system scope)
  • "<Component>" (if component is a child of the container scope)
  • "<Container>/<Component>" (if container is a child of the software system scope)

The scope may be nil in which case the path must be rooted with a top level element (person or software system).

func (*Model) Person

func (m *Model) Person(name string) *Person

Person returns the person with the given name if any, nil otherwise.

func (*Model) SoftwareSystem

func (m *Model) SoftwareSystem(name string) *SoftwareSystem

SoftwareSystem returns the software system with the given name if any, nil otherwise.

func (*Model) Validate

func (m *Model) Validate() error

Validate makes sure all element names are unique.

type PaperSizeKind

type PaperSizeKind int

PaperSizeKind is the enum for possible paper kinds.

const (
	SizeUndefined PaperSizeKind = iota
	SizeA0Landscape
	SizeA0Portrait
	SizeA1Landscape
	SizeA1Portrait
	SizeA2Landscape
	SizeA2Portrait
	SizeA3Landscape
	SizeA3Portrait
	SizeA4Landscape
	SizeA4Portrait
	SizeA5Landscape
	SizeA5Portrait
	SizeA6Landscape
	SizeA6Portrait
	SizeLegalLandscape
	SizeLegalPortrait
	SizeLetterLandscape
	SizeLetterPortrait
	SizeSlide16X10
	SizeSlide16X9
	SizeSlide4X3
)

type People

type People []*Person

People is a slide of Person that can easily be converted into a slice of ElementHolder.

func (People) Elements

func (p People) Elements() []ElementHolder

Elements returns a slice of ElementHolder that contains the people.

type Person

type Person struct {
	*Element
	Location LocationKind
}

Person represents a person.

func (*Person) EvalName

func (p *Person) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*Person) Finalize

func (p *Person) Finalize()

Finalize adds the 'Person' tag ands finalizes relationships.

type RankDirectionKind

type RankDirectionKind int

RankDirectionKind is the enum for possible automatic layout rank directions.

const (
	RankUndefined RankDirectionKind = iota
	RankTopBottom
	RankBottomTop
	RankLeftRight
	RankRightLeft
)

type Relationship

type Relationship struct {
	ID               string
	Source           *Element
	Description      string
	Technology       string
	InteractionStyle InteractionStyleKind
	Tags             string
	URL              string

	// DestinationPath is used to compute the destination after all DSL has
	// completed execution.
	DestinationPath string

	// Destination is only guaranteed to be initialized after the DSL has
	// been executed. It can be used in validations and finalizers.
	Destination *Element

	// LinkedRelationshipID is the ID of the relationship pointing to the
	// container corresponding to the container instance with this
	// relationship.
	LinkedRelationshipID string
}

Relationship describes a uni-directional relationship between two elements.

func (*Relationship) Dup

func (r *Relationship) Dup(newSrc, newDest *Element) *Relationship

PrefixTags adds the given tags to the beginning of the comm Dup creates a new relationship with identical description, tags, URL, technology and interaction style as r. Dup also creates a new ID for the result.

func (*Relationship) EvalName

func (r *Relationship) EvalName() string

EvalName is the qualified name of the expression.

func (*Relationship) Finalize

func (r *Relationship) Finalize()

Finalize computes the destination and adds the "Relationship" tag.

func (*Relationship) MergeTags

func (r *Relationship) MergeTags(tags ...string)

MergeTags adds the given tags. It skips tags already present in e.Tags.

type RelationshipStyle

type RelationshipStyle struct {
	Tag       string
	Thickness *int
	FontSize  *int
	Width     *int
	Position  *int
	Color     string
	Stroke    string
	Dashed    *bool
	Routing   RoutingKind
	Opacity   *int
}

RelationshipStyle defines a relationship style.

func (*RelationshipStyle) EvalName

func (rs *RelationshipStyle) EvalName() string

EvalName returns the generic expression name used in error messages.

type RelationshipView

type RelationshipView struct {
	Source      *Element
	Destination *Element
	Description string
	Order       string
	Vertices    []*Vertex
	Routing     RoutingKind
	Position    *int

	// RelationshipID is computed in finalize.
	RelationshipID string
}

RelationshipView describes an instance of a model relationship in a view.

func (*RelationshipView) EvalName

func (*RelationshipView) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*RelationshipView) Validate added in v1.5.0

func (v *RelationshipView) Validate() error

Validate makes sure there is a corresponding relationship (and exactly one).

type RoutingKind

type RoutingKind int

RoutingKind is the enum for possible routing algorithms.

const (
	RoutingUndefined RoutingKind = iota
	RoutingDirect
	RoutingOrthogonal
	RoutingCurved
)

type ShapeKind

type ShapeKind int

ShapeKind is the enum used to represent shapes used to render elements.

const (
	ShapeUndefined ShapeKind = iota
	ShapeBox
	ShapeCircle
	ShapeCylinder
	ShapeEllipse
	ShapeHexagon
	ShapeRoundedBox
	ShapeComponent
	ShapeFolder
	ShapeMobileDeviceLandscape
	ShapeMobileDevicePortrait
	ShapePerson
	ShapePipe
	ShapeRobot
	ShapeWebBrowser
)

func (ShapeKind) Name added in v1.9.1

func (s ShapeKind) Name() string

Name returns then name of the shape.

type SoftwareSystem

type SoftwareSystem struct {
	*Element
	Location   LocationKind
	Containers Containers
}

SoftwareSystem represents a software system.

func (*SoftwareSystem) AddContainer

func (s *SoftwareSystem) AddContainer(c *Container) *Container

AddContainer adds the given container to the software system. If there is already a container with the given name then AddContainer merges both definitions. The merge algorithm:

  • overrides the description, technology and URL if provided,
  • merges any new tag or propery into the existing tags and properties,
  • merges any new component into the existing components.

AddContainer returns the new or merged person.

func (*SoftwareSystem) Container

func (s *SoftwareSystem) Container(name string) *Container

Container returns the container with the given name if any, nil otherwise.

func (*SoftwareSystem) EvalName

func (s *SoftwareSystem) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*SoftwareSystem) Finalize

func (s *SoftwareSystem) Finalize()

Finalize adds the 'SoftwareSystem' tag ands finalizes relationships.

type SoftwareSystems

type SoftwareSystems []*SoftwareSystem

SoftwareSystems is a slice of software system that can be easily converted into a slice of ElementHolder.

func (SoftwareSystems) Elements

func (s SoftwareSystems) Elements() []ElementHolder

Elements returns a slice of ElementHolder that contains the elements of s.

type Styles

type Styles struct {
	Elements      []*ElementStyle
	Relationships []*RelationshipStyle
}

Styles describes the styles for a view.

func (*Styles) EvalName added in v1.5.0

func (*Styles) EvalName() string

EvalName returns the generic expression name used in error messages.

type Vertex

type Vertex struct {
	X int
	Y int
}

Vertex describes the x and y coordinate of a bend in a line.

type View

type View interface {
	Props() *ViewProps
}

View is the common interface for all views.

type ViewAdder

type ViewAdder interface {
	AddElements(...ElementHolder) error
	AddAnimationStep(*AnimationStep) error
}

ViewAdder is the interface implemented by views that allow adding elements and animations explicitly.

type ViewProps

type ViewProps struct {
	Key               string
	Description       string
	Title             string
	AutoLayout        *AutoLayout
	PaperSize         PaperSizeKind
	ElementViews      []*ElementView
	RelationshipViews []*RelationshipView
	AnimationSteps    []*AnimationStep

	// The following fields are used to compute the elements and
	// relationships that should be added to the view.
	AddAll              bool
	AddDefault          bool
	AddNeighbors        []*Element
	RemoveElements      []*Element
	RemoveTags          []string
	RemoveRelationships []*Relationship
	RemoveUnreachable   []*Element
	RemoveUnrelated     bool
}

ViewProps contains common properties of a view as well as helper methods to fetch them.

func (*ViewProps) ElementView

func (v *ViewProps) ElementView(id string) *ElementView

ElementView returns the element view for the element with the given ID if any.

func (*ViewProps) EvalName

func (v *ViewProps) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*ViewProps) Props

func (v *ViewProps) Props() *ViewProps

Props returns the underlying properties object.

type Views

type Views struct {
	LandscapeViews  []*LandscapeView
	ContextViews    []*ContextView
	ContainerViews  []*ContainerView
	ComponentViews  []*ComponentView
	DynamicViews    []*DynamicView
	DeploymentViews []*DeploymentView
	FilteredViews   []*FilteredView
	Styles          *Styles
	DSLFunc         func()
}

Views is the container for all views.

func (Views) All added in v1.5.0

func (vs Views) All() (vps []View)

All returns all the views in a single slice.

func (*Views) DSL

func (vs *Views) DSL() func()

DSL returns the DSL to execute.

func (*Views) EvalName

func (*Views) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*Views) Finalize

func (vs *Views) Finalize()

Finalize relationships.

func (*Views) Validate

func (vs *Views) Validate() error

Validate makes sure the right element are in the right views, it also makes sure all animation steps have elements.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL