Documentation
¶
Overview ¶
Package notify provides durable, rule-filtered owner notifications. Channel secrets never appear in API responses, delivery logs, or transport errors.
Index ¶
- Constants
- Variables
- func RunMonitor(input io.Reader) error
- type Channel
- type Event
- type EventInfo
- type Heartbeat
- type Options
- type PushKeys
- type PushSubscription
- type Service
- func (s *Service) BackupFailed(ctx context.Context, err error) error
- func (s *Service) Channels(ctx context.Context) ([]Channel, error)
- func (s *Service) Drain(ctx context.Context) error
- func (s *Service) Emit(ctx context.Context, e Event) error
- func (s *Service) EmitOnce(ctx context.Context, key string, e Event) (bool, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) Heartbeat(ctx context.Context) error
- func (s *Service) HeartbeatSettings(ctx context.Context, redact bool) (Heartbeat, error)
- func (s *Service) MigrateSecrets(ctx context.Context) (int, error)
- func (s *Service) ObserveIndexer(e newznab.Event)
- func (s *Service) ObservePlayback(ev playback.Event)
- func (s *Service) Run(ctx context.Context)
- func (s *Service) SampleHealth(ctx context.Context) error
- func (s *Service) Save(ctx context.Context, c Channel) error
- func (s *Service) SaveHeartbeat(ctx context.Context, h Heartbeat) error
- func (s *Service) TitleAvailable(ctx context.Context, title string) error
- func (s *Service) TitleAvailableOnce(ctx context.Context, key, title string) error
- func (s *Service) UpdateAvailable(ctx context.Context, current, version string) error
- func (s *Service) WatchProcess(executable string) (func(bool) error, error)
Constants ¶
const Redacted = "[configured]"
Variables ¶
var Kinds = []string{"server.started", "server.stopping", "server.crash", "provider.recovered", "indexer.recovered", "cache.recovered", "playback.start", "playback.stop", "playback.error", "playback.failover", "provider.outage", "indexer.outage", "indexer.budget", "cache.full", "cert.renewed", "update.available", "backup.failed", "user.joined", "title.available", "newsletter.weekly", "test"}
Functions ¶
func RunMonitor ¶ added in v0.2.4
RunMonitor is used only by the executable's notification-monitor entry point. A killed host, network outage, or supervisor killing the whole process group also stops this watcher. An external uptime monitor is required for those.
Types ¶
type Channel ¶
type Channel struct {
SMTPMode string `json:"smtpMode,omitempty"`
Subscription *PushSubscription `json:"subscription,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Enabled bool `json:"enabled"`
Events []string `json:"events"`
Endpoint string `json:"endpoint"`
Token string `json:"token"`
Target string `json:"target"`
Username string `json:"username"`
Password string `json:"password"`
From string `json:"from"`
To string `json:"to"`
PerMinute int `json:"perMinute"`
DigestMinutes int `json:"digestMinutes"`
}
type EventInfo ¶ added in v0.2.4
type EventInfo struct {
Kind string `json:"kind"`
Description string `json:"description"`
Automatic bool `json:"automatic"`
}
EventInfo distinguishes automatic producers from owner API integrations. Existing event identifiers remain accepted for compatibility.
type Options ¶
type Options struct {
// NodeID names this node on the queue rows it claims; a random id is
// used when empty.
NodeID string
Providers func() []usenet.ProviderStats
CacheUsage func() (int64, int64)
Client *http.Client
Now func() time.Time
Logger *slog.Logger
// Sealer protects stored channel secrets and the push identity
// (secrets.go); nil stores them as given.
Sealer config.FieldSealer
}
type PushSubscription ¶ added in v0.2.4
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) BackupFailed ¶ added in v0.2.48
BackupFailed reports a scheduled backup that did not complete.
func (*Service) EmitOnce ¶ added in v0.2.48
EmitOnce emits e unless an event was already emitted under key, and reports whether it emitted. The key and the queued deliveries commit in one transaction: a crash or a failed enqueue leaves neither, so a later attempt emits it.
func (*Service) Heartbeat ¶ added in v0.2.4
Heartbeat is called only after a successful local HTTP probe. The remote monitor must alert when these one-minute pings stop (allow a three-minute grace).
func (*Service) HeartbeatSettings ¶ added in v0.2.4
func (*Service) MigrateSecrets ¶ added in v0.2.4
MigrateSecrets seals channel secrets and the push identity stored in plaintext and returns how many rows it rewrote. A row is replaced only if it is unchanged since read, so it is safe to rerun on any node; a row that does not open is left untouched and reported in the error.
func (*Service) ObserveIndexer ¶
ObserveIndexer alerts once per outage, retrying failed queue writes at most once a minute. Database waits never hold the shared health mutex.
func (*Service) ObservePlayback ¶
ObservePlayback only enqueues; network delivery runs separately in Run.
func (*Service) Run ¶
Run is the single queue consumer. Failed sends are recorded without automatic retry, avoiding duplicate delivery when an upstream timeout is ambiguous.
func (*Service) SampleHealth ¶
SampleHealth emits one alert on entering an unhealthy state, rather than one alert for every sample. Normal recovery allows a later outage to alert again.
func (*Service) SaveHeartbeat ¶ added in v0.2.4
func (*Service) TitleAvailable ¶
TitleAvailable lets the discovery/watchlist flow publish availability.
func (*Service) TitleAvailableOnce ¶ added in v0.2.48
TitleAvailableOnce publishes availability once per key (an episode, say), however often a caller retries after a failure or crash.
func (*Service) UpdateAvailable ¶ added in v0.2.48
UpdateAvailable announces a release once per version.
func (*Service) WatchProcess ¶ added in v0.2.4
WatchProcess starts a small independent delivery process. The returned function must be called on normal exit, with clean=false for a fatal run error. A panic must be allowed to terminate the parent so that EOF reaches the watcher.