package outpost import "time" // Hooks observes relay activity. Every field is optional. // // Hook functions are called concurrently, from up to WithWorkers delivery // goroutines at a time, so implementations must be safe for concurrent use. type Hooks struct { // OnRetry reports a failure the relay will retry at retryAt: the time the // relay will next allow delivery, and the same value it records in the // store. It is the only backend-neutral way to observe the schedule. OnRetry func(info Info, cause error, retryAt time.Time) // OnDeadLetter reports a failure the relay abandons, either because the // error was Permanent or because the attempts were exhausted. OnDeadLetter func(info Info, cause error) // OnError reports a store error. Stale claims are expected and are not // reported here. OnError func(err error) } func (h Hooks) retry(info Info, cause error, retryAt time.Time) { if h.OnRetry != nil { h.OnRetry(info, cause, retryAt) } } func (h Hooks) deadLetter(info Info, cause error) { if h.OnDeadLetter != nil { h.OnDeadLetter(info, cause) } } func (h Hooks) err(err error) { if h.OnError != nil { h.OnError(err) } }