Skip to content

Commit bd088fc

Browse files
authored
Rename Session.lastBookmark to Session.lastBookmarks (#848)
Made a clear internal distinction between what single bookmark is (a string that is exchanged with the server) and what Bookmarks are (an array of such strings).
1 parent 35c82b3 commit bd088fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+505
-489
lines changed

packages/bolt-connection/src/bolt/bolt-protocol-v1.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
import { internal } from 'neo4j-driver-core'
3434

3535
const {
36-
bookmark: { Bookmark },
36+
bookmarks: { Bookmarks },
3737
constants: { ACCESS_MODE_WRITE, BOLT_PROTOCOL_V1 },
3838
logger: { Logger },
3939
txConfig: { TxConfig }
@@ -140,7 +140,7 @@ export default class BoltProtocol {
140140
/**
141141
* Begin an explicit transaction.
142142
* @param {Object} param
143-
* @param {Bookmark} param.bookmark the bookmark.
143+
* @param {Bookmarks} param.bookmarks the bookmarks.
144144
* @param {TxConfig} param.txConfig the configuration.
145145
* @param {string} param.database the target database name.
146146
* @param {string} param.mode the access mode.
@@ -152,7 +152,7 @@ export default class BoltProtocol {
152152
* @returns {StreamObserver} the stream observer that monitors the corresponding server response.
153153
*/
154154
beginTransaction ({
155-
bookmark,
155+
bookmarks,
156156
txConfig,
157157
database,
158158
mode,
@@ -164,9 +164,9 @@ export default class BoltProtocol {
164164
} = {}) {
165165
return this.run(
166166
'BEGIN',
167-
bookmark ? bookmark.asBeginTransactionParameters() : {},
167+
bookmarks ? bookmarks.asBeginTransactionParameters() : {},
168168
{
169-
bookmark: bookmark,
169+
bookmarks: bookmarks,
170170
txConfig: txConfig,
171171
database,
172172
mode,
@@ -201,7 +201,7 @@ export default class BoltProtocol {
201201
'COMMIT',
202202
{},
203203
{
204-
bookmark: Bookmark.empty(),
204+
bookmarks: Bookmarks.empty(),
205205
txConfig: TxConfig.empty(),
206206
mode: ACCESS_MODE_WRITE,
207207
beforeError,
@@ -233,7 +233,7 @@ export default class BoltProtocol {
233233
'ROLLBACK',
234234
{},
235235
{
236-
bookmark: Bookmark.empty(),
236+
bookmarks: Bookmarks.empty(),
237237
txConfig: TxConfig.empty(),
238238
mode: ACCESS_MODE_WRITE,
239239
beforeError,
@@ -249,7 +249,7 @@ export default class BoltProtocol {
249249
* @param {string} query the cypher query.
250250
* @param {Object} parameters the query parameters.
251251
* @param {Object} param
252-
* @param {Bookmark} param.bookmark the bookmark.
252+
* @param {Bookmarks} param.bookmarks the bookmarks.
253253
* @param {TxConfig} param.txConfig the transaction configuration.
254254
* @param {string} param.database the target database name.
255255
* @param {string} param.impersonatedUser the impersonated user
@@ -267,7 +267,7 @@ export default class BoltProtocol {
267267
query,
268268
parameters,
269269
{
270-
bookmark,
270+
bookmarks,
271271
txConfig,
272272
database,
273273
mode,
@@ -295,7 +295,7 @@ export default class BoltProtocol {
295295
lowRecordWatermark
296296
})
297297

298-
// bookmark and mode are ignored in this version of the protocol
298+
// bookmarks and mode are ignored in this version of the protocol
299299
assertTxConfigIsEmpty(txConfig, this._onProtocolError, observer)
300300
// passing in a database name on this protocol version throws an error
301301
assertDatabaseIsEmpty(database, this._onProtocolError, observer)

packages/bolt-connection/src/bolt/bolt-protocol-v3.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
import { internal } from 'neo4j-driver-core'
2929

3030
const {
31-
bookmark: { Bookmark },
31+
bookmarks: { Bookmarks },
3232
constants: { BOLT_PROTOCOL_V3 },
3333
txConfig: { TxConfig }
3434
} = internal
@@ -75,7 +75,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
7575
}
7676

7777
beginTransaction ({
78-
bookmark,
78+
bookmarks,
7979
txConfig,
8080
database,
8181
impersonatedUser,
@@ -100,7 +100,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
100100
assertImpersonatedUserIsEmpty(impersonatedUser, this._onProtocolError, observer)
101101

102102
this.write(
103-
RequestMessage.begin({ bookmark, txConfig, mode }),
103+
RequestMessage.begin({ bookmarks, txConfig, mode }),
104104
observer,
105105
true
106106
)
@@ -152,7 +152,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
152152
query,
153153
parameters,
154154
{
155-
bookmark,
155+
bookmarks,
156156
txConfig,
157157
database,
158158
impersonatedUser,
@@ -187,7 +187,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
187187

188188
this.write(
189189
RequestMessage.runWithMetadata(query, parameters, {
190-
bookmark,
190+
bookmarks,
191191
txConfig,
192192
mode
193193
}),
@@ -206,7 +206,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
206206
* @param {object} param.routingContext The routing context used to define the routing table.
207207
* Multi-datacenter deployments is one of its use cases
208208
* @param {string} param.databaseName The database name
209-
* @param {Bookmark} params.sessionContext.bookmark The bookmark used for request the routing table
209+
* @param {Bookmarks} params.sessionContext.bookmarks The bookmarks used for requesting the routing table
210210
* @param {string} params.sessionContext.mode The session mode
211211
* @param {string} params.sessionContext.database The database name used on the session
212212
* @param {function()} params.sessionContext.afterComplete The session param used after the session closed

packages/bolt-connection/src/bolt/bolt-protocol-v4x0.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
import { internal } from 'neo4j-driver-core'
2828

2929
const {
30-
bookmark: { Bookmark },
30+
bookmarks: { Bookmarks },
3131
constants: { BOLT_PROTOCOL_V4_0, FETCH_ALL },
3232
txConfig: { TxConfig }
3333
} = internal
@@ -42,7 +42,7 @@ export default class BoltProtocol extends BoltProtocolV3 {
4242
}
4343

4444
beginTransaction ({
45-
bookmark,
45+
bookmarks,
4646
txConfig,
4747
database,
4848
impersonatedUser,
@@ -65,7 +65,7 @@ export default class BoltProtocol extends BoltProtocolV3 {
6565
assertImpersonatedUserIsEmpty(impersonatedUser, this._onProtocolError, observer)
6666

6767
this.write(
68-
RequestMessage.begin({ bookmark, txConfig, database, mode }),
68+
RequestMessage.begin({ bookmarks, txConfig, database, mode }),
6969
observer,
7070
true
7171
)
@@ -77,7 +77,7 @@ export default class BoltProtocol extends BoltProtocolV3 {
7777
query,
7878
parameters,
7979
{
80-
bookmark,
80+
bookmarks,
8181
txConfig,
8282
database,
8383
impersonatedUser,
@@ -117,7 +117,7 @@ export default class BoltProtocol extends BoltProtocolV3 {
117117
const flushRun = reactive
118118
this.write(
119119
RequestMessage.runWithMetadata(query, parameters, {
120-
bookmark,
120+
bookmarks,
121121
txConfig,
122122
database,
123123
mode
@@ -150,7 +150,7 @@ export default class BoltProtocol extends BoltProtocolV3 {
150150
* @param {object} param.routingContext The routing context used to define the routing table.
151151
* Multi-datacenter deployments is one of its use cases
152152
* @param {string} param.databaseName The database name
153-
* @param {Bookmark} params.sessionContext.bookmark The bookmark used for request the routing table
153+
* @param {Bookmarks} params.sessionContext.bookmarks The bookmarks used for requesting the routing table
154154
* @param {string} params.sessionContext.mode The session mode
155155
* @param {string} params.sessionContext.database The database name used on the session
156156
* @param {function()} params.sessionContext.afterComplete The session param used after the session closed

packages/bolt-connection/src/bolt/bolt-protocol-v4x3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { RouteObserver } from './stream-observers'
2323
import { internal } from 'neo4j-driver-core'
2424

2525
const {
26-
bookmark: { Bookmark },
26+
bookmarks: { Bookmarks },
2727
constants: { BOLT_PROTOCOL_V4_3 }
2828
} = internal
2929

@@ -39,7 +39,7 @@ export default class BoltProtocol extends BoltProtocolV42 {
3939
* @param {object} param.routingContext The routing context used to define the routing table.
4040
* Multi-datacenter deployments is one of its use cases
4141
* @param {string} param.databaseName The database name
42-
* @param {Bookmark} params.sessionContext.bookmark The bookmark used for request the routing table
42+
* @param {Bookmarks} params.sessionContext.bookmarks The bookmarks used for requesting the routing table
4343
* @param {function(err: Error)} param.onError
4444
* @param {function(RawRoutingTable)} param.onCompleted
4545
* @returns {RouteObserver} the route observer
@@ -56,9 +56,9 @@ export default class BoltProtocol extends BoltProtocolV42 {
5656
onError,
5757
onCompleted
5858
})
59-
const bookmark = sessionContext.bookmark || Bookmark.empty()
59+
const bookmarks = sessionContext.bookmarks || Bookmarks.empty()
6060
this.write(
61-
RequestMessage.route(routingContext, bookmark.values(), databaseName),
61+
RequestMessage.route(routingContext, bookmarks.values(), databaseName),
6262
observer,
6363
true
6464
)

packages/bolt-connection/src/bolt/bolt-protocol-v4x4.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { RouteObserver, ResultStreamObserver } from './stream-observers'
2424

2525
const {
2626
constants: { BOLT_PROTOCOL_V4_4, FETCH_ALL },
27-
bookmark: { Bookmark },
27+
bookmarks: { Bookmarks },
2828
} = internal
2929

3030
export default class BoltProtocol extends BoltProtocolV43 {
@@ -39,7 +39,7 @@ export default class BoltProtocol extends BoltProtocolV43 {
3939
* @param {object} param.routingContext The routing context used to define the routing table.
4040
* Multi-datacenter deployments is one of its use cases
4141
* @param {string} param.databaseName The database name
42-
* @param {Bookmark} params.sessionContext.bookmark The bookmark used for request the routing table
42+
* @param {Bookmarks} params.sessionContext.bookmarks The bookmarks used for requesting the routing table
4343
* @param {function(err: Error)} param.onError
4444
* @param {function(RawRoutingTable)} param.onCompleted
4545
* @returns {RouteObserver} the route observer
@@ -57,9 +57,9 @@ export default class BoltProtocol extends BoltProtocolV43 {
5757
onError,
5858
onCompleted
5959
})
60-
const bookmark = sessionContext.bookmark || Bookmark.empty()
60+
const bookmarks = sessionContext.bookmarks || Bookmarks.empty()
6161
this.write(
62-
RequestMessage.routeV4x4(routingContext, bookmark.values(), { databaseName, impersonatedUser }),
62+
RequestMessage.routeV4x4(routingContext, bookmarks.values(), { databaseName, impersonatedUser }),
6363
observer,
6464
true
6565
)
@@ -71,7 +71,7 @@ export default class BoltProtocol extends BoltProtocolV43 {
7171
query,
7272
parameters,
7373
{
74-
bookmark,
74+
bookmarks,
7575
txConfig,
7676
database,
7777
mode,
@@ -108,7 +108,7 @@ export default class BoltProtocol extends BoltProtocolV43 {
108108
const flushRun = reactive
109109
this.write(
110110
RequestMessage.runWithMetadata(query, parameters, {
111-
bookmark,
111+
bookmarks,
112112
txConfig,
113113
database,
114114
mode,
@@ -126,7 +126,7 @@ export default class BoltProtocol extends BoltProtocolV43 {
126126
}
127127

128128
beginTransaction ({
129-
bookmark,
129+
bookmarks,
130130
txConfig,
131131
database,
132132
mode,
@@ -146,7 +146,7 @@ export default class BoltProtocol extends BoltProtocolV43 {
146146
observer.prepareToHandleSingleResponse()
147147

148148
this.write(
149-
RequestMessage.begin({ bookmark, txConfig, database, mode, impersonatedUser }),
149+
RequestMessage.begin({ bookmarks, txConfig, database, mode, impersonatedUser }),
150150
observer,
151151
true
152152
)

packages/bolt-connection/src/bolt/request-message.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ export default class RequestMessage {
120120

121121
/**
122122
* Create a new BEGIN message.
123-
* @param {Bookmark} bookmark the bookmark.
123+
* @param {Bookmarks} bookmarks the bookmarks.
124124
* @param {TxConfig} txConfig the configuration.
125125
* @param {string} database the database name.
126126
* @param {string} mode the access mode.
127127
* @param {string} impersonatedUser the impersonated user.
128128
* @return {RequestMessage} new BEGIN message.
129129
*/
130-
static begin ({ bookmark, txConfig, database, mode, impersonatedUser } = {}) {
131-
const metadata = buildTxMetadata(bookmark, txConfig, database, mode, impersonatedUser)
130+
static begin ({ bookmarks, txConfig, database, mode, impersonatedUser } = {}) {
131+
const metadata = buildTxMetadata(bookmarks, txConfig, database, mode, impersonatedUser)
132132
return new RequestMessage(
133133
BEGIN,
134134
[metadata],
@@ -156,7 +156,7 @@ export default class RequestMessage {
156156
* Create a new RUN message with additional metadata.
157157
* @param {string} query the cypher query.
158158
* @param {Object} parameters the query parameters.
159-
* @param {Bookmark} bookmark the bookmark.
159+
* @param {Bookmarks} bookmarks the bookmarks.
160160
* @param {TxConfig} txConfig the configuration.
161161
* @param {string} database the database name.
162162
* @param {string} mode the access mode.
@@ -166,9 +166,9 @@ export default class RequestMessage {
166166
static runWithMetadata (
167167
query,
168168
parameters,
169-
{ bookmark, txConfig, database, mode, impersonatedUser } = {}
169+
{ bookmarks, txConfig, database, mode, impersonatedUser } = {}
170170
) {
171-
const metadata = buildTxMetadata(bookmark, txConfig, database, mode, impersonatedUser)
171+
const metadata = buildTxMetadata(bookmarks, txConfig, database, mode, impersonatedUser)
172172
return new RequestMessage(
173173
RUN,
174174
[query, parameters, metadata],
@@ -225,7 +225,7 @@ export default class RequestMessage {
225225
* Generate the ROUTE message, this message is used to fetch the routing table from the server
226226
*
227227
* @param {object} routingContext The routing context used to define the routing table. Multi-datacenter deployments is one of its use cases
228-
* @param {string[]} bookmarks The list of the bookmark should be used
228+
* @param {string[]} bookmarks The list of the bookmarks should be used
229229
* @param {string} databaseName The name of the database to get the routing table for.
230230
* @return {RequestMessage} the ROUTE message.
231231
*/
@@ -244,7 +244,7 @@ export default class RequestMessage {
244244
* Generate the ROUTE message, this message is used to fetch the routing table from the server
245245
*
246246
* @param {object} routingContext The routing context used to define the routing table. Multi-datacenter deployments is one of its use cases
247-
* @param {string[]} bookmarks The list of the bookmark should be used
247+
* @param {string[]} bookmarks The list of the bookmarks should be used
248248
* @param {object} databaseContext The context inforamtion of the database to get the routing table for.
249249
* @param {string} databaseContext.databaseName The name of the database to get the routing table.
250250
* @param {string} databaseContext.impersonatedUser The name of the user to impersonation when getting the routing table.
@@ -274,17 +274,17 @@ export default class RequestMessage {
274274

275275
/**
276276
* Create an object that represent transaction metadata.
277-
* @param {Bookmark} bookmark the bookmark.
277+
* @param {Bookmarks} bookmarks the bookmarks.
278278
* @param {TxConfig} txConfig the configuration.
279279
* @param {string} database the database name.
280280
* @param {string} mode the access mode.
281281
* @param {string} impersonatedUser the impersonated user mode.
282282
* @return {Object} a metadata object.
283283
*/
284-
function buildTxMetadata (bookmark, txConfig, database, mode, impersonatedUser) {
284+
function buildTxMetadata (bookmarks, txConfig, database, mode, impersonatedUser) {
285285
const metadata = {}
286-
if (!bookmark.isEmpty()) {
287-
metadata.bookmarks = bookmark.values()
286+
if (!bookmarks.isEmpty()) {
287+
metadata.bookmarks = bookmarks.values()
288288
}
289289
if (txConfig.timeout !== null) {
290290
metadata.tx_timeout = txConfig.timeout

0 commit comments

Comments
 (0)