Skip to content

Commit 88ec702

Browse files
authored
Bolt agent added to hello metadata (#1076)
1 parent 1d15ccb commit 88ec702

File tree

98 files changed

+3000
-251
lines changed

Some content is hidden

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

98 files changed

+3000
-251
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"build::notci": "lerna bootstrap",
4545
"docs": "lerna run docs --stream --concurrency 1",
4646
"test::unit": "lerna run test::unit --stream",
47+
"test::deno": "lerna run test::deno --stream",
4748
"test::integration": "lerna run test::integration --stream",
4849
"test::browser": "lerna run test::browser --stream",
4950
"test::stress": "lerna run test::stress --stream",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default class BoltProtocol {
175175
* @param {function()} param.onComplete the callback to invoke on completion.
176176
* @returns {StreamObserver} the stream observer that monitors the corresponding server response.
177177
*/
178-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
178+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
179179
const observer = new LoginObserver({
180180
onError: error => this._onLoginError(error, onError),
181181
onCompleted: metadata => this._onLoginCompleted(metadata, onComplete)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
6969
return metadata
7070
}
7171

72-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
72+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
7373
const observer = new LoginObserver({
7474
onError: error => this._onLoginError(error, onError),
7575
onCompleted: metadata => this._onLoginCompleted(metadata, authToken, onComplete)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class BoltProtocol extends BoltProtocolV4 {
7373
return this._transformer
7474
}
7575

76-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
76+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
7777
const observer = new LoginObserver({
7878
onError: error => this._onLoginError(error, onError),
7979
onCompleted: metadata => this._onLoginCompleted(metadata, authToken, onComplete)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default class BoltProtocol extends BoltProtocolV42 {
8989
* @param {function(onComplte)} args.onComplete On complete callback
9090
* @returns {LoginObserver} The Login observer
9191
*/
92-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
92+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
9393
const observer = new LoginObserver({
9494
onError: error => this._onLoginError(error, onError),
9595
onCompleted: metadata => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default class BoltProtocol extends BoltProtocolV44 {
5353
* @param {function(onComplte)} args.onComplete On complete callback
5454
* @returns {LoginObserver} The Login observer
5555
*/
56-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
56+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
5757
const observer = new LoginObserver({
5858
onError: error => this._onLoginError(error, onError),
5959
onCompleted: metadata => this._onLoginCompleted(metadata, authToken, onComplete)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class BoltProtocol extends BoltProtocolV5x0 {
5757
* @param {function(onComplete)} args.onComplete On complete callback
5858
* @returns {LoginObserver} The Login observer
5959
*/
60-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
60+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
6161
const state = {}
6262
const observer = new LoginObserver({
6363
onError: error => this._onLoginError(error, onError),

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ export default class BoltProtocol extends BoltProtocolV5x1 {
5050
*
5151
* @param {Object} args The params
5252
* @param {string} args.userAgent The user agent
53+
* @param {string} args.boltAgent The bolt agent
5354
* @param {any} args.authToken The auth token
5455
* @param {NotificationFilter} args.notificationFilter The notification filters.
5556
* @param {function(error)} args.onError On error callback
5657
* @param {function(onComplete)} args.onComplete On complete callback
5758
* @returns {LoginObserver} The Login observer
5859
*/
59-
initialize ({ userAgent, authToken, notificationFilter, onError, onComplete } = {}) {
60+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
6061
const state = {}
6162
const observer = new LoginObserver({
6263
onError: error => this._onLoginError(error, onError),
@@ -67,6 +68,7 @@ export default class BoltProtocol extends BoltProtocolV5x1 {
6768
})
6869

6970
this.write(
71+
// if useragent is null then for all versions before 5.3 it should be bolt agent by default
7072
RequestMessage.hello5x2(userAgent, notificationFilter, this._serversideRouting),
7173
observer,
7274
false
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
import BoltProtocolV5x2 from './bolt-protocol-v5x2'
20+
21+
import transformersFactories from './bolt-protocol-v5x3.transformer'
22+
import Transformer from './transformer'
23+
import RequestMessage from './request-message'
24+
import { LoginObserver } from './stream-observers'
25+
26+
import { internal } from 'neo4j-driver-core'
27+
28+
const {
29+
constants: { BOLT_PROTOCOL_V5_3 }
30+
} = internal
31+
32+
export default class BoltProtocol extends BoltProtocolV5x2 {
33+
get version () {
34+
return BOLT_PROTOCOL_V5_3
35+
}
36+
37+
get transformer () {
38+
if (this._transformer === undefined) {
39+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
40+
}
41+
return this._transformer
42+
}
43+
44+
/**
45+
* Initialize a connection with the server
46+
*
47+
* @param {Object} args The params
48+
* @param {string} args.userAgent The user agent
49+
* @param {any} args.authToken The auth token
50+
* @param {NotificationFilter} args.notificationFilter The notification filters.
51+
* @param {function(error)} args.onError On error callback
52+
* @param {function(onComplete)} args.onComplete On complete callback
53+
* @returns {LoginObserver} The Login observer
54+
*/
55+
initialize ({ userAgent, boltAgent, authToken, notificationFilter, onError, onComplete } = {}) {
56+
const state = {}
57+
const observer = new LoginObserver({
58+
onError: error => this._onLoginError(error, onError),
59+
onCompleted: metadata => {
60+
state.metadata = metadata
61+
return this._onLoginCompleted(metadata)
62+
}
63+
})
64+
65+
this.write(
66+
RequestMessage.hello5x3(userAgent, boltAgent, notificationFilter, this._serversideRouting),
67+
observer,
68+
false
69+
)
70+
71+
return this.logon({
72+
authToken,
73+
onComplete: metadata => onComplete({ ...metadata, ...state.metadata }),
74+
onError,
75+
flush: true
76+
})
77+
}
78+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
import v5x2 from './bolt-protocol-v5x2.transformer'
21+
22+
export default {
23+
...v5x2
24+
}

0 commit comments

Comments
 (0)