Skip to content

Commit f9ff63f

Browse files
authored
Use in-memory broker for dramatiq local development (#232)
* Do not alert if using Dramatiq stub broker for local development * Remove dramatiq-worker docker dependency
1 parent fa37b73 commit f9ff63f

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ services:
1313
volumes:
1414
- '.:/app'
1515
depends_on:
16-
- dramatiq-worker
1716
- otel-collector
1817
command:
1918
- opentelemetry-instrument
@@ -34,7 +33,6 @@ services:
3433
context: .
3534
target: http_app
3635
depends_on:
37-
- dramatiq-worker
3836
- otel-collector
3937
env_file: local.env
4038
environment:

local.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ENVIRONMENT: "local"
12
AUTH__JWKS_URL: "http://oathkeeper:4456/.well-known/jwks.json"
2-
DRAMATIQ__REDIS_URL: "redis://redis:6379/0"
3+
#DRAMATIQ__REDIS_URL: "redis://redis:6379/0"
34
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"

src/common/dramatiq.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def init_dramatiq(config: AppConfig):
3737
else:
3838
broker = StubBroker()
3939
# broker.emit_after("process_boot")
40-
if config.ENVIRONMENT != "test":
41-
logging.critical("Running a non-test environment without Redis URL set")
40+
if config.ENVIRONMENT not in ["test", "local"]:
41+
logging.critical(
42+
"Running a non-test/non-local environment without Redis URL set",
43+
extra={"ENVIRONMENT": config.ENVIRONMENT},
44+
)
4245
broker.add_middleware(AsyncIO())
4346
set_broker(broker)
4447
set_encoder(ORJSONEncoder())

tests/common/test_dramatiq.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ def test_init_dramatiq_without_redis_url(caplog):
7070
with caplog.at_level(logging.CRITICAL):
7171
init_dramatiq(config)
7272

73-
assert "Running a non-test environment without Redis URL set" in caplog.text
73+
assert (
74+
"Running a non-test/non-local environment without Redis URL set" in caplog.text
75+
)

0 commit comments

Comments
 (0)