Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
m5l14i11 committed Sep 19, 2024
1 parent 25e7234 commit 672fe9d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions infrastructure/event_dispatcher/event_dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from typing import Any, Callable, Optional, Type
from typing import Any, Callable, Optional, Type, Union

from core.commands.base import Command
from core.events.base import Event, EventEnded
Expand Down Expand Up @@ -87,12 +87,18 @@ async def stop(self) -> None:
self._store.close()

async def _dispatch_to_poll(
self, event: Type[Event], worker_pool: WorkerPool, *args, **kwargs
self,
event: Union[Event, Command, Query],
worker_pool: WorkerPool,
*args,
**kwargs,
) -> None:
if isinstance(event, EventEnded):
self._cancel_event.set()
else:
elif isinstance(event, (Command, Query, Event)):
await worker_pool.dispatch_to_worker(event, *args, **kwargs)
else:
raise ValueError(f"Invalid event type: {type(event)}")

def _create_worker_pool(self) -> WorkerPool:
return WorkerPool(
Expand Down

0 comments on commit 672fe9d

Please sign in to comment.