Licensing: allow multiple registration of the same feature#76272
Licensing: allow multiple registration of the same feature#76272pgayvallet merged 1 commit intoelastic:masterfrom
Conversation
| const registered = this.lastUsages.get(featureName); | ||
| if (registered) { | ||
| if (registered.licenseType !== licenseType) { | ||
| throw new Error( | ||
| `Feature '${featureName}' has already been registered with another license type. (current: ${registered.licenseType}, new: ${licenseType})` | ||
| ); | ||
| } | ||
| } else { |
There was a problem hiding this comment.
@restrry This is the easiest fix for the problem, and answer the need.
Another option would be to instead adapt the client-side service to fetch the list of already registered features from the server-side during setup and to not perform calls to the server when trying to register an already existing feature. This is just a little trickier if we want to keep the client-side service synchronous
as it would mean creating the fetch promise during setup and await for its result in every call to register. But nothing that can't be done. Do you think this would be better?
There was a problem hiding this comment.
I like the solution you have in PR. It's simpler and less likely to break IMO.
|
Other option could be to allow multiple |
|
Yea, that would be another possibility |
💚 Build SucceededBuild metrics
To update your PR or re-run it, just comment with: |
|
Pinging @elastic/kibana-platform (Team:Platform) |
| const registered = this.lastUsages.get(featureName); | ||
| if (registered) { | ||
| if (registered.licenseType !== licenseType) { | ||
| throw new Error( | ||
| `Feature '${featureName}' has already been registered with another license type. (current: ${registered.licenseType}, new: ${licenseType})` | ||
| ); | ||
| } | ||
| } else { |
There was a problem hiding this comment.
I like the solution you have in PR. It's simpler and less likely to break IMO.
Summary
Adapt the
FeatureUsageservice to accept multiple registrations of the same feature, as long as thelicenseTypeis the same.This is driven by the fact that features can now be registered from the client-side, so every refresh or new client can call this API, resulting in multiple calls.
Checklist