Skip to content

Commit 1cc63b7

Browse files
committed
minor polishing
1 parent c9163ab commit 1cc63b7

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

typedb/localstack_typedb/extension.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from localstack.utils.docker_utils import DOCKER_CLIENT
66
from localstack_typedb.utils.docker import ProxiedDockerContainerExtension
77
from rolo import Request
8+
from werkzeug.datastructures import Headers
89

910
# environment variable for user-defined command args to pass to TypeDB
1011
ENV_CMD_FLAGS = "TYPEDB_FLAGS"
@@ -43,6 +44,15 @@ def _get_image_command(self) -> list[str]:
4344
image_command = result["Config"]["Cmd"]
4445
return image_command
4546

47+
def should_proxy_request(self, headers: Headers) -> bool:
48+
# determine if this is a gRPC request targeting TypeDB
49+
content_type = headers.get("content-type") or ""
50+
req_path = headers.get(":path") or ""
51+
is_typedb_grpc_request = (
52+
"grpc" in content_type and "/typedb.protocol.TypeDB" in req_path
53+
)
54+
return is_typedb_grpc_request
55+
4656
def request_to_port_router(self, request: Request) -> int:
4757
# TODO add REST API / gRPC routing based on request
4858
return 1729

typedb/localstack_typedb/utils/docker.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from rolo import route
2020
from rolo.proxy import Proxy
2121
from rolo.routing import RuleAdapter, WithHost
22-
from werkzeug.datastructures import Headers
2322

2423
LOG = logging.getLogger(__name__)
2524
logging.getLogger("localstack_typedb").setLevel(
@@ -109,15 +108,6 @@ def _get_container_name(self) -> str:
109108
name = re.sub(r"\W", "-", name)
110109
return name
111110

112-
def should_proxy_request(self, headers: Headers) -> bool:
113-
# determine if this is a gRPC request targeting TypeDB
114-
content_type = headers.get("content-type") or ""
115-
req_path = headers.get(":path") or ""
116-
is_typedb_grpc_request = (
117-
"grpc" in content_type and "/typedb.protocol.TypeDB" in req_path
118-
)
119-
return is_typedb_grpc_request
120-
121111
@cache
122112
def start_container(self) -> None:
123113
container_name = self._get_container_name()

0 commit comments

Comments
 (0)