-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Initial implementation of server licensing service #41026
Conversation
Pinging @elastic/kibana-platform |
Right now the current return value of setting up the server licensing service returns a type LicensingServiceSubject = BehaviorSubject<LicensingServiceSetup | null>;
const licensing: LicensingServiceSubject;
// ...
licensing.subscribe(license => {
if (!license) {
// Service is null until polled and started.
return;
}
const { status, message } = license.check('discovery', LICENSE_TYPE.gold);
// ...
}); |
f78bdb4
to
0415e96
Compare
from(this.fetchInfo(deps, clusterSource, pollingFrequency)).pipe( | ||
tap(({ license, error, features }) => { | ||
// If license is false, the license did not change and we don't need to push | ||
// a new one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 91 it returns false if the license did change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
💔 Build Failed |
Overall, this is looking like how I would expect it to 👍 Per our discussion in the weekly, I would advise changing the interface exposed by the service to be a Observable of some interface rather than a class, and then you can implement that interface in the class. This makes testing and mocking easier for consumers. #39446 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious so I had to look. 😄 Had some comments I thought worth sharing, feel free to disregard them.
private serializable: LicenseFeatureSerializer = service => ({ | ||
name: this.name, | ||
isAvailable: this.isAvailable, | ||
isEnabled: this.isEnabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between isAvailable
and isEnabled
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a clue, I'll see what I can find out. 😄
|
||
private hasLicenseInfoChanged(newLicense: any) { | ||
return ( | ||
newLicense.mode !== this.license.mode || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's mode
? If this corresponds to the LICENSE_TYPE
enum, then maybe type
would make that clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was preexisting from x-pack legacy, so I'll see about making this clearer.
private clusterSource: string | ||
) { | ||
this._license = license; | ||
this.license = license || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably won't ever maintain this code, but if I did, I think I would be confused by the presence of this._license
and this.license
. I would be able to follow this code more easily if we only had one or the other. It looks like this._license
is only used to assert whether there is a license or not. In that case, could we do this instead?
constructor(
license: any,
features: any,
private error: Error | null,
private clusterSource: string
) {
this.hasLicense = Boolean(license);
this.license = license || {};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree 💯
return this.objectified; | ||
} | ||
|
||
feature(name: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit, but I'd find this method easier to understand if there was a verb in the name, e.g. getFeature
.
* @internal | ||
*/ | ||
constructor(rawConfig: LicensingConfigType, env: Env) { | ||
this.enabled = rawConfig.enabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see isEnabled
used in some places and enabled
in others. Should be standardize on one or the other? My preference would be isEnabled
, because I'm used to seeing words like is
used to identify booleans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this comes from configuration that we control, this is a good idea. Will revise.
💔 Build Failed |
Summary
Licensing service. This is currently a work in progress:
Fixes #18356.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers