mirror of
https://github.com/caddyserver/caddy.git
synced 2026-10-31 16:32:45 -04:00
CertMagic assembles an event's data before emit() can look at OnEvent, because Go evaluates arguments first, so tls_get_certificate costs a map and a ClientHello copy on every handshake even when nothing will read them. caddyserver/certmagic#406 added Config.ShouldEmitFunc so an embedder can answer that question first. Export App.ShouldEmit and pass it along with OnEvent. The predicate has to account for every observer, not just subscribed handlers: Emit writes a debug line for each event, so an event is observable whenever debug logging is on. Emit now asks the same method it exports, so the two cannot drift. Benchmarks are included; measurements are in the pull request.