Documentation
¶
Overview ¶
Package webhook provides the audit-event webhook dispatcher for the registry server. It owns the Store type, which holds the outbound HTTP dispatcher (with DLQ and retry), and exposes the three wire handler methods that the registry dispatch table calls via thin Server wrappers.
Fan-out from the event bus is wired by calling Store.Subscribe(bus) after construction; the store listens for "audit.entry" events and calls Emit on each one so callers no longer need to touch the store directly at mutation sites.
Index ¶
- Constants
- type Event
- type Store
- func (st *Store) Close()
- func (st *Store) Emit(action string, details map[string]interface{})
- func (st *Store) HandleGetWebhook() map[string]interface{}
- func (st *Store) HandleGetWebhookDLQ() map[string]interface{}
- func (st *Store) HandleSetWebhook(urlStr string) map[string]interface{}
- func (st *Store) SetInitialBackoff(d time.Duration)
- func (st *Store) SetURL(url string)
- func (st *Store) Subscribe(bus events.Bus)
Constants ¶
const ( MaxRetries = 3 InitialBackoff = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
EventID uint64 `json:"event_id"`
Action string `json:"action"`
Timestamp time.Time `json:"timestamp"`
Details map[string]interface{} `json:"details,omitempty"`
}
Event is the JSON payload POSTed to webhook endpoints.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds the webhook configuration and dispatcher for the audit-event webhook. A nil *Store is valid and behaves as "no webhook configured".
Typical lifecycle:
st := webhook.NewStore()
st.Subscribe(bus) // hook into the event bus for automatic fan-out
st.SetURL("https://...") // configure the endpoint (or leave empty)
...
st.Close() // on server shutdown
func NewStore ¶
func NewStore() *Store
NewStore returns an initialised *Store with no webhook URL configured.
func (*Store) Close ¶
func (st *Store) Close()
Close drains the current dispatcher and releases resources.
func (*Store) HandleGetWebhook ¶
HandleGetWebhook requires admin-token verification by the caller.
func (*Store) HandleGetWebhookDLQ ¶
HandleGetWebhookDLQ requires admin-token verification by the caller.
func (*Store) HandleSetWebhook ¶
HandleSetWebhook requires admin-token verification by the caller. Empty urlStr disables the webhook.
func (*Store) SetInitialBackoff ¶
SetInitialBackoff sets the retry backoff. Tests set a short value to avoid waiting on retry exhaustion. No-op when no dispatcher is active.