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

Relax ChildAware API requirements #336

Merged
merged 2 commits into from Feb 20, 2023

Conversation

CherryPerry
Copy link
Collaborator

@CherryPerry CherryPerry commented Jan 31, 2023

Description

ChildAware API should allow any type instead of Node subtypes.
The current implementation is too permissive and does not allow to use interfaces as internode communication contract:

interface Child : Connectable<Input, Output> {
  sealed class Input
  sealed class Output
}

// We can't make ChildNode internal like we did in RIBs
class ChildNode(...): Node(...), Child by NodeConnector() {} 
// Somewhere in the parent node
whenChildrenAttached<Child>(...) // <-- Can't use Child interface here right now
whenChildrenAttached<ChildNode>(...) // <-- Have to use node instead with much wider public API

With this change it is possible to use Child interface to setup node connections, but still impossible to make ChildNode class internal. To do it we need to change Builder classes too, either introduce base Node interface like Rib interface or come up with something else.

Check list

  • I have updated CHANGELOG.md if required.
  • I have updated documentation if required.

@@ -53,7 +53,7 @@ class ChildAwareImpl<N : Node> : ChildAware<N> {
}
}

override fun <T : Node> whenChildAttached(
override fun <T : Any> whenChildAttached(
child: KClass<T>,
callback: ChildCallback<T>
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe check if child is a Node to fail early? Rather that never get a callback?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But it is not, that the main point. In my sample Child is just an interface, like we have in our templates.

Copy link
Collaborator

@KovalevAndrey KovalevAndrey left a comment

Choose a reason for hiding this comment

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

I don't mind, but we'll never know if we accidentally pass wrong class

@CherryPerry CherryPerry merged commit d97aef1 into bumble-tech:1.x Feb 20, 2023
@CherryPerry CherryPerry deleted the relax-child-aware branch February 20, 2023 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants