Skip to content

Make newly created session return no bookmarks #844

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

Closed

Conversation

robsdedude
Copy link
Member

@robsdedude robsdedude force-pushed the no-bookmarks-from-new-session branch from 8407b47 to 97f3840 Compare January 18, 2022 12:54
@robsdedude robsdedude force-pushed the no-bookmarks-from-new-session branch from 97f3840 to c93a64d Compare January 18, 2022 13:55
@robsdedude robsdedude requested a review from bigmontz January 18, 2022 14:02
Copy link
Contributor

@bigmontz bigmontz left a comment

Choose a reason for hiding this comment

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

I've made some comments for understand some changes in the code and specially in the interface.

Apart of the other question, why does the received bookmark could not be considered last seem until we receive a new one?

Comment on lines -229 to +230
_onCompleteCallback(meta: { bookmark?: string | string[] }): void {
this._onBookmark(new Bookmark(meta.bookmark))
_onCompleteCallback(meta: { bookmark?: string }): void {
this._onBookmark(meta.bookmark)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change onBookmark signature?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because I want to fail fast should the server send multiple bookmarks. According to the protocol spec, there should only ever be 0 or 1 bookmark in a SUCCESS message.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, thinking further down the call stack, I want _bookmarkOut to be a string. How do you turn a Bookmark (which can contain a string array) into a single string in a type safe way?

Comment on lines -382 to +386
_updateBookmark(newBookmark?: Bookmark): void {
if (newBookmark && !newBookmark.isEmpty()) {
this._lastBookmark = newBookmark
_updateBookmark(newBookmark?: string): void {
if (newBookmark !== undefined) {
this._bookmarkIn = new Bookmark(newBookmark)
this._bookmarkOut = newBookmark
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the previous newBookmark will be always defined. So, it could be changed for if(!newBookmark.isEmpty())

Copy link
Member Author

Choose a reason for hiding this comment

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

But what was the !newBookmark.isEmpty() there fore before if not to check if the SUCCESS message that triggered this update actually contains a bookmark?

Comment on lines +58 to +59
private _bookmarkIn: Bookmark
private _bookmarkOut?: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it could be called currentBookmark and lastReceivedBookmark, or something like this. Because the _bookmarkIn is being changed when a new bookmark arrives.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine with that 👌 Will do.

Comment on lines 297 to 304
/**
* Return the bookmark received following the last completed {@link Transaction}.
*
* @return {string[]} A reference to a previous transaction.
* @return {string | undefined} A reference to a previous transaction if present.
*/
lastBookmark(): string[] {
return this._lastBookmark.values()
lastBookmark(): string | undefined {
return this._bookmarkOut
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did the interface changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw a recent question from support regarding the Java driver: they wanted to know if they can safely assume that .lastBookmark would only ever return one bookmark. With this signature, there is no doubt about it.

@robsdedude robsdedude marked this pull request as draft January 19, 2022 11:13
@robsdedude
Copy link
Member Author

Superseded by #848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants