Design a notification service
medium 85 minDesign the classes that tell people things by push, text message and email: routes from personal wishes, quiet hours, retries, fallback to another channel, and protection against repeats.
Watch lesson4:50
Where it shows up
The same pattern appears across everyday software.
Laravel notifications
A notification class has a `via` method that names the channels for this person, and one method for each channel that builds the message. Delays can differ by channel.
Symfony Notifier
The setting `channel_policy` maps an importance to channels: urgent to text message, chat and email, low to the browser. Transports can be combined with `||` for failover between vendors.
Prometheus Alertmanager
Grouping merges alerts of one nature into one message, inhibition keeps alerts quiet when a bigger one fires, silences mute for a time. Digest, replacement and quiet hours under other names.
Firebase Cloud Messaging
A `collapse_key` lets a new message replace a waiting one. At most four keys are kept for one device. The guide asks senders for exponential backoff with jitter.
Apple push notifications
Request headers carry a priority, an expiration and `apns-collapse-id`, so that several notifications are shown as one. The promise of a key, kept on the device.
Web Push, RFC 8030
A message has a time to live, an urgency, and a topic. A message with a topic replaces an outstanding one with the same topic.
Amazon SNS delivery retries
A policy in four phases: at once, before backoff, backoff, after backoff. Other numbers for managed endpoints than for HTTP, and jitter included. For HTTP the total is limited to 3,600 seconds.
Android notification channels
Since Android 8.0 an app must put every notification in a channel, and the person decides for each channel how intrusive it is. Wishes by kind, kept by the operating system.
Apprise
A Python library that reaches a long list of services through one `notify` call. A service is an address in the form of a URL, and tags choose who is told.