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

Introducing ChannelProvidingConnection #36

Closed
wants to merge 1 commit into from

Conversation

edwarnicke
Copy link
Contributor

api.Connection is a very convenient interface for using
the RPC style binapi

Unfortunately, in order to Subscribe to Events like
interfaces.SwInterfaceEvent{} you have to have an api.Channel
against which you can call SubscribeNotification

Conveniently, core.Connection implements both api.Connection and
api.ChannelProvider.

Unfortunately, we have no type with which a function can indicate
it requires both of those interfaces.

ChannelProvidingConnection implements both api.ChannelProvider and
api.Connection allowing it to be used as a parameter to functions
which require an argument that implements both.

Signed-off-by: Ed Warnicke [email protected]

api.Connection is a very convenient interface for using
the RPC style binapi

Unfortunately, in order to Subscribe to Events like
interfaces.SwInterfaceEvent{} you have to have an api.Channel
against which you can call SubscribeNotification

Conveniently, core.Connection implements both api.Connection and
api.ChannelProvider.

Unfortunately,  we have no type with which a function can indicate
it requires *both* of those interfaces.

ChannelProvidingConnection implements both api.ChannelProvider and
api.Connection allowing it to be used as a parameter to functions
which require an argument that implements both.

Signed-off-by: Ed Warnicke <[email protected]>
@edwarnicke
Copy link
Contributor Author

I introduced this because I've found need to introduce it in multiple different places.

@ondrej-fabry
Copy link
Member

ondrej-fabry commented Sep 8, 2022

This combined interface of Connection and ChannelProvider was purposefully omitted when the Connection and Stream were introduced.

The main reason behind this is that Channel should eventually be deprecated. So providing interface like this seems like adding extra work for users after they need to switch later and also possibly confusing users with the redundant ways to do things.

Rather, we should make ourselves more clear to the users about the planned intentions with the API. For this reason and also to open more broad discussion related to this I have created an issue where I started putting info related to this: Stream API & RPC services

The missing support for subscription/events is on point though, they are the missing piece in the Stream API. I have not mentioned it in the issue yet, but planning to update it with some info for this too.

Summary

I think adding this interface would make more work for us and the users in the long run compared the the work users currently need to do to achieve the same. One of the Go Proverbs is "A little copying is better than a little dependency."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants