-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Maps] Always initialize routes on server-startup #84806
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,25 +52,31 @@ const EMPTY_EMS_CLIENT = { | |
addQueryParams() {}, | ||
}; | ||
|
||
export function initRoutes(router, licenseUid, emsSettings, kbnVersion, logger) { | ||
export function initRoutes(router, getLicenseId, emsSettings, kbnVersion, logger) { | ||
let emsClient; | ||
|
||
if (emsSettings.isIncludeElasticMapsService()) { | ||
emsClient = new EMSClient({ | ||
language: i18n.getLocale(), | ||
appVersion: kbnVersion, | ||
appName: EMS_APP_NAME, | ||
fileApiUrl: emsSettings.getEMSFileApiUrl(), | ||
tileApiUrl: emsSettings.getEMSTileApiUrl(), | ||
landingPageUrl: emsSettings.getEMSLandingPageUrl(), | ||
fetchFunction: fetch, | ||
}); | ||
emsClient.addQueryParams({ license: licenseUid }); | ||
} else { | ||
emsClient = EMPTY_EMS_CLIENT; | ||
} | ||
let lastLicenseId; | ||
|
||
function getEMSClient() { | ||
const currentLicenseId = getLicenseId(); | ||
if (emsClient && lastLicenseId === currentLicenseId) { | ||
return emsClient; | ||
} | ||
|
||
lastLicenseId = currentLicenseId; | ||
if (emsSettings.isIncludeElasticMapsService()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this include a check for lastLicenseId being undefined? What happens if getLicenseId returns undefined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EMS has a license validation on the backend as well. This will fallback to as-if OSS EMS would be used. |
||
emsClient = new EMSClient({ | ||
language: i18n.getLocale(), | ||
appVersion: kbnVersion, | ||
appName: EMS_APP_NAME, | ||
fileApiUrl: emsSettings.getEMSFileApiUrl(), | ||
tileApiUrl: emsSettings.getEMSTileApiUrl(), | ||
landingPageUrl: emsSettings.getEMSLandingPageUrl(), | ||
fetchFunction: fetch, | ||
}); | ||
emsClient.addQueryParams({ license: currentLicenseId }); | ||
} else { | ||
emsClient = EMPTY_EMS_CLIENT; | ||
} | ||
return emsSettings.isEMSEnabled() ? emsClient : EMPTY_EMS_CLIENT; | ||
thomasneirynck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
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.
checking for validity is not necessary. Other plugins do not check license-validity before registering the routes.
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.
Might be carryover from legacy patterns? Thanks for the clean up