Skip to content

Commit 234d4c2

Browse files
authored
Merge pull request #1012 from oskarhane/prefer-routed-url
Prefer `bolt_routing` URL from discovery if it exists
2 parents 7e02376 + d6a19a1 commit 234d4c2

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/shared/modules/discovery/discoveryDuck.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ export const discoveryOnStartupEpic = (some$, store) => {
136136
// fake discovery response
137137
// Promise.resolve({ bolt: 'bolt+routing://localhost:7687' })
138138
.then(result => {
139-
const host = result && (result.bolt_direct || result.bolt)
139+
const host =
140+
result &&
141+
(result.bolt_routing || result.bolt_direct || result.bolt)
140142
// Try to get info from server
141143
if (!host) {
142144
throw new Error('No bolt address found') // No bolt info from server, throw

src/shared/modules/discovery/discoveryDuck.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,30 @@ describe('discoveryOnStartupEpic', () => {
146146
// When
147147
store.dispatch(action)
148148
})
149+
test('listens on APP_START and finds all of bolt_routing, bolt_direct and a bold host and dispatches an action with the found bolt_routing host', done => {
150+
// Given
151+
const action = { type: APP_START, env: WEB }
152+
const expectedHost = 'neo4j://myhost:7777'
153+
nock(getDiscoveryEndpoint())
154+
.get('/')
155+
.reply(200, {
156+
bolt_routing: expectedHost,
157+
bolt_direct: 'bolt://myhost:666',
158+
bolt: 'very://bad:1337'
159+
})
160+
bus.take(discovery.DONE, currentAction => {
161+
// Then
162+
expect(store.getActions()).toEqual([
163+
action,
164+
discovery.updateDiscoveryConnection({ host: expectedHost }),
165+
{ type: discovery.DONE }
166+
])
167+
done()
168+
})
169+
170+
// When
171+
store.dispatch(action)
172+
})
149173
test('listens on APP_START and reads bolt URL from location URL and dispatches an action with the found host', done => {
150174
// Given
151175
const action = {

0 commit comments

Comments
 (0)