Skip to content
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

remove polling code from frontend plugin #235

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dashboards-reports/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ export const OPENSEARCH_REPORTS_API = {
LIST_REPORT_INSTANCES: `${BASE_REPORTS_URI}/instances`,
REPORT_DEFINITION: `${BASE_REPORTS_URI}/definition`,
LIST_REPORT_DEFINITIONS: `${BASE_REPORTS_URI}/definitions`,
POLL_REPORT_INSTANCE: `${BASE_REPORTS_URI}/poll_instance`,
};

const REPORTING_NOTIFICATIONS_API_PREFIX = '/api/reporting_notifications';
export const REPORTING_NOTIFICATIONS_DASHBOARDS_API = Object.freeze({
GET_CONFIGS: `${REPORTING_NOTIFICATIONS_API_PREFIX}/get_configs`,
GET_EVENT: `${REPORTING_NOTIFICATIONS_API_PREFIX}/get_event`,
SEND_TEST_MESSAGE: `${REPORTING_NOTIFICATIONS_API_PREFIX}/test_message`
SEND_TEST_MESSAGE: `${REPORTING_NOTIFICATIONS_API_PREFIX}/test_message`,
});

const NOTIFICATIONS_API_BASE_PATH = '/_plugins/_notifications';
export const NOTIFICATIONS_API = Object.freeze({
CONFIGS: `${NOTIFICATIONS_API_BASE_PATH}/configs`,
EVENTS: `${NOTIFICATIONS_API_BASE_PATH}/events`,
TEST_MESSAGE: `${NOTIFICATIONS_API_BASE_PATH}/feature/test`
});
TEST_MESSAGE: `${NOTIFICATIONS_API_BASE_PATH}/feature/test`,
});
10 changes: 0 additions & 10 deletions dashboards-reports/server/backend/opensearch-reports-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,4 @@ export default function (Client: any, config: any, components: any) {
},
method: 'DELETE',
});

/**
* Poller API
*/
opensearchReports.pollReportInstance = clientAction({
url: {
fmt: `${OPENSEARCH_REPORTS_API.POLL_REPORT_INSTANCE}`,
},
method: 'GET',
});
}
4 changes: 2 additions & 2 deletions dashboards-reports/server/clusters/notificationsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function NotificationsPlugin(Client: any, config: any, components: any) {
},
},
method: 'GET',
})
});

notifications.sendTestMessage = clientAction({
url: {
Expand All @@ -43,4 +43,4 @@ export function NotificationsPlugin(Client: any, config: any, components: any) {
},
method: 'GET',
});
}
}
62 changes: 0 additions & 62 deletions dashboards-reports/server/executor/createScheduledReport.ts

This file was deleted.

54 changes: 0 additions & 54 deletions dashboards-reports/server/executor/executor.ts

This file was deleted.

28 changes: 0 additions & 28 deletions dashboards-reports/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import {
Logger,
ILegacyClusterClient,
} from '../../../src/core/server';
import { setIntervalAsync } from 'set-interval-async/dynamic';
import { Semaphore, SemaphoreInterface, withTimeout } from 'async-mutex';
import opensearchReportsPlugin from './backend/opensearch-reports-plugin';
import {
ReportsDashboardsPluginSetup,
ReportsDashboardsPluginStart,
} from './types';
import registerRoutes from './routes';
import { pollAndExecuteJob } from './executor/executor';
import { POLL_INTERVAL } from './utils/constants';
import { NotificationsPlugin } from './clusters/notificationsPlugin';
import { buildConfig, ReportingConfigType } from './config';
import { ReportingConfig } from './config/config';
Expand Down Expand Up @@ -114,31 +111,6 @@ export class ReportsDashboardsPlugin

public start(core: CoreStart) {
this.logger.debug('reports-dashboards: Started');
const opensearchReportsClient: ILegacyClusterClient = core.opensearch.legacy.createClient(
'opensearch_reports',
{
plugins: [opensearchReportsPlugin],
}
);

const opensearchClient: ILegacyClusterClient =
core.opensearch.legacy.client;
/*
setIntervalAsync provides the same familiar interface as built-in setInterval for asynchronous functions,
while preventing multiple executions from overlapping in time.
Polling at at a 5 min fixed interval

TODO: need further optimization polling with a mix approach of
random delay and dynamic delay based on the amount of jobs.
*/
// setIntervalAsync(
// pollAndExecuteJob,
// POLL_INTERVAL,
// opensearchReportsClient,
// notificationClient,
// opensearchClient,
// this.logger
// );
return {};
}

Expand Down
4 changes: 0 additions & 4 deletions dashboards-reports/server/routes/lib/createReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import {
REPORT_TYPE,
REPORT_STATE,
DELIVERY_TYPE,
DATA_REPORT_CONFIG,
EXTRA_HEADERS,
} from '../utils/constants';
Expand All @@ -21,8 +19,6 @@ import { createSavedSearchReport } from '../utils/savedSearchReportHelper';
import { ReportSchemaType } from '../../model';
import { CreateReportResultType } from '../utils/types';
import { createVisualReport } from '../utils/visual_report/visualReportHelper';
import { SetCookie, Headers } from 'puppeteer-core';
import { updateReportState } from './updateReportState';
import { saveReport } from './saveReport';
import { SemaphoreInterface } from 'async-mutex';
import { ReportingConfig } from 'server';
Expand Down
6 changes: 0 additions & 6 deletions dashboards-reports/server/utils/constants.ts

This file was deleted.