-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 (Web) for logger #12791
Conversation
10f7253
to
912924f
Compare
packages/core/src/utils/queuedStorage/createQueuedStorage.native.ts
Outdated
Show resolved
Hide resolved
packages/core/__tests__/utils/queuedStorage/queuedStorage.test.ts
Outdated
Show resolved
Hide resolved
packages/core/__tests__/utils/queuedStorage/queuedStorage.test.ts
Outdated
Show resolved
Hide resolved
mockGetAll.mockClear(); | ||
}); | ||
|
||
test('peek() returns specified number of queued items', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Looks like you're intentionally mixing it
and test
, would it be better to add describe instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it
and test
are identical functionally as it
is an alias of test
, I think they fit in in this context to save two describe()
wrappers... wdyt?
912924f
to
38e0351
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
e89ef1f
to
f359840
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me!
|
||
const openDBPromise = new Promise<IDBDatabase>((resolve, reject) => { | ||
const { indexedDB } = window; | ||
const openRequest = indexedDB.open(DATABASE_NAME, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: is 1
required?
const { indexedDB } = window; | ||
const openRequest = indexedDB.open(DATABASE_NAME, 1); | ||
|
||
openRequest.onupgradeneeded = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: some doc string around when onupgradeneeded
is triggered. From untrained eye, I'd expect upgrade is not needed when indexedDB version is 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me!
|
||
await promisifyIDBRequest(request); | ||
|
||
for (const item of request.result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, QQ
Are we fetching only the items recently changed and append the size or are we fetching all items in db and then re-assign the size
I'm guessing it's the former. so ideally would request.result just have a single item when we're adding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's all items, on app reload.
await promisifyIDBRequest(request); | ||
|
||
for (const item of request.result) { | ||
currentBytesSize += (item as QueuedItem).bytesSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit QQ
Would openRequest.onsuccess get called when items are deleted as well. In which case this would append that size as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openRequest.onsuccess
is being called once when opening the db.
@@ -0,0 +1,380 @@ | |||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |||
// SPDX-License-Identifier: Apache-2.0 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit QQ
when adding or deleting items are we also testing if the total currentBytesSize
is getting updated as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will add a new test for this separately.
f359840
to
5596896
Compare
Description of changes
Add implementation of a queued storage for the upcoming logger. Backed by the IndexedDB on Web.
Issue #, if available
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.