Debian Codegraph @

pkg/router/doc.go

raw
1 // Package router provides service routing functionality for shoutrrr notifications.
2 //
3 // The router package is responsible for routing notification messages to specific
4 // notification services based on service URLs. It manages the lifecycle of service
5 // instances, handles URL parsing, and provides both synchronous and asynchronous
6 // message delivery.
7 //
8 // # Main Components
9 //
10 // ServiceRouter (router.go)
11 //
12 // The primary type that manages notification services and routes messages.
13 // ServiceRouter provides methods for:
14 // - Initializing services from URLs
15 // - Sending messages synchronously and asynchronously
16 // - Managing service lifecycles
17 // - Queueing and flushing batched messages
18 //
19 // Service Factory (servicemap.go)
20 //
21 // Maps service schemes to their factory functions, enabling dynamic service
22 // instantiation. Supports over 20 notification services including:
23 // - Chat: Discord, Slack, Telegram, Matrix, Mattermost, Teams, etc.
24 // - Email: SMTP
25 // - Push: Gotify, Pushover, Pushbullet, ntfy, etc.
26 // - SMS: Twilio
27 // - Incident: PagerDuty, OpsGenie
28 //
29 // Basic usage:
30 //
31 // router, err := router.New(logger, "slack://webhook/...", "discord://webhook/...")
32 // if err != nil {
33 // // handle error
34 // }
35 //
36 // errors := router.Send("Hello, World!", nil)
37 //
38 // For more control, use individual methods:
39 //
40 // service, err := router.Locate("slack://webhook/...")
41 // if err != nil {
42 // // handle error
43 // }
44 //
45 // err := service.Send("Hello, World!", nil)
46 package router