Skip to content

Commit 3d74514

Browse files
authored
[Streams] Merge AssetClient into QueryClient (elastic#242998)
It closes elastic#243479 ## Summary This PR merges `AssetClient` into `QueryClient`, simplifying the codebase by removing an unnecessary abstraction layer. ### Background The `AssetClient` was originally designed as a generic data access layer for managing different asset types linked to streams. However, with the introduction of `AttachmentClient` to handle dashboards, rules, and SLOs, the only remaining asset type managed by `AssetClient` is `query` (significant events). Since `AssetClient` and `QueryClient` were always used together and `query` is now the only asset type, maintaining two separate clients added unnecessary complexity.
1 parent 432dfd0 commit 3d74514

17 files changed

Lines changed: 418 additions & 525 deletions

File tree

x-pack/platform/plugins/shared/streams/server/lib/significant_events/read_significant_events_from_alerts_indices.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ import type { IScopedClusterClient } from '@kbn/core/server';
1414
import type { ChangePointType } from '@kbn/es-types/src';
1515
import type { SignificantEventsGetResponse, StreamQueryKql } from '@kbn/streams-schema';
1616
import { get, isArray, isEmpty, keyBy } from 'lodash';
17-
import type { AssetClient } from '../streams/assets/asset_client';
17+
import type { QueryClient } from '../streams/assets/query/query_client';
1818
import { getRuleIdFromQueryLink } from '../streams/assets/query/helpers/query';
1919
import { SecurityError } from '../streams/errors/security_error';
2020
import type { QueryLink } from '../../../common/assets';
2121

2222
export async function readSignificantEventsFromAlertsIndices(
2323
params: { name: string; from: Date; to: Date; bucketSize: string; query?: string },
2424
dependencies: {
25-
assetClient: AssetClient;
25+
queryClient: QueryClient;
2626
scopedClusterClient: IScopedClusterClient;
2727
}
2828
): Promise<SignificantEventsGetResponse> {
29-
const { assetClient, scopedClusterClient } = dependencies;
29+
const { queryClient, scopedClusterClient } = dependencies;
3030
const { name, from, to, bucketSize, query } = params;
3131

3232
const queryLinks = await (query
33-
? assetClient.findQueries(name, query)
34-
: assetClient.getAssetLinks([name], ['query']).then(({ [name]: links }) => links));
33+
? queryClient.findQueries(name, query)
34+
: queryClient.getQueryLinks([name]).then(({ [name]: links }) => links));
3535
if (isEmpty(queryLinks)) {
3636
return { significant_events: [], aggregated_occurrences: [] };
3737
}

x-pack/platform/plugins/shared/streams/server/lib/streams/assets/asset_client.ts

Lines changed: 0 additions & 359 deletions
This file was deleted.

0 commit comments

Comments
 (0)