31 lines
929 B
Go
31 lines
929 B
Go
// SPDX-License-Identifier: MIT
|
|
|
|
package checker
|
|
|
|
import (
|
|
"context"
|
|
|
|
sdk "git.happydns.org/checker-sdk-go/checker"
|
|
)
|
|
|
|
// CollectFn is the function signature for the DNSViz data collection step.
|
|
// The checker package is decoupled from the subprocess invocation so it can
|
|
// be imported without GPL obligations. Implementations live in the binary or
|
|
// plugin layer (see internal/collect).
|
|
type CollectFn func(ctx context.Context, opts sdk.CheckerOptions) (any, error)
|
|
|
|
// Provider returns a new DNSViz observation provider backed by the given
|
|
// collect function.
|
|
func Provider(collect CollectFn) sdk.ObservationProvider {
|
|
return &dnsvizProvider{collect: collect}
|
|
}
|
|
|
|
type dnsvizProvider struct{ collect CollectFn }
|
|
|
|
func (p *dnsvizProvider) Key() sdk.ObservationKey {
|
|
return ObservationKeyDNSViz
|
|
}
|
|
|
|
func (p *dnsvizProvider) Collect(ctx context.Context, opts sdk.CheckerOptions) (any, error) {
|
|
return p.collect(ctx, opts)
|
|
}
|