Skip to content

Commit

Permalink
[ResponseOps]: Refactor alerting task runner - combine loadRuleAttrib…
Browse files Browse the repository at this point in the history
…utesAndRun() and validateAndExecuteRule() (#132079)

resolves #131544

Extract the `loadRuleAttributesAndRun()` and `validateAndExecuteRule()`
methods from the alerting task runner, into a separate module.

meta issue: #124206
  • Loading branch information
pmuellr authored Jun 14, 2022
1 parent 343ae0e commit 04e259a
Show file tree
Hide file tree
Showing 11 changed files with 567 additions and 159 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/common/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export enum RuleExecutionStatusErrorReasons {
License = 'license',
Timeout = 'timeout',
Disabled = 'disabled',
Validate = 'validate',
}

export enum RuleExecutionStatusWarningReasons {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
import { PluginStartContract as FeaturesPluginStart } from '@kbn/features-plugin/server';
import { PluginStart as DataPluginStart } from '@kbn/data-plugin/server';
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
import { RulesClient } from './rules_client';
import { RuleTypeRegistry } from './rule_type_registry';
import { TaskRunnerFactory } from './task_runner';
import { RulesClientFactory } from './rules_client_factory';
Expand All @@ -63,6 +62,7 @@ import {
RuleType,
RuleTypeParams,
RuleTypeState,
RulesClientApi,
} from './types';
import { registerAlertingUsageCollector } from './usage';
import { initializeAlertingTelemetry, scheduleAlertingTelemetry } from './usage/task';
Expand Down Expand Up @@ -122,7 +122,7 @@ export interface PluginSetupContract {
export interface PluginStartContract {
listTypes: RuleTypeRegistry['list'];

getRulesClientWithRequest(request: KibanaRequest): PublicMethodsOf<RulesClient>;
getRulesClientWithRequest(request: KibanaRequest): RulesClientApi;

getAlertingAuthorizationWithRequest(
request: KibanaRequest
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/alerting/server/rules_client.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
* 2.0.
*/

import type { PublicMethodsOf } from '@kbn/utility-types';
import { RulesClient } from './rules_client';
import { RulesClientApi } from './types';

type Schema = PublicMethodsOf<RulesClient>;
type Schema = RulesClientApi;
export type RulesClientMock = jest.Mocked<Schema>;

const createRulesClientMock = () => {
Expand Down
Loading

0 comments on commit 04e259a

Please sign in to comment.