Skip to content

Commit 0d25c19

Browse files
committed
Implement bolt 5.0 and add it to the handshake
1 parent bca8e9c commit 0d25c19

File tree

9 files changed

+759
-36
lines changed

9 files changed

+759
-36
lines changed

neo4j/_async/io/_bolt.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,21 @@ def protocol_handlers(cls, protocol_version=None):
175175
# Carry out Bolt subclass imports locally to avoid circular dependency issues.
176176
from ._bolt3 import AsyncBolt3
177177
from ._bolt4 import (
178-
AsyncBolt4x0,
179178
AsyncBolt4x1,
180179
AsyncBolt4x2,
181180
AsyncBolt4x3,
182181
AsyncBolt4x4,
183182
)
183+
from ._bolt5 import AsyncBolt5x0
184184

185185
handlers = {
186186
AsyncBolt3.PROTOCOL_VERSION: AsyncBolt3,
187-
AsyncBolt4x0.PROTOCOL_VERSION: AsyncBolt4x0,
187+
# 4.0 unsupported because no space left in the handshake
188188
AsyncBolt4x1.PROTOCOL_VERSION: AsyncBolt4x1,
189189
AsyncBolt4x2.PROTOCOL_VERSION: AsyncBolt4x2,
190190
AsyncBolt4x3.PROTOCOL_VERSION: AsyncBolt4x3,
191191
AsyncBolt4x4.PROTOCOL_VERSION: AsyncBolt4x4,
192+
AsyncBolt5x0.PROTOCOL_VERSION: AsyncBolt5x0,
192193
}
193194

194195
if protocol_version is None:
@@ -208,9 +209,9 @@ def version_list(cls, versions, limit=4):
208209
preference. The number of protocol versions (or ranges)
209210
returned is limited to four.
210211
"""
211-
# In fact, 4.3 is the fist version to support ranges. However, the range
212-
# support got backported to 4.2. But even if the server is too old to
213-
# have the backport, negotiating BOLT 4.1 is no problem as it's
212+
# In fact, 4.3 is the fist version to support ranges. However, the
213+
# range support got backported to 4.2. But even if the server is too
214+
# old to have the backport, negotiating BOLT 4.1 is no problem as it's
214215
# equivalent to 4.2
215216
first_with_range_support = Version(4, 2)
216217
result = []
@@ -288,9 +289,12 @@ async def open(
288289
if pool_config.protocol_version == (3, 0):
289290
from ._bolt3 import AsyncBolt3
290291
bolt_cls = AsyncBolt3
291-
elif pool_config.protocol_version == (4, 0):
292-
from ._bolt4 import AsyncBolt4x0
293-
bolt_cls = AsyncBolt4x0
292+
# Implementation for 4.0 exists, but there was no space left in the
293+
# handshake to offer this version to the server. Hence, the server
294+
# should never request us to speak bolt 4.0.
295+
# elif pool_config.protocol_version == (4, 0):
296+
# from ._bolt4 import AsyncBolt4x0
297+
# bolt_cls = AsyncBolt4x0
294298
elif pool_config.protocol_version == (4, 1):
295299
from ._bolt4 import AsyncBolt4x1
296300
bolt_cls = AsyncBolt4x1
@@ -303,6 +307,9 @@ async def open(
303307
elif pool_config.protocol_version == (4, 4):
304308
from ._bolt4 import AsyncBolt4x4
305309
bolt_cls = AsyncBolt4x4
310+
elif pool_config.protocol_version == (5, 0):
311+
from ._bolt5 import AsyncBolt5x0
312+
bolt_cls = AsyncBolt5x0
306313
else:
307314
log.debug("[#%04X] S: <CLOSE>", s.getsockname()[1])
308315
AsyncBoltSocket.close_socket(s)

neo4j/_async/io/_bolt4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
class AsyncBolt4x0(AsyncBolt):
5858
""" Protocol handler for Bolt 4.0.
5959
60-
This is supported by Neo4j versions 4.0, 4.1 and 4.2.
60+
This is supported by Neo4j versions 4.0-4.4.
6161
"""
6262

6363
PROTOCOL_VERSION = Version(4, 0)

0 commit comments

Comments
 (0)