-
-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathobserver.py
More file actions
35 lines (26 loc) · 1.02 KB
/
observer.py
File metadata and controls
35 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from typing import Protocol, runtime_checkable
@runtime_checkable
class ReceiverObserver(Protocol):
"""
Observer for receiver stats.
This class is used to observe/collect metrics for the receiver.
This includes semaphore usage, tasks in queue, etc.
metrics tracked:
- Number of tasks in queue
- Number of tasks in execution (semaphore usage)
"""
def on_prefetch_queue_size(self, size: int) -> None:
"""Called when the prefetch queue size changes."""
...
def on_semaphore_status(self, available: int) -> None:
"""Called when semaphore availability changes."""
...
def on_active_tasks_count(self, count: int) -> None:
"""Called when the number of active tasks changes."""
...
def on_task_not_found(self, task_name: str) -> None:
"""Called when a received task is not registered."""
...
def on_deserialize_error(self, raw: bytes, error: Exception) -> None:
"""Called when a message fails to deserialize."""
...