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

Batch events for writing to the database. #21

Merged

Conversation

navilperez
Copy link
Contributor

Currently, each event is written to the database as an individual entry.
With this change, the client batches any available events and writes
them to the database as a single entry. By writing all events to the
database in a single entry this removes the need to use a transaction.

Other:
WorkspaceClient.js: this.inProgress was an array of events, now
this.inProgress is an array of LocalEntry objects. Tracking a LocalEntry
object facilitates merging client and server events. Currently, only one
LocalEntry event will exist at a time, however, once websockets are
implemented, inProgress will hold multiple LocalEntry objects.

Currently, each event is written to the database as an individual entry.
With this change, the client batches any available events and writes
them to the database as a single entry. By writing all events to the
database in a single entry this removes the need to use a transaction.

Other:
WorkspaceClient.js: this.inProgress was an array of events, now
this.inProgress is an array of LocalEntry objects. Tracking a LocalEntry
object facilitates merging client and server events. Currently, only one
LocalEntry event will exist at a time, however, once websockets are
implemented, inProgress will hold multiple LocalEntry objects.
Copy link

@RoboErikG RoboErikG left a comment

Choose a reason for hiding this comment

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

Didn't take a close look at all the code, but noted an edge case to watch out for.

blockly-rtc/src/WorkspaceClient.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

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

A few questions but looks good overall.

this.endWrite_(false);
throw Error('Failed to write to database.');
};
this.beginWrite_();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: get rid of the extra indentation here.

Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

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

One nit, then lgtm.

@navilperez navilperez merged commit 7cb94cf into google:realtime_collab Nov 25, 2019
@navilperez navilperez deleted the navilperez-schema-refactor branch November 25, 2019 22:33
@navilperez navilperez moved this from In progress to Done in Realtime Collaboration Demo Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants