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
Batch events for writing to the database. #21
Conversation
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.
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.
Didn't take a close look at all the code, but noted an edge case to watch out for.
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.
A few questions but looks good overall.
blockly-rtc/src/WorkspaceClient.js
Outdated
this.endWrite_(false); | ||
throw Error('Failed to write to database.'); | ||
}; | ||
this.beginWrite_(); |
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: get rid of the extra indentation here.
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.
One nit, then lgtm.
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.