mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
[ML] Fixing capabilites polling in manage page (#163399)
On ML's management page a new capabilities poll is created every time the user changes tabs. `getMlGlobalServices` gets called every time the jobs list renders, which creates a new `MlCapabilitiesService` which creates a new timer to poll for ml's capabilities. This change moves the `mlServices` so it isn't called on each render. It also bumps up the interval from 1 min to 5 mins as think 1 min is a bit too frequent.
This commit is contained in:
parent
9fb83fed86
commit
6673e9dc59
2 changed files with 7 additions and 2 deletions
|
@ -24,7 +24,7 @@ import { type MlApiServices } from '../services/ml_api_service';
|
||||||
|
|
||||||
let _capabilities: MlCapabilities = getDefaultCapabilities();
|
let _capabilities: MlCapabilities = getDefaultCapabilities();
|
||||||
|
|
||||||
const CAPABILITIES_REFRESH_INTERVAL = 60000;
|
const CAPABILITIES_REFRESH_INTERVAL = 5 * 60 * 1000; // 5min;
|
||||||
|
|
||||||
export class MlCapabilitiesService {
|
export class MlCapabilitiesService {
|
||||||
private _isLoading$ = new BehaviorSubject<boolean>(true);
|
private _isLoading$ = new BehaviorSubject<boolean>(true);
|
||||||
|
|
|
@ -70,6 +70,11 @@ export const JobsListPage: FC<{
|
||||||
const I18nContext = coreStart.i18n.Context;
|
const I18nContext = coreStart.i18n.Context;
|
||||||
const theme$ = coreStart.theme.theme$;
|
const theme$ = coreStart.theme.theme$;
|
||||||
|
|
||||||
|
const mlServices = useMemo(
|
||||||
|
() => getMlGlobalServices(coreStart.http, usageCollection),
|
||||||
|
[coreStart.http, usageCollection]
|
||||||
|
);
|
||||||
|
|
||||||
const check = async () => {
|
const check = async () => {
|
||||||
try {
|
try {
|
||||||
await checkGetManagementMlJobsResolver(mlApiServices);
|
await checkGetManagementMlJobsResolver(mlApiServices);
|
||||||
|
@ -122,7 +127,7 @@ export const JobsListPage: FC<{
|
||||||
usageCollection,
|
usageCollection,
|
||||||
fieldFormats,
|
fieldFormats,
|
||||||
spacesApi,
|
spacesApi,
|
||||||
mlServices: getMlGlobalServices(coreStart.http, usageCollection),
|
mlServices,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ContextWrapper feature={PLUGIN_ID}>
|
<ContextWrapper feature={PLUGIN_ID}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue