Skip to content

Commit ada44e2

Browse files
whummerclaudepurcell
authored
skip HTTP proxy in base class for TCP-only extensions (#130)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Steve Purcell <steve@sanityinc.com>
1 parent 06250fa commit ada44e2

File tree

10 files changed

+58
-49
lines changed

10 files changed

+58
-49
lines changed

.github/workflows/aws-proxy.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
name: LocalStack AWS Proxy Extension Tests
22

33
on:
4-
push:
5-
paths:
6-
- aws-proxy/**
7-
branches:
8-
- main
9-
pull_request:
10-
paths:
11-
- .github/workflows/aws-proxy.yml
12-
- aws-proxy/**
4+
# TODO: temporarily disabled - AWS proxy codebase needs to be fixed, to accommodate recent
5+
# changes in CLI and runtime repos, see: https://github.com/localstack/localstack/pull/13704
6+
# push:
7+
# paths:
8+
# - aws-proxy/**
9+
# branches:
10+
# - main
11+
# pull_request:
12+
# paths:
13+
# - .github/workflows/aws-proxy.yml
14+
# - aws-proxy/**
1315
workflow_dispatch:
1416

1517
jobs:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ You can install the respective extension by calling `localstack extensions insta
7676
| [Stripe](https://github.com/localstack/localstack-extensions/tree/main/stripe) | localstack-extension-stripe | 0.2.0 | Stable |
7777
| [Terraform Init](https://github.com/localstack/localstack-extensions/tree/main/terraform-init) | localstack-extension-terraform-init | 0.2.0 | Experimental |
7878
| [TypeDB](https://github.com/localstack/localstack-extensions/tree/main/typedb) | localstack-extension-typedb | 0.1.3 | Experimental |
79-
| [ParadeDB](https://github.com/localstack/localstack-extensions/tree/main/paradedb) | localstack-extension-paradedb | 0.1.0 | Experimental |
79+
| [WireMock](https://github.com/localstack/localstack-extensions/tree/main/wiremock) | localstack-wiremock | 0.1.0 | Experimental |
80+
| [ParadeDB](https://github.com/localstack/localstack-extensions/tree/main/paradedb) | localstack-extension-paradedb | 0.1.0 | Experimental |
8081

8182

8283
## Developing Extensions

paradedb/localstack_paradedb/extension.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from localstack_extensions.utils.docker import ProxiedDockerContainerExtension
55
from localstack import config
6-
from localstack.extensions.api import http
76

87
# Environment variables for configuration
98
ENV_POSTGRES_USER = "PARADEDB_POSTGRES_USER"
@@ -57,23 +56,6 @@ def _tcp_health_check():
5756
tcp_ports=[postgres_port], # Enable TCP proxying through gateway
5857
)
5958

60-
# TODO: this should be migrated into the base class directly ..!
61-
def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
62-
"""
63-
Override to set up only TCP routing without HTTP proxy.
64-
65-
ParadeDB uses the native PostgreSQL wire protocol (not HTTP), so we
66-
only need TCP protocol routing - not HTTP proxying. Adding an HTTP
67-
proxy without a host restriction would cause all HTTP requests to be
68-
forwarded to the PostgreSQL container, breaking other services.
69-
"""
70-
# Start the container
71-
self.start_container()
72-
73-
# Set up only TCP protocol routing (skip HTTP proxy from base class)
74-
if self.tcp_ports:
75-
self._setup_tcp_protocol_routing()
76-
7759
def tcp_connection_matcher(self, data: bytes) -> bool:
7860
"""
7961
Identify PostgreSQL/ParadeDB connections by protocol handshake.

paradedb/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dev = [
2525
"boto3",
2626
"build",
2727
"jsonpatch",
28-
"localstack",
28+
"localstack-core",
2929
"psycopg2-binary",
3030
"pytest",
3131
"rolo",

paradedb/tests/test_extension.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import boto3
22
import psycopg2
33
from localstack.utils.strings import short_uid
4+
from localstack.utils.sync import retry
45

56

67
# Connection details for ParadeDB
@@ -13,14 +14,16 @@
1314

1415

1516
def get_connection():
16-
"""Create a connection to ParadeDB."""
17-
return psycopg2.connect(
18-
host=HOST,
19-
port=PORT,
20-
user=USER,
21-
password=PASSWORD,
22-
database=DATABASE,
23-
)
17+
"""Create a connection to ParadeDB, retrying until the server is ready."""
18+
def _connect():
19+
return psycopg2.connect(
20+
host=HOST,
21+
port=PORT,
22+
user=USER,
23+
password=PASSWORD,
24+
database=DATABASE,
25+
)
26+
return retry(_connect, retries=15, sleep=2.0)
2427

2528

2629
def test_connect_to_paradedb():

typedb/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dev = [
2525
"boto3",
2626
"build",
2727
"jsonpatch",
28-
"localstack",
28+
"localstack-core",
2929
"pytest",
3030
"rolo",
3131
"ruff",

utils/localstack_extensions/utils/docker.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,21 @@ def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
134134
)
135135
# note: for simplicity, starting the external container at startup - could be optimized over time ...
136136
self.start_container()
137-
# add resource for HTTP/1.1 requests
138-
resource = RuleAdapter(ProxyResource(self.container_host, self.main_port))
139-
if self.host:
140-
resource = WithHost(self.host, [resource])
141-
router.add(resource)
137+
138+
# Determine if HTTP proxy should be set up. Skip it when all container ports are
139+
# TCP-only and no host restriction is set, since a catch-all HTTP proxy would
140+
# intercept all requests and break other services.
141+
uses_http = (
142+
self.host
143+
and set(self.container_ports) - set(self.tcp_ports or [])
144+
)
145+
146+
if uses_http:
147+
# add resource for HTTP/1.1 requests
148+
resource = RuleAdapter(ProxyResource(self.container_host, self.main_port))
149+
if self.host:
150+
resource = WithHost(self.host, [resource])
151+
router.add(resource)
142152

143153
# apply patches to serve HTTP/2 requests
144154
for port in self.http2_ports or []:

utils/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ dev = [
3232
"boto3",
3333
"build",
3434
"jsonpatch",
35-
"localstack",
35+
"localstack-core",
3636
"pytest",
3737
"ruff",
3838
]
3939
test = [
4040
"grpcio>=1.60.0",
4141
"grpcio-tools>=1.60.0",
4242
"jsonpatch",
43-
"localstack",
43+
"localstack-core",
4444
"pytest>=7.0",
4545
"pytest-timeout>=2.0",
4646
]

wiremock/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ localstack start
108108

109109
- `WIREMOCK_API_TOKEN`: Your WireMock Cloud API token (required for runner mode)
110110
- `WIREMOCK_CONFIG_DIR`: Path to the directory containing your `.wiremock` folder (required for runner mode)
111+
- `WIREMOCK_IMAGE`: Custom Docker image name for the Wiremock OSS image (default: `wiremock/wiremock`)
112+
- `WIREMOCK_IMAGE_RUNNER`: Custom Docker image name for the Wiremock Cloud runner image (default: `wiremock/wiremock-runner`)
111113

112114
Note: When using the LocalStack CLI, prefix environment variables with `LOCALSTACK_` to forward them to the container.
113115

@@ -118,3 +120,12 @@ See the `sample-app-runner/` directory for a complete example using Terraform th
118120
- Creating an API Gateway
119121
- Lambda function that calls WireMock stubs
120122
- Integration testing with mocked external APIs
123+
124+
## Change Log
125+
126+
- `0.1.1`: Add environment variables to customize the WireMock image names
127+
- `0.1.0`: Initial release of the extension
128+
129+
## License
130+
131+
This project is licensed under the Apache License, Version 2.0.

wiremock/pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "localstack-wiremock"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "WireMock Extension for LocalStack"
99
readme = {file = "README.md", content-type = "text/markdown; charset=UTF-8"}
1010
requires-python = ">=3.9"
@@ -14,8 +14,8 @@ authors = [
1414
keywords = ["LocalStack", "WireMock"]
1515
classifiers = []
1616
dependencies = [
17-
"priority",
18-
"localstack-extensions-utils"
17+
"localstack-extensions-utils",
18+
"priority"
1919
]
2020

2121
[project.urls]
@@ -26,7 +26,7 @@ dev = [
2626
"boto3",
2727
"build",
2828
"jsonpatch",
29-
"localstack",
29+
"localstack-core",
3030
"pytest",
3131
"rolo",
3232
"ruff",

0 commit comments

Comments
 (0)