Skip to content

Commit

Permalink
Removing observable
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 15, 2021
1 parent 6851db2 commit d769723
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions x-pack/plugins/alerting/server/task_runner/task_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import type { PublicMethodsOf } from '@kbn/utility-types';
import { Dictionary, pickBy, mapValues, without, cloneDeep } from 'lodash';
import type { Request } from '@hapi/hapi';
import { BehaviorSubject } from 'rxjs';
import { addSpaceIdToPath } from '../../../spaces/server';
import { Logger, KibanaRequest } from '../../../../../src/core/server';
import { TaskRunnerContext } from './task_runner_factory';
Expand Down Expand Up @@ -94,7 +93,7 @@ export class TaskRunner<
RecoveryActionGroupId
>;
private readonly ruleTypeRegistry: RuleTypeRegistry;
private cancelled$: BehaviorSubject<boolean>;
private cancelled: boolean;

constructor(
alertType: NormalizedAlertType<
Expand All @@ -115,7 +114,7 @@ export class TaskRunner<
this.ruleName = null;
this.taskInstance = taskInstanceToAlertTaskInstance(taskInstance);
this.ruleTypeRegistry = context.ruleTypeRegistry;
this.cancelled$ = new BehaviorSubject<boolean>(false);
this.cancelled = false;
}

async getApiKeyForAlertPermissions(alertId: string, spaceId: string) {
Expand Down Expand Up @@ -231,7 +230,7 @@ export class TaskRunner<

private shouldLogAndScheduleActionsForAlerts() {
// if execution hasn't been cancelled, return true
if (!this.cancelled$.getValue()) {
if (!this.cancelled) {
return true;
}

Expand Down Expand Up @@ -645,7 +644,7 @@ export class TaskRunner<

eventLogger.logEvent(event);

if (!this.cancelled$.getValue()) {
if (!this.cancelled) {
this.logger.debug(
`Updating rule task for ${this.alertType.id} rule with id ${alertId} - ${JSON.stringify(
executionStatus
Expand Down Expand Up @@ -689,11 +688,11 @@ export class TaskRunner<
}

async cancel(): Promise<void> {
if (this.cancelled$.getValue()) {
if (this.cancelled) {
return;
}

this.cancelled$.next(true);
this.cancelled = true;

// Write event log entry
const {
Expand Down

0 comments on commit d769723

Please sign in to comment.