Skip to content

Commit

Permalink
feat: introduce edgeMode in source-iotsitewise
Browse files Browse the repository at this point in the history
  • Loading branch information
chejimmy committed Feb 28, 2024
1 parent e270f30 commit 3106695
Show file tree
Hide file tree
Showing 13 changed files with 1,231 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type {
RequestInformationAndRange,
} from '@iot-app-kit/core';
import type { AggregatedPropertyParams } from './client';
import { flattenRequestInfoByFetch } from '../util/flattenRequestInfoByFetch';

export type BatchAggregatedEntry = {
requestInformation: RequestInformationAndRange;
Expand Down Expand Up @@ -195,39 +196,7 @@ export const batchGetAggregatedPropertyDataPoints = ({
// Aggregates for raw data only (denoted by '0')
.filter(({ resolution }) => resolution !== '0')
// fanout on fetchMostRecentBeforeStart, fetchMostRecentBeforeEnd, fetchFromStartToEnd into dedicated request info
.flatMap(
({
fetchMostRecentBeforeStart,
fetchMostRecentBeforeEnd,
fetchFromStartToEnd,
...rest
}) => {
const infos: RequestInformationAndRange[] = [];

if (fetchMostRecentBeforeStart) {
infos.push({
...rest,
fetchMostRecentBeforeStart,
});
}

if (fetchMostRecentBeforeEnd) {
infos.push({
...rest,
fetchMostRecentBeforeEnd,
});
}

if (fetchFromStartToEnd) {
infos.push({
...rest,
fetchFromStartToEnd,
});
}

return infos;
}
)
.flatMap(flattenRequestInfoByFetch)
.forEach((requestInformation) => {
// only 1 of the following options are enabled at this point:
// fetchMostRecentBeforeStart, fetchMostRecentBeforeEnd, fetchFromStartToEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@iot-app-kit/core';
import type { HistoricalPropertyParams } from './client';
import { withinLatestPropertyDataThreshold } from './withinLatestPropertyDataThreshold';
import { flattenRequestInfoByFetch } from '../util/flattenRequestInfoByFetch';

export type BatchHistoricalEntry = {
requestInformation: RequestInformationAndRange;
Expand Down Expand Up @@ -204,39 +205,7 @@ export const batchGetHistoricalPropertyDataPoints = ({
requestInformations
.filter(shouldAcceptRequest)
// fanout on fetchMostRecentBeforeStart, fetchMostRecentBeforeEnd, fetchFromStartToEnd into dedicated request info
.flatMap(
({
fetchMostRecentBeforeStart,
fetchMostRecentBeforeEnd,
fetchFromStartToEnd,
...rest
}) => {
const infos: RequestInformationAndRange[] = [];

if (fetchMostRecentBeforeStart) {
infos.push({
...rest,
fetchMostRecentBeforeStart,
});
}

if (fetchMostRecentBeforeEnd) {
infos.push({
...rest,
fetchMostRecentBeforeEnd,
});
}

if (fetchFromStartToEnd) {
infos.push({
...rest,
fetchFromStartToEnd,
});
}

return infos;
}
)
.flatMap(flattenRequestInfoByFetch)
.forEach((requestInformation) => {
// only 1 of the following options are enabled at this point:
// fetchMostRecentBeforeStart, fetchMostRecentBeforeEnd, fetchFromStartToEnd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export type AggregatedPropertyParams = {
onSuccess: OnSuccessCallback;
};

export type SiteWiseClientSettings = {
batchDuration?: SiteWiseDataSourceSettings['batchDuration'];
};

export class SiteWiseClient {
private siteWiseSdk: IoTSiteWiseClient;
private settings: SiteWiseDataSourceSettings;
Expand All @@ -46,7 +50,7 @@ export class SiteWiseClient {

constructor(
siteWiseSdk: IoTSiteWiseClient,
settings: SiteWiseDataSourceSettings = {}
settings: SiteWiseClientSettings = {}
) {
this.siteWiseSdk = siteWiseSdk;
this.settings = settings;
Expand Down

0 comments on commit 3106695

Please sign in to comment.