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

feat(core): queued storage (react-native) for logger #12798

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

HuiSF
Copy link
Contributor

@HuiSF HuiSF commented Jan 4, 2024

Description of changes

Implementation of the queued storage for react-native.

Depends on #12791

NOTE: Please do NOT click the update branch button.

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@HuiSF HuiSF requested review from a team as code owners January 4, 2024 20:50
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage-rn branch from 8677a78 to 61cd97f Compare January 4, 2024 20:54
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage branch from 912924f to 38e0351 Compare January 5, 2024 18:21
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage-rn branch from 61cd97f to 74d99c3 Compare January 5, 2024 18:21
jimblanc
jimblanc previously approved these changes Jan 8, 2024
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage branch from 38e0351 to e89ef1f Compare January 8, 2024 19:00
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage-rn branch from 74d99c3 to e77ccab Compare January 8, 2024 19:00
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage branch from e89ef1f to f359840 Compare January 9, 2024 00:58
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage-rn branch from e77ccab to d0b5c9a Compare January 9, 2024 00:58
AllanZhengYP
AllanZhengYP previously approved these changes Jan 9, 2024
ashwinkumar6
ashwinkumar6 previously approved these changes Jan 10, 2024

const getQueuedItemKeys = async (
as: ReturnType<typeof loadAsyncStorage>,
sortKeys: boolean = false
Copy link
Contributor

Choose a reason for hiding this comment

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

nit QQ
I think performance wise it's faster if we aren't manually sorting hence we default to false.
But I'm wondering if when this is used by CW, we'd always set this to true to make sure the older logs get a chance first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enable sortKeys is less performant actually, it should only be used when there is a need, for example, get first N items from the queue. So made it an opt-in option here. Feel free to change though as this is an internal util.

const testBytesSize = 1;
const mockKeys = [`${keyPrefix}_key1`, `${keyPrefix}_key2`];
const mockQueuedItems = [
{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit QQ
Is it possible the store might have other keys as well (without db prefix)

should we add a test wit those keys as well and check if

  • those keys aren't getting updated/deleted.
  • those keys getting changed don't have an impact on total currentBytesSize

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These items should've been covered with the test suites in this PR.

} from '../../../src/utils/queuedStorage/createQueuedStorage.native';
import { ItemToAdd, QueuedItem } from '../../../src/utils/queuedStorage/types';
import { getAddItemBytesSize } from '../../../src/utils/queuedStorage/getAddItemBytesSize';

Copy link
Contributor

Choose a reason for hiding this comment

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

nit QQ
same comment

@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage branch from f359840 to 5596896 Compare January 10, 2024 19:07
@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage-rn branch from d0b5c9a to a160870 Compare January 10, 2024 19:07
Base automatically changed from hui/feat/core/queued-storage to main January 10, 2024 19:22
@HuiSF HuiSF dismissed stale reviews from ashwinkumar6, AllanZhengYP, and jimblanc January 10, 2024 19:22

The base branch was changed.

@HuiSF HuiSF force-pushed the hui/feat/core/queued-storage-rn branch from a160870 to e8d6212 Compare January 10, 2024 19:23
@HuiSF HuiSF merged commit 14d5e13 into main Jan 10, 2024
30 checks passed
@HuiSF HuiSF deleted the hui/feat/core/queued-storage-rn branch January 10, 2024 20:44
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

4 participants