checker: add DiscoveryPublisher interface for cross-checker discovery
Introduce a DiscoveryEntry struct and an optional DiscoveryPublisher interface that providers can co-implement to declare things worth probing by other checkers (TLS endpoints, HTTP probes, ACME challenges, DNSSEC keys, ...) without having to re-parse raw observations. DiscoveryEntry carries an opaque Payload: the SDK does not interpret it. Producers and consumers agree on the Payload schema through a separate contract (eg. a small shared Go package imported by both) identified by the free-form Type string. This keeps the SDK free of protocol-specific concepts; new entry families can appear without touching it. The /collect HTTP handler type-asserts the provider against DiscoveryPublisher immediately after Collect and forwards the resulting entries in ExternalCollectResponse.Entries.
This commit is contained in:
parent
6b96ee8c2f
commit
087032f6cc
2 changed files with 67 additions and 5 deletions
|
|
@ -256,9 +256,21 @@ func (s *Server) handleCollect(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, ExternalCollectResponse{
|
||||
Data: json.RawMessage(raw),
|
||||
})
|
||||
resp := ExternalCollectResponse{Data: json.RawMessage(raw)}
|
||||
|
||||
// Harvest discovery entries from the native Go value, before it goes
|
||||
// out of scope. No re-parse; DiscoverEntries operates on the same
|
||||
// object that was just marshaled above.
|
||||
if dp, ok := s.provider.(DiscoveryPublisher); ok {
|
||||
entries, derr := dp.DiscoverEntries(data)
|
||||
if derr != nil {
|
||||
log.Printf("DiscoverEntries failed: %v", derr)
|
||||
} else {
|
||||
resp.Entries = entries
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func (s *Server) handleEvaluate(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue