Skip to content

Commit 5841ec5

Browse files
committed
Ensure apply_http2_patches_for_grpc_support isn't called twice
1 parent bc8b601 commit 5841ec5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

typedb/localstack_typedb/utils/h2_proxy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@ def close(self):
5555
pass
5656

5757

58+
patched_connection = False
59+
5860
def apply_http2_patches_for_grpc_support(
5961
target_host: str, target_port: int, request_matcher: ProxyRequestMatcher
6062
):
6163
"""
6264
Apply some patches to proxy incoming gRPC requests and forward them to a target port.
6365
Note: this is a very brute-force approach and needs to be fixed/enhanced over time!
6466
"""
67+
LOG.debug(f"Enabling proxying to backend {target_host}:{target_port}")
68+
global patched_connection
69+
assert not patched_connection, "It is not safe to patch H2Connection twice with this function"
70+
patched_connection = True
6571

6672
class ForwardingBuffer:
6773
"""

0 commit comments

Comments
 (0)