-
Notifications
You must be signed in to change notification settings - Fork 74
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
Breaking: Replace Callbacks interface by Callbacks struct #324
Breaking: Replace Callbacks interface by Callbacks struct #324
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #324 +/- ##
==========================================
+ Coverage 77.24% 77.29% +0.04%
==========================================
Files 25 25
Lines 2303 2281 -22
==========================================
- Hits 1779 1763 -16
+ Misses 420 410 -10
- Partials 104 108 +4 ☔ View full report in Codecov by Sentry. |
@open-telemetry/opamp-go-approvers please take a look, I would like to know what your opinion is. |
The interface has the following downsides: - Impossible to define non-trivial default behavior. Here is an example where it was needed: open-telemetry#269 (comment) - Adding new callbacks requires expanding the interface, which is a breaking change for existing client users. Getting rid of the interface and keeping just a struct for callbacks solves both problems: - Arbitrarily complex default behavior can be now defined on the struct if the user does not provide the particular callback func. - Adding new callback funcs is not a braking change, existing users won't be affected.
e6ea31c
to
2204615
Compare
If we like this direction I will also make similar changes to Server callbacks. |
Thanks @tigrannajaryan, I think this is a nice simplification of the callbacks API! I might suggest preserving the CallbacksStruct type name (although the name is a bit awkward now) for backwards compatibility. Perhaps add a type alias, to avoid breaking the API for people using CallbacksStruct. It could also be given a "Deprecated" comment, so that users can be made aware of its deprecated status by static analysis tools. (https://go.dev/wiki/Deprecated)
|
Thanks, LGTM |
I am not sure about this. It is not just the struct name, we also have to preserve the field names, which all have the "Func" suffix now, otherwise it is a breaking change anyway. |
That's a good point, I didn't notice the field names had changed as well. |
This continues work start in open-telemetry#324 for Client. The interface has the following downsides: - Impossible to define non-trivial default behavior. Here is an example where it was needed: open-telemetry#269 (comment) - Adding new callbacks requires expanding the interface, which is a breaking change for existing client users. Getting rid of the interface and keeping just a struct for callbacks solves both problems: - Arbitrarily complex default behavior can be now defined on the struct if the user does not provide the particular callback func. - Adding new callback funcs is not a braking change, existing users won't be affected.
The interface has the following downsides:
Getting rid of the interface and keeping just a struct for callbacks solves both problems: