Documentation
¶
Overview ¶
Package webhook delivers the events of a subscription as signed HTTP POSTs.
Delivery is at least once and in order, from one goroutine: while an event is being retried the later ones wait in the subscription's bounded queue, and what does not fit there is dropped by the hub. Receivers de-duplicate by the event id, which stays the same across retries.
Index ¶
Constants ¶
const ( HeaderEventID = "X-NPS-Event-Id" HeaderEventType = "X-NPS-Event-Type" HeaderTimestamp = "X-NPS-Timestamp" HeaderSignature = "X-NPS-Signature" )
The headers of a delivery.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
URL string
// Secret signs the deliveries; if empty they carry no signature.
Secret string
// Timeout bounds one attempt; zero or less means 5 seconds.
Timeout time.Duration
// Retries is how many times a failed attempt is repeated; zero or less
// means none.
Retries int
// Backoff is the wait before the first retry, doubling up to 30 seconds;
// zero or less means a second.
Backoff time.Duration
}
Config configures a Sender.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender delivers the events of one subscription.
func Start ¶
func Start(cfg Config, sub *event.Subscription) *Sender
Start begins delivering what sub receives. The Sender owns sub.
func (*Sender) Close ¶
func (s *Sender) Close()
Close stops at once: an attempt in flight is cancelled and queued events are discarded. Deliveries are not persisted, so they do not survive it.