Plugins Extend Nexus with 15 lifecycle hooks for audit, metrics, webhooks, and custom processing.
The plugin system lets you react to lifecycle events without modifying engine code. Each hook is a separate Go interface — implement only the events you care about.
type Extension interface {
Name () string
}
Hook When OnRequestReceivedRequest enters the pipeline OnRequestCompletedProvider returns a response OnRequestFailedRequest fails OnRequestCachedResponse served from cache
Hook When OnProviderFailedProvider call fails OnCircuitOpenedCircuit breaker opens OnFallbackTriggeredFallback provider used
Hook When OnGuardrailBlockedRequest blocked by guardrail OnGuardrailRedactedContent redacted by guardrail
Hook When OnTenantCreatedNew tenant created OnTenantDisabledTenant disabled OnKeyCreatedAPI key created OnKeyRevokedAPI key revoked
Hook When OnBudgetWarning80% budget threshold OnBudgetExceededBudget exceeded
gw := nexus. New (
nexus. WithExtension (audithook. New (recorder)),
nexus. WithExtension (observability. NewMetricsExtension ()),
nexus. WithExtension (relayhook. NewWebhook ( "https://hooks.example.com/nexus" )),
)
audit_hook — Records lifecycle events for audit trails (Chronicle integration)
observability — Increments atomic counters for operational metrics
relay_hook — Forwards events as webhooks to external systems