Coverage for kwai/core/events/bus.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-09-05 17:55 +0000

1"""Module that defines the interface for a bus.""" 

2from abc import abstractmethod 

3from typing import Any 

4 

5from kwai.core.events.event import Event 

6 

7 

8class Bus: 

9 """Interface for a message bus.""" 

10 

11 @abstractmethod 

12 async def publish(self, event: Event): 

13 """Publish an event.""" 

14 raise NotImplementedError 

15 

16 @abstractmethod 

17 def subscribe(self, event: type[Event], task: Any): 

18 """Subscribe on an event.""" 

19 raise NotImplementedError