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

consume readBlob in dds #4856

Merged
merged 16 commits into from
Jan 29, 2021
Merged

consume readBlob in dds #4856

merged 16 commits into from
Jan 29, 2021

Conversation

chensixx
Copy link
Contributor

@chensixx chensixx commented Jan 20, 2021

Step 4 of #4464

@@ -242,10 +242,11 @@ export class SharedCell<T extends Serializable = any> extends SharedObject<IShar
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
*/
protected async loadCore(storage: IChannelStorageService): Promise<void> {
const rawContent = await storage.read(snapshotFileName);
const blob = await storage.readBlob(snapshotFileName);
Copy link
Contributor

Choose a reason for hiding this comment

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

I really dislike existing duplication of code.
In my view, readBlob, bufferToString & JSON.parse should be refactored to be replaced by calling readAndParse().
If it was done in the first place (before you :)), it would make your work trivial - just change 2 lines of code and all of repo is using different flow.
Same arguments works for future - maybe we will decide that for all or some scenarios we want to encode/decode everything in utf-16 - it would be so much simpler if such logic exists in a single place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so I should change readAndParse to consume readBlob and then replace code like above with it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that would be preference. It can go in either order - you could first change all this code to use readAndParse, and then change it in later PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

You may get this PR in as is (given it's ready), and following up here with separate PR.

@github-actions github-actions bot requested a review from vladsud January 21, 2021 00:39
@github-actions github-actions bot requested review from arinwt and curtisman January 22, 2021 00:29
@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Jan 22, 2021

@fluidframework/base-host: No change
Metric NameBaseline SizeCompare SizeSize Diff
main.js 168.99 KB 168.99 KB No change
Total Size 168.99 KB 168.99 KB No change
@fluid-example/bundle-size-tests: +481 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
container.js 193.84 KB 193.97 KB +131 Bytes
map.js 45.83 KB 45.92 KB +86 Bytes
matrix.js 144.34 KB 144.44 KB +104 Bytes
odspDriver.js 195.02 KB 195.08 KB +65 Bytes
sharedString.js 158.39 KB 158.48 KB +95 Bytes
Total Size 737.42 KB 737.89 KB +481 Bytes

Baseline commit: 7b3b6c1

Generated by 🚫 dangerJS against e1807f4

@github-actions github-actions bot requested a review from tanviraumi January 22, 2021 03:12

// for back compat. will be replaced with readBlob after version 0.35
const res = await this.storage.read(id);
return stringToBuffer(res, "base64");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we use this.storage.readBlob here now, the back compat tests will fail, because it will call the old readBlob which does not read from cache like read. So I'm only keeping this as read here. If I can debug and find the solution before version 0.35 is ready, I will change it back. Otherwise I will wait for 0.35.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good - please open an issue not to forget

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chensixx chensixx marked this pull request as ready for review January 22, 2021 22:06
@github-actions github-actions bot requested a review from vladsud January 29, 2021 19:09
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.

3 participants