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

Add check if all blueprint ports are connected #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions cmd/slang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ func runHttpPost(operator *core.Operator, bind string) {

})

// In order to generate a response to a HTTP-Request we need to have
// the out port fully connected. In some cases the out port is a map of multiple
// types and we need them all connected to their `src`. Otherwise we `pull` on the port
// and wait forever to return something. Which would make the client timeout.
if err := operator.Main().Out().FullyConnected(); err != nil {
log.Fatal(err)
}

operator.Main().Out().Bufferize()
operator.Start()
log.Print("started as httpPost")
Expand Down
23 changes: 23 additions & 0 deletions pkg/core/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,29 @@ func (p *Port) Bufferize() {
}
}

// Check port has a `src`
// What is strange though for an operator with a connected delegate this would
// return an error. For instance if you take `controlIterate` and connect the delegate.
// And nothing more it would still work when you `push` and `pull` on `controlIterateId`
func (p *Port) FullyConnected() error {
if p.PrimitiveType() {
if p.src == nil && p.strSrc.src == nil {
return fmt.Errorf("%v is not connected to a source", p.Name())
} else {
return nil
}
} else if p.itemType == TYPE_MAP {
for _, sub := range p.subs {
if err := sub.FullyConnected(); err != nil {
return err
}
}
} else if p.itemType == TYPE_STREAM {
return p.sub.FullyConnected()
}
return nil
}

// PRIVATE METHODS

func setParentStreams(p *Port, parent *Port) {
Expand Down
1 change: 1 addition & 0 deletions pkg/elem/control_iterate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func Test_CtrlIterate__SimpleAggregation(t *testing.T) {
// Connect
require.NoError(t, ao.Delegate("iterator").Out().Connect(fo.Main().In()))
require.NoError(t, fo.Main().Out().Connect(ao.Delegate("iterator").In()))
require.NoError(t, ao.Main().Out().FullyConnected())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo to @td5r: control_iterate out port pushes data but 'port.FullyConnected' returns an error, which indicates, that out port is not connected ... why?!


ao.Main().Out().Bufferize()

Expand Down