-
Notifications
You must be signed in to change notification settings - Fork 74
Replace Session.LastBookmark() with Session.LastBookmarks()
#302
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
328e533
Replace `Session.LastBookmark()` with `Session.LastBookmarks()`
robsdedude cd1e946
Rename `ConcatenateStringSlices` to `CombineBookmarks`
robsdedude 8aec7f7
Improve test context name
robsdedude 5a37e12
Clean up names
robsdedude f7468a1
Deprecate `Session.LastBookmark` instead of removing it
robsdedude 716b67e
Merge branch '5.0' into session-last-bookmarks
robsdedude 8b29027
Merge branch '5.0' into session-last-bookmarks
fbiville File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package neo4j | ||
|
|
||
| /* | ||
| Bookmarks is a holder for server-side bookmarks which are used for causally chaining sessions. | ||
| See also CombineBookmarks. | ||
| Note: | ||
| Will be changed from being a type alias to being a struct in 6.0. Please use BookmarksFromRawValues for construction | ||
| from raw values and BookmarksToRawValues for accessing the raw values. | ||
| */ | ||
| type Bookmarks = []string | ||
|
|
||
| /* | ||
| CombineBookmarks is a helper method to combine []Bookmarks into a single Bookmarks instance. | ||
| Let s1, s2, s3 be Session interfaces. You can easily causally chain the sessions like so: | ||
| s4 := driver.NewSession(neo4j.SessionConfig{ | ||
| Bookmarks: neo4j.CombineBookmarks(s1.LastBookmarks(), s2.LastBookmarks(), s3.LastBookmarks()), | ||
| }) | ||
| The server will then make sure to execute all transactions in s4 after any that were already executed in s1, s2, or s3 | ||
| at the time of calling LastBookmarks. | ||
| */ | ||
| func CombineBookmarks(bookmarks... Bookmarks) Bookmarks { | ||
| var lenSum int | ||
| for _, b := range bookmarks { | ||
| lenSum += len(b) | ||
| } | ||
| res := make([]string, lenSum) | ||
| var i int | ||
| for _, b := range bookmarks { | ||
| i += copy(res[i:], b) | ||
| } | ||
| return res | ||
| } | ||
|
|
||
| /* | ||
| BookmarksToRawValues exposes the raw server-side bookmarks. | ||
| You should not need to use this method unless you want to serialize bookmarks. | ||
| See Session.LastBookmarks and CombineBookmarks for alternatives. | ||
| */ | ||
| func BookmarksToRawValues(bookmarks Bookmarks) []string { | ||
| return bookmarks | ||
| } | ||
|
|
||
| /* | ||
| BookmarksFromRawValues creates Bookmarks from raw server-side bookmarks. | ||
| You should not need to use this method unless you want to de-serialize bookmarks. | ||
| See Session.LastBookmarks and CombineBookmarks for alternatives. | ||
| */ | ||
| func BookmarksFromRawValues(values... string) Bookmarks { | ||
fbiville marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return values | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package neo4j | ||
|
|
||
| import ( | ||
| "testing" | ||
| "testing/quick" | ||
| ) | ||
|
|
||
| func TestCombineBookmarks(t *testing.T) { | ||
| f := func(slices []Bookmarks) bool { | ||
| concatenation := CombineBookmarks(slices...) | ||
| totalLen := 0 | ||
| for _, s := range slices { | ||
| totalLen += len(s) | ||
| } | ||
| if totalLen != len(concatenation) { | ||
| return false | ||
| } | ||
| i := 0 | ||
| for _, slice := range slices { | ||
| for _, str := range slice { | ||
| if str != concatenation[i] { | ||
| return false | ||
| } | ||
| i += 1 | ||
| } | ||
| } | ||
| return true | ||
| } | ||
| if err := quick.Check(f, nil); err != nil { | ||
| t.Error(err) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.