Skip to content

Commit a22c807

Browse files
author
Alan Christie
committed
feat: Faster handling of missing streams
1 parent 706037b commit a22c807

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/app.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ async def event_stream(
274274
await websocket.accept()
275275
_LOGGER.info("Accepted connection for %s", es_id)
276276

277-
_LOGGER.info(
277+
_LOGGER.debug(
278278
"Creating Consumer for %s (%s:%s@%s/%s)...",
279279
es_id,
280280
_AMPQ_USERNAME,
@@ -289,6 +289,14 @@ async def event_stream(
289289
vhost=_AMPQ_VHOST,
290290
load_balancer_mode=True,
291291
)
292+
if not await consumer.stream_exists(routing_key):
293+
msg: str = f"EventStream {uuid} cannot be found"
294+
_LOGGER.warning(msg)
295+
raise HTTPException(
296+
status_code=status.HTTP_404_NOT_FOUND,
297+
detail=msg,
298+
)
299+
292300
_LOGGER.info("Consuming %s...", es_id)
293301
await _consume(
294302
consumer=consumer,

0 commit comments

Comments
 (0)