Notification Router¶
Routes notifications to the appropriate notifier based on configuration.
Notification routing handler.
Provides the main Lambda handler for routing notifications to appropriate delivery channels.
NotificationRouter
dataclass
¶
NotificationRouter(notifiers=list())
Bases: LambdaHandler[NotificationRequest, NotificationResponse]
Handler for routing notifications to appropriate delivery channels.
Routes notifications to different notifiers (SES, SNS, etc.) based on the target specification using a chain-of-responsibility pattern.
Each notifier attempts to parse and handle the target. If successful, it delivers the notification. If not, the next notifier is tried.
Attributes:
| Name | Type | Description |
|---|---|---|
notifiers |
List[Notifier]
|
List of notifier instances to try in order. |
Example
handler = NotificationRouter.get_handler()
# Or with custom notifiers
handler = NotificationRouter(notifiers=[SESNotifier()]).get_handler()
handle ¶
handle(request)
Route and deliver notifications to targets.
Attempts to deliver the notification content to each target using the available notifiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
NotificationRequest
|
Request containing content and target specifications. |
required |
Returns:
| Type | Description |
|---|---|
NotificationResponse
|
Response containing results for each target. |
Source code in src/aibs_informatics_aws_lambda/handlers/notifications/router.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |