-
Notifications
You must be signed in to change notification settings - Fork 224
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
proposal: remove shared connections #179
Comments
Adding the additional convenience functions is a good idea. I'm not sure I'd support deprecating the older ones, I'd just say they are just special case and document the differences. Deprecation implies that they will be removed in the future, but I wouldn't want to see that as it would cause considerable updates when switching major versions, which we'd like to avoid. In general I'd like to see us avoiding any breaking changes in the future and make this library's external API additive only, avoiding the need to incrementing the module number again. |
This whole shared vs. private thing also cost me a lot of time, I was never able to use more than one connection (e.g., listen to UDisks2 and send desktop notifications at the same time). The following works for me, I wonder whether the library could provide a convenience function for it:
At least all examples could be updated with this. |
Feel free to open pull requests if you would like to contribute these enhancements. |
I guess this is mostly closed now with #185. FYI: the shared connections mirror the C API, where they address the case that there are multiple shared libraries that use the bus independently, but should still use the same connection (since multiple connections to the same bus from the same process are possible, but rather wasteful). This also applies to Go bindings in general, but maybe just isn't that relevant unless there actually are multiple libraries in the same process trying to use the same bus. Having easier access to a private connection makes sense, but I'd still keep the shared connections as a concept - maybe we should just make clearer what the implications of using one are. |
Fixes spiffe#4315 The connection to system bus is shared and should not be closed after use in order to avoid errors on concurrent usage. It is typical to share the connection in the same process as per this explanation: godbus/dbus#179 (comment) In case of errors, this shared connection will detect that and attempt to reconnect: https://github.com/godbus/dbus/blob/v5.1.0/conn.go#L124.
Fixes spiffe#4315 The connection to system bus is shared and should not be closed after use in order to avoid errors on concurrent usage. It is typical to share the connection in the same process as per this explanation: godbus/dbus#179 (comment) In case of errors, this shared connection will detect that and attempt to reconnect: https://github.com/godbus/dbus/blob/v5.1.0/conn.go#L124. Signed-off-by: Raghu Kaippully <rkaippully@gmail.com>
* workloadattestor systemd: dbus use of closed network connection Fixes #4315 The connection to system bus is shared and should not be closed after use in order to avoid errors on concurrent usage. It is typical to share the connection in the same process as per this explanation: godbus/dbus#179 (comment) In case of errors, this shared connection will detect that and attempt to reconnect: https://github.com/godbus/dbus/blob/v5.1.0/conn.go#L124. Signed-off-by: Raghu Kaippully <rkaippully@gmail.com> * Use a plugin level shared connection ...instead of a global shared one. This ensures that the connection is never closed by any other library while this plugin is using it. Signed-off-by: Raghu Kaippully <rkaippully@gmail.com> * Fix lint error - context must be the first parameter Signed-off-by: Raghu Kaippully <rkaippully@gmail.com> * incorporate review comments - Implement `Close()` on the plugin to close the DBus connection - Do not export `DBusConn` method - Fix a comment Signed-off-by: Raghu Kaippully <rkaippully@gmail.com> --------- Signed-off-by: Raghu Kaippully <rkaippully@gmail.com> Co-authored-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
I'd propose remove shared connections to make the library less confusing choosing between shared and private connection and generally simplify it.
I've found myself misusing shared connections multiple times, such as closing a connection when it's shared with another part of the code base, subscribing to signals makes receive them other subscribers that don't expect to receive them at all, etc.
It's not possible to pass
ConnOption
toSystemBus
andSessionBus
because if it's called later by another piece of code with different options it'll return an inconsistent result.As for me it's user's responsibility to implement connections sharing and in most situations connection is established once in
main
or a close to main function that passes it down to other clients.For now we can add
DialSystemBus(opts...)
andDialSessionBus(opts...)
and mark current functions as deprecated.Also I'd make calling
Auth
andHello
implicit inDial
function as well, because they are implementation details, and explicit calling them should produce a warning, for low-level we haveNewConn
.The text was updated successfully, but these errors were encountered: