package main import ( "context" "time" "amadan.net/oficina/equipo/internal/hostedctl" "amadan.net/oficina/equipo/internal/isolatedjob/awsjob" ) // alertTimeout bounds one alert's delivery. hostedctl.New delivers startup // alerts with a context that never ends, so the alerter sets its own limit. const alertTimeout = 10 * time.Second // snsAlerter delivers the controller's operator alerts to SNS. type snsAlerter struct { pub awsjob.SNSPublisher } var _ hostedctl.Alerter = snsAlerter{} // Alert publishes a's kind and detail, giving up after alertTimeout. func (s snsAlerter) Alert(ctx context.Context, a hostedctl.Alert) error { ctx, cancel := context.WithTimeout(ctx, alertTimeout) defer cancel() return s.pub.Publish(ctx, a.Kind, a.Detail) }