Migrate to checker-sdk-go v1.3.0 with standalone build tag
The SDK split the HTTP server scaffolding into the new checker-sdk-go/checker/server subpackage. Update main.go to import server and call server.New, and isolate the interactive form code behind the standalone build tag so plugin/builtin builds skip net/http entirely.
This commit is contained in:
parent
a74c8d83aa
commit
b1ebac2198
10 changed files with 23 additions and 24 deletions
|
|
@ -38,7 +38,7 @@ import (
|
|||
var Version = "built-in"
|
||||
|
||||
// Definition returns the CheckerDefinition for the ping checker.
|
||||
func Definition() *happydns.CheckerDefinition {
|
||||
func (p *pingProvider) Definition() *happydns.CheckerDefinition {
|
||||
return &happydns.CheckerDefinition{
|
||||
ID: "ping",
|
||||
Name: "Ping (ICMP)",
|
||||
|
|
@ -89,9 +89,7 @@ func Definition() *happydns.CheckerDefinition {
|
|||
},
|
||||
},
|
||||
},
|
||||
Rules: []happydns.CheckRule{
|
||||
Rule(),
|
||||
},
|
||||
Rules: Rules(),
|
||||
Interval: &happydns.CheckIntervalSpec{
|
||||
Min: 1 * time.Minute,
|
||||
Max: 1 * time.Hour,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//go:build standalone
|
||||
|
||||
package checker
|
||||
|
||||
import (
|
||||
|
|
@ -30,7 +32,7 @@ import (
|
|||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
// RenderForm implements sdk.CheckerInteractive. It exposes a minimal form
|
||||
// RenderForm implements server.Interactive. It exposes a minimal form
|
||||
// letting a human submit one or more ping targets (hostnames or IPs) along
|
||||
// with the usual threshold knobs.
|
||||
func (p *pingProvider) RenderForm() []sdk.CheckerOptionField {
|
||||
|
|
@ -76,8 +78,8 @@ func (p *pingProvider) RenderForm() []sdk.CheckerOptionField {
|
|||
}
|
||||
}
|
||||
|
||||
// ParseForm implements sdk.CheckerInteractive. It converts the HTML form
|
||||
// inputs into a CheckerOptions that Collect can consume directly — pinging
|
||||
// ParseForm implements server.Interactive. It converts the HTML form
|
||||
// inputs into a CheckerOptions that Collect can consume directly, pinging
|
||||
// resolves hostnames on its own, so no extra lookups are needed here.
|
||||
func (p *pingProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) {
|
||||
raw := strings.TrimSpace(r.FormValue("addresses"))
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@ func (p *pingProvider) Key() happydns.ObservationKey {
|
|||
return ObservationKeyPing
|
||||
}
|
||||
|
||||
// Definition implements happydns.CheckerDefinitionProvider.
|
||||
func (p *pingProvider) Definition() *happydns.CheckerDefinition {
|
||||
return Definition()
|
||||
}
|
||||
|
||||
// ExtractMetrics implements happydns.CheckerMetricsReporter.
|
||||
func (p *pingProvider) ExtractMetrics(ctx happydns.ReportContext, collectedAt time.Time) ([]happydns.CheckMetric, error) {
|
||||
var data PingData
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue