Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Endpoint/Calls in favor of Component #529

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/mdl/webapp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions dsl/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,54 +235,6 @@ func Component(name string, args ...interface{}) *expr.Component {
return container.AddComponent(c)
}

// Endpoint defines an endpoint on a container. The endpoint may be a REST
// endpoint, a gRPC endpoint or any other kind of endpoint.
//
// Endpoint must appear in a Container expression.
//
// Endpoint takes 1 to 2 arguments: the endpoint name and an optional
// description.
//
// The valid syntax for Endpoint is thus:
//
// Endpoint("<name>", "[description]")
//
// Example:
//
// var _ = Design(func() {
// SoftwareSystem("My system", "A system with a great architecture", func() {
// Container("My container", "A container with a great architecture", "Go and Goa", func() {
// Endpoint("MyEndpoint", "An endpoint")
// })
// })
// })
func Endpoint(name string, args ...interface{}) {
container, ok := eval.Current().(*expr.Container)
if !ok {
eval.IncompatibleDSL()
return
}
if len(args) > 1 {
eval.ReportError("Endpoint: too many arguments")
return
}
description, _, _, err := parseElementArgs(args...)
if err != nil {
eval.ReportError("Endpoint: " + err.Error())
return
}
for _, e := range container.Endpoints {
if e.Name == name {
eval.ReportError("Endpoint %q already defined", name)
return
}
}
container.Endpoints = append(container.Endpoints, &expr.Endpoint{
Name: name,
Description: description,
})
}

// parseElement is a helper function that parses the given element DSL
// arguments. Accepted syntax are:
//
Expand Down
46 changes: 0 additions & 46 deletions dsl/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,52 +240,6 @@ func Delivers(person interface{}, description string, args ...interface{}) {

}

// Calls specifies a list of endpoint names that the relationship source calls.
// The target of the relationship must be a container.
//
// Calls must appear in Uses.
//
// Calls takes one or more arguments each of which is the name of an endpoint
// defined in the target container.
//
// Usage:
//
// Calls("endpoint")
//
// Calls("endpoint1", "endpoint2")
//
// Example:
//
// var _ = Design("my workspace", "a great architecture model", func() {
// SoftwareSystem("SystemA", func() {
// Container("ContainerA", func() {
// Uses("ContainerB", "Uses", func() {
// Calls("endpoint1", "endpoint2")
// })
// })
// })
// })
func Calls(endpoints ...string) {
v, ok := eval.Current().(*expr.Relationship)
if !ok {
eval.IncompatibleDSL()
return
}
for _, e := range endpoints {
if e == "" {
eval.ReportError("Calls: endpoint name cannot be empty")
return
}
for _, ep := range v.Endpoints {
if ep == e {
eval.ReportError("Calls: endpoint %q already defined", e)
return
}
}
v.Endpoints = append(v.Endpoints, e)
}
}

// Description provides a short description for a relationship displayed in a
// dynamic view.
//
Expand Down
8 changes: 4 additions & 4 deletions examples/json/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ var _ = Design("Getting Started", "This is a model of my software system.", func
Tag("database")
})
Container("Web Application", "Delivers content to users.", func() {
Endpoint("Web", "Delivers HTML pages.")
Component("Dashboard Endpoint", "Serve dashboard content.", func() {
Tag("endpoint")
})
Uses("Application Database", "Reads from and writes to", "MySQL", Synchronous)
})
Container("Load Balancer", "Distributes requests across the Web Application instances.", func() {
Uses("Web Application", "Routes requests to", "HTTPS", Synchronous, func() {
Calls("Web")
})
Uses("Web Application/Dashboard Endpoint", "Routes requests to", "HTTPS", Synchronous)
})
Tag("system")
})
Expand Down
11 changes: 0 additions & 11 deletions expr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,10 @@ type (
// Container represents a container.
Container struct {
*Element
Endpoints []*Endpoint
Components Components
System *SoftwareSystem
}

// Endpoint describes a container endpoint.
//
// Note: Endpoint information is not used directly in diagrams instead
// it is serialized in the system JSON representation for other tools to
// consume.
Endpoint struct {
Name string
Description string
}

// Containers is a slice of containers that can be easily
// converted into a slice of ElementHolder.
Containers []*Container
Expand Down
1 change: 0 additions & 1 deletion expr/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type (
InteractionStyle InteractionStyleKind
Tags string
URL string
Endpoints []string

// DestinationPath is used to compute the destination after all DSL has
// completed execution.
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/jaschaephraim/lrserver v0.0.0-20171129202958-50d19f603f71
github.com/kylelemons/godebug v1.1.0
goa.design/goa/v3 v3.13.2
golang.org/x/tools v0.13.0
golang.org/x/tools v0.14.0
)

require (
Expand All @@ -19,8 +19,8 @@ require (
github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
)
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,22 @@ goa.design/goa/v3 v3.13.2 h1:RclNIpo7891ZqGRVO4fpBjT7Fs7LjBNm78i8J41KHrI=
goa.design/goa/v3 v3.13.2/go.mod h1:VvZsuC8CSIUQOHVqk6Ep3MFSFz21OjOv87UPqCHiB94=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
Expand Down
13 changes: 0 additions & 13 deletions mdl/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func modelizeRelationships(rels []*expr.Relationship) []*Relationship {
Description: r.Description,
Tags: r.Tags,
URL: r.URL,
Endpoints: r.Endpoints,
SourceID: r.Source.ID,
DestinationID: r.Destination.ID,
Technology: r.Technology,
Expand Down Expand Up @@ -180,7 +179,6 @@ func modelizeContainers(cs []*expr.Container) []*Container {
Properties: c.Properties,
Relationships: modelizeRelationships(c.Relationships),
Components: modelizeComponents(c.Components),
Endpoints: modelizeEndpoints(c.Endpoints),
}
}
return res
Expand All @@ -203,17 +201,6 @@ func modelizeComponents(cs []*expr.Component) []*Component {
return res
}

func modelizeEndpoints(es []*expr.Endpoint) []*Endpoint {
res := make([]*Endpoint, len(es))
for i, e := range es {
res[i] = &Endpoint{
Name: e.Name,
Description: e.Description,
}
}
return res
}

func modelizeDeploymentNodes(dns []*expr.DeploymentNode) []*DeploymentNode {
res := make([]*DeploymentNode, len(dns))
for i, dn := range dns {
Expand Down
2 changes: 0 additions & 2 deletions mdl/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ type (
Tags string `json:"tags,omitempty"`
// URL where more information can be found.
URL string `json:"url,omitempty"`
// Endpoints of relationship if any.
Endpoints []string `json:"endpoints,omitempty"`
// SourceID is the ID of the source element.
SourceID string `json:"sourceId"`
// DestinationID is ID the destination element.
Expand Down
Loading