Skip to content

Commit 4e892a2

Browse files
committed
Add notification filters to Connection.initialize
1 parent 3221e22 commit 4e892a2

File tree

7 files changed

+51
-18
lines changed

7 files changed

+51
-18
lines changed

packages/bolt-connection/src/connection/connection-channel.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,27 @@ export default class ChannelConnection extends Connection {
169169
* Send initialization message.
170170
* @param {string} userAgent the user agent for this driver.
171171
* @param {Object} authToken the object containing auth information.
172+
* @param {?string[]} notificationFilters the notification filters.
172173
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.
173174
*/
174-
connect (userAgent, authToken) {
175-
return this._initialize(userAgent, authToken)
175+
connect (userAgent, authToken, notificationFilters) {
176+
return this._initialize(userAgent, authToken, notificationFilters)
176177
}
177178

178179
/**
179180
* Perform protocol-specific initialization which includes authentication.
180181
* @param {string} userAgent the user agent for this driver.
181182
* @param {Object} authToken the object containing auth information.
183+
* @param {?string[]} notificationFilters the notification filters.
182184
* @return {Promise<Connection>} promise resolved with the current connection if initialization is successful. Rejected promise otherwise.
183185
*/
184-
_initialize (userAgent, authToken) {
186+
_initialize (userAgent, authToken, notificationFilters) {
185187
const self = this
186188
return new Promise((resolve, reject) => {
187189
this._protocol.initialize({
188190
userAgent,
189191
authToken,
192+
notificationFilters,
190193
onError: err => reject(err),
191194
onComplete: metadata => {
192195
if (metadata) {
@@ -340,13 +343,14 @@ export default class ChannelConnection extends Connection {
340343
})
341344
}
342345

343-
_reset(observer) {
346+
_reset (observer) {
344347
if (this._reseting) {
345348
if (!this._protocol.isLastMessageReset()) {
346349
this._protocol.reset({
347350
onError: error => {
348351
observer.onError(error)
349-
}, onComplete: () => {
352+
},
353+
onComplete: () => {
350354
observer.onComplete()
351355
}
352356
})
@@ -369,7 +373,8 @@ export default class ChannelConnection extends Connection {
369373
this._protocol.reset({
370374
onError: error => {
371375
notifyFinish(obs => obs.onError(error))
372-
}, onComplete: () => {
376+
},
377+
onComplete: () => {
373378
notifyFinish(obs => obs.onComplete())
374379
}
375380
})

packages/bolt-connection/src/connection/connection-delegate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export default class DelegateConnection extends Connection {
7171
return this._delegate.protocol()
7272
}
7373

74-
connect (userAgent, authToken) {
75-
return this._delegate.connect(userAgent, authToken)
74+
connect (userAgent, authToken, notificationFilters) {
75+
return this._delegate.connect(userAgent, authToken, notificationFilters)
7676
}
7777

7878
write (message, observer, flush) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ export default class Connection {
7979
* Connect to the target address, negotiate Bolt protocol and send initialization message.
8080
* @param {string} userAgent the user agent for this driver.
8181
* @param {Object} authToken the object containing auth information.
82+
* @param {?string[]} notificationFilters the notification filters.
8283
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.
8384
*/
84-
connect (userAgent, authToken) {
85+
connect (userAgent, authToken, notificationFilters) {
8586
throw new Error('not implemented')
8687
}
8788

packages/bolt-connection/test/connection/connection-channel.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,27 @@ describe('ChannelConnection', () => {
124124
)
125125
}
126126
)
127+
128+
it.each([
129+
undefined,
130+
null,
131+
[],
132+
['*.*', 'WARNING.*']
133+
])('should call protocol.initialize with notification filters when notificationFilters is %o',
134+
async (notificationFilters) => {
135+
const protocol = {
136+
initialize: jest.fn(observer => observer.onComplete({}))
137+
}
138+
const protocolSupplier = () => protocol
139+
const connection = spyOnConnectionChannel({ protocolSupplier })
140+
141+
await connection.connect('userAgent', {}, notificationFilters)
142+
143+
expect(protocol.initialize).toHaveBeenCalledTimes(1)
144+
expect(protocol.initialize).toBeCalledWith(expect.objectContaining({
145+
notificationFilters
146+
}))
147+
})
127148
})
128149

129150
describe('._handleFatalError()', () => {

packages/neo4j-driver-deno/lib/bolt-connection/connection/connection-channel.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,27 @@ export default class ChannelConnection extends Connection {
169169
* Send initialization message.
170170
* @param {string} userAgent the user agent for this driver.
171171
* @param {Object} authToken the object containing auth information.
172+
* @param {?string[]} notificationFilters the notification filters.
172173
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.
173174
*/
174-
connect (userAgent, authToken) {
175-
return this._initialize(userAgent, authToken)
175+
connect (userAgent, authToken, notificationFilters) {
176+
return this._initialize(userAgent, authToken, notificationFilters)
176177
}
177178

178179
/**
179180
* Perform protocol-specific initialization which includes authentication.
180181
* @param {string} userAgent the user agent for this driver.
181182
* @param {Object} authToken the object containing auth information.
183+
* @param {?string[]} notificationFilters the notification filters.
182184
* @return {Promise<Connection>} promise resolved with the current connection if initialization is successful. Rejected promise otherwise.
183185
*/
184-
_initialize (userAgent, authToken) {
186+
_initialize (userAgent, authToken, notificationFilters) {
185187
const self = this
186188
return new Promise((resolve, reject) => {
187189
this._protocol.initialize({
188190
userAgent,
189191
authToken,
192+
notificationFilters,
190193
onError: err => reject(err),
191194
onComplete: metadata => {
192195
if (metadata) {
@@ -340,13 +343,14 @@ export default class ChannelConnection extends Connection {
340343
})
341344
}
342345

343-
_reset(observer) {
346+
_reset (observer) {
344347
if (this._reseting) {
345348
if (!this._protocol.isLastMessageReset()) {
346349
this._protocol.reset({
347350
onError: error => {
348351
observer.onError(error)
349-
}, onComplete: () => {
352+
},
353+
onComplete: () => {
350354
observer.onComplete()
351355
}
352356
})
@@ -369,7 +373,8 @@ export default class ChannelConnection extends Connection {
369373
this._protocol.reset({
370374
onError: error => {
371375
notifyFinish(obs => obs.onError(error))
372-
}, onComplete: () => {
376+
},
377+
onComplete: () => {
373378
notifyFinish(obs => obs.onComplete())
374379
}
375380
})

packages/neo4j-driver-deno/lib/bolt-connection/connection/connection-delegate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export default class DelegateConnection extends Connection {
7171
return this._delegate.protocol()
7272
}
7373

74-
connect (userAgent, authToken) {
75-
return this._delegate.connect(userAgent, authToken)
74+
connect (userAgent, authToken, notificationFilters) {
75+
return this._delegate.connect(userAgent, authToken, notificationFilters)
7676
}
7777

7878
write (message, observer, flush) {

packages/neo4j-driver-deno/lib/bolt-connection/connection/connection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ export default class Connection {
7979
* Connect to the target address, negotiate Bolt protocol and send initialization message.
8080
* @param {string} userAgent the user agent for this driver.
8181
* @param {Object} authToken the object containing auth information.
82+
* @param {?string[]} notificationFilters the notification filters.
8283
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.
8384
*/
84-
connect (userAgent, authToken) {
85+
connect (userAgent, authToken, notificationFilters) {
8586
throw new Error('not implemented')
8687
}
8788

0 commit comments

Comments
 (0)