Documentation
¶
Overview ¶
Package hooks implements the Hook dispatcher. It subscribes to the Event Bus and delivers events to registered external hooks via batched HTTP webhook OR per-event JSON-lines file — asynchronously.
Per-protocol delivery shape:
HTTP: events buffered into a per-hook batcher; flushed when the batch hits BatchMaxItems OR when the BatchFlushIntervalSec timer fires. Failed batches re-queue at the front for the next flush. The queue is bounded by BatchMaxQueueItems — older events drop on overflow.
File: each event appended as a single JSON line. No batching — log shippers (Filebeat / Vector / Promtail) tail one line at a time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHookTestUnsupported = errors.New("hooks: test delivery not supported for this hook type")
ErrHookTestUnsupported is returned when the hook type cannot receive a synthetic test delivery.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service subscribes to the event bus and dispatches events to registered hooks.
HTTP hooks share an http.Client and route through per-hook batchers. File hooks share a per-target write mutex map so concurrent deliveries to the same path serialise without interleaving partial JSON lines.
func (*Service) DeliverTestEvent ¶
DeliverTestEvent sends a single synthetic event to the hook using the same path as live delivery. For HTTP hooks the test event is enqueued into the batcher and shipped on the next flush — typically within a second when BatchFlushIntervalSec is 5 and the queue is otherwise empty (the test event triggers a size-1 batch only if BatchMaxItems=1).
To make tests visible quickly without forcing the operator to set BatchMaxItems=1, we explicitly signal the batcher right after enqueuing. The signal is a no-op when MaxItems hasn't been reached, so production behaviour is unaffected.