Skip to content

Commit d2e1e20

Browse files
authored
Use shared notification event helpers (#72)
* Use shared notification event helpers * Update UsEquityStrategies dependency
1 parent d0bd996 commit d2e1e20

2 files changed

Lines changed: 15 additions & 46 deletions

File tree

notifications/events.py

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,13 @@
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+
]

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
flask
22
gunicorn
3-
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@663e80be60b0da80e81513b711c579d221a2111d
4-
us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@3c8262d1df7d11e47e5ffbff83784544d10f4b9b
3+
quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@9c4ea7878a08fb2f518c74c99bda68d8ef8fd0bb
4+
us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@ce7887482eeab7f519484610ee8b20cb7bc886a0
55
pandas
66
numpy
77
requests

0 commit comments

Comments
 (0)