oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3import (
4 "context"
5 "time"
6
7 "amadan.net/oficina/equipo/internal/hostedctl"
8 "amadan.net/oficina/equipo/internal/isolatedjob/awsjob"
9)
10
11// alertTimeout bounds one alert's delivery. hostedctl.New delivers startup
12// alerts with a context that never ends, so the alerter sets its own limit.
13const alertTimeout = 10 * time.Second
14
15// snsAlerter delivers the controller's operator alerts to SNS.
16type snsAlerter struct {
17 pub awsjob.SNSPublisher
18}
19
20var _ hostedctl.Alerter = snsAlerter{}
21
22// Alert publishes a's kind and detail, giving up after alertTimeout.
23func (s snsAlerter) Alert(ctx context.Context, a hostedctl.Alert) error {
24 ctx, cancel := context.WithTimeout(ctx, alertTimeout)
25 defer cancel()
26 return s.pub.Publish(ctx, a.Kind, a.Detail)
27}
28