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

[Config] Expose TTLDurationMapping as data module configuration #20

Merged
merged 1 commit into from
Dec 16, 2021

Conversation

boweihan
Copy link
Contributor

@boweihan boweihan commented Dec 14, 2021

Overview

The IoT App Kit takes a granular approach to time-series caching rules. The idea is to allow data points to be re-requested at different frequencies depending on how close those data points are to chart boundaries - e.g. more "recent" data can be refreshed with higher frequency.

This change allows IoT App Kit consumers to customize cache invalidation rules by overriding the default ttlDurationMapping.

Tests

https://github.com/boweihan/iot-app-kit/runs/4523021422?check_suite_focus=true

Legal

This project is available under the Apache 2.0 License.

import DataSourceStore from './data-source-store/dataSourceStore';
import { SubscriptionResponse } from '../data-sources/site-wise/types.d';
import { DataCache } from './data-cache/dataCacheWrapped';
import { Request } from './data-cache/requestTypes';
import { requestRange } from './data-cache/requestRange';
import { getDateRangesToRequest } from './data-cache/caching/caching';
import { viewportEndDate, viewportStartDate } from '../common/viewport';
import { MINUTE_IN_MS, SECOND_IN_MS } from '../common/time';

// given duration specified as a key, it may only be re-requested after the provided TTL value
Copy link
Contributor Author

@boweihan boweihan Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move this (and more) into doc-site documentation once we align on an approach.

/**
* Create a new data module, optionally with a pre-hydrated data cache.
*
*/
constructor(initialDataCache?: DataStreamsStore) {
constructor(configuration: IotAppKitDataModuleConfiguration = {}) {
const { initialDataCache, ttlDurationMapping = DEFAULT_TTL_DURATION_MAPPING } = configuration;
Copy link
Contributor Author

@boweihan boweihan Dec 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about having ttlDurationMapping be even more granular and attached to a DataStreamStore but I think that's overkill for now. Especially because other time-series offerings like Grafana don't even offer this type of granular customization.

If we want to add granularity per stream in the future it should be fairly straightforward - more specific configuration will simply override this data module scoped configuration.

@boweihan boweihan changed the title [Seeking Feedback] Expose TTLDurationMapping as data module configuration [Config] Expose TTLDurationMapping as data module configuration Dec 14, 2021
@boweihan boweihan force-pushed the ttl-rules branch 3 times, most recently from 24681ab to 19a7dd5 Compare December 14, 2021 20:16
@@ -506,6 +508,87 @@ describe('caching', () => {
});
});

describe('cache settings', () => {
let getDateRangesToRequestSpy = jest.spyOn(caching, 'getDateRangesToRequest');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be const?

@boweihan boweihan merged commit 88c0fcb into awslabs:main Dec 16, 2021
sheilaXu pushed a commit that referenced this pull request Sep 23, 2022
Allow entering entity id with autosuggest 


Co-authored-by: Zuraiz Zafar 🙃 <zuraiz@amazon.com>
This was referenced Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants