|
1 | | -"""Notification event envelope and delivery helpers.""" |
2 | | - |
3 | | -from __future__ import annotations |
4 | | - |
5 | | -from collections.abc import Callable |
6 | | -from dataclasses import dataclass |
7 | | - |
8 | | - |
9 | | -@dataclass(frozen=True) |
10 | | -class RenderedNotification: |
11 | | - """Rendered notification payload split by sink.""" |
12 | | - |
13 | | - detailed_text: str |
14 | | - compact_text: str |
15 | | - |
16 | | - |
17 | | -@dataclass(frozen=True) |
18 | | -class NotificationPublisher: |
19 | | - """Publish rendered notifications to the configured sinks.""" |
20 | | - |
21 | | - log_message: Callable[[str], None] |
22 | | - send_message: Callable[[str], None] |
23 | | - |
24 | | - def publish(self, notification: RenderedNotification) -> None: |
25 | | - publish_rendered_notification( |
26 | | - notification, |
27 | | - log_message=self.log_message, |
28 | | - send_message=self.send_message, |
29 | | - ) |
30 | | - |
31 | | - |
32 | | -def publish_rendered_notification( |
33 | | - notification: RenderedNotification, |
34 | | - *, |
35 | | - log_message: Callable[[str], None], |
36 | | - send_message: Callable[[str], None], |
37 | | -) -> None: |
38 | | - """Write the detailed log copy and send the compact user notification.""" |
39 | | - detailed = str(notification.detailed_text or "").strip() |
40 | | - compact = str(notification.compact_text or "").strip() |
41 | | - if detailed: |
42 | | - log_message(detailed) |
43 | | - if compact: |
44 | | - send_message(compact) |
| 1 | +"""Compatibility exports for shared notification event helpers.""" |
| 2 | + |
| 3 | +from quant_platform_kit.notifications.events import ( |
| 4 | + NotificationPublisher, |
| 5 | + RenderedNotification, |
| 6 | + publish_rendered_notification, |
| 7 | +) |
| 8 | + |
| 9 | +__all__ = [ |
| 10 | + "NotificationPublisher", |
| 11 | + "RenderedNotification", |
| 12 | + "publish_rendered_notification", |
| 13 | +] |
0 commit comments