feat: support bolt+routing#391
Draft
mattkjames7 wants to merge 2 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Expose client-side Bolt routing support (for Memgraph HA) through GQLAlchemy’s connection/vendor layers, and add CI + tests to validate routed read/write behavior.
Changes:
- Add routing-capable connection creation (
routing,access_mode,resolver) toMemgraphConnectionand plumb it through theMemgraphvendor client. - Introduce a
GQLAlchemyTransientErrorand mapmgclient.TransientErrorviadatabase_error_handler. - Add HA routing integration tests plus a Docker-based HA cluster bootstrap script and CI workflow step.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
gqlalchemy/connection.py |
Adds routing/access-mode/resolver plumbing into mgclient.connect(...) creation. |
gqlalchemy/vendors/memgraph.py |
Passes routing parameters from Memgraph client into MemgraphConnection. |
gqlalchemy/exceptions.py |
Adds GQLAlchemyTransientError and maps transient driver errors in the decorator. |
gqlalchemy/__init__.py |
Exposes new exception types at the package top-level. |
tests/test_exceptions.py |
Adds unit tests for transient vs non-transient error mapping behavior. |
tests/integration/test_routing.py |
Adds integration tests validating routed READ/WRITE connections against an HA cluster. |
scripts/ha_cluster.sh |
Adds a helper script to start/stop a local Memgraph HA cluster in Docker for tests/CI. |
pytest.ini |
Registers a routing marker for HA-dependent tests. |
pyproject.toml |
Temporarily points pymgclient to a git branch via uv sources to develop/test routing. |
.github/workflows/build-and-test.yml |
Starts/stops the HA cluster in CI (when license secrets exist) to run routing tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
222
to
226
| return func(*args, **kwargs) | ||
| except mgclient.TransientError as e: | ||
| raise GQLAlchemyTransientError(e) from e | ||
| except Exception as e: | ||
| raise GQLAlchemyDatabaseError(e) from e |
Comment on lines
+97
to
+100
| # TEMPORARY: client-side routing (connect(routing=True, ...)) is not yet in a | ||
| # released pymgclient. Track the branch so routing can be developed/tested; | ||
| # drop this and bump the "pymgclient" pin above once it ships in a release. | ||
| pymgclient = { git = "https://github.com/memgraph/pymgclient.git", branch = "bolt-routing-wrapper" } |
Comment on lines
+31
to
+34
| def test_transient_error_is_mapped_to_gqlalchemy_transient_error(): | ||
| @database_error_handler | ||
| def boom(): | ||
| raise mgclient.TransientError("instance briefly unreachable during a failover") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Expose bolt+routing support for Memgraph HA provided by
pymgclientin memgraph/pymgclient#86Pull request type
Please delete options that are not relevant.
Related issues
Delete section if this PR doesn't resolve any issues.
Closes (link to issue)
Checklist:
######################################
Reviewer checklist (the reviewer checks this part)
######################################