HTTP Check-In Example
To make a check-in with Deadcheck using an HTTP request, follow this example:
Step 1: Create a Check
Checks are created in YAML and loaded when Deadcheck starts. The following is an example of a check configuration:
checks:
- id: "5pm-checkin"
name: "Reports Finalized"
schedule:
weekdays:
timezone: "America/New_York"
times: ["17:00"]
tolerance: "5m"
Step 2: Check-In
Once your check is created, you can confirm the check-in using this HTTP call:
curl -X PUT http://localhost:8080/checks/5pm-checkin/check-in
Check-In Using Go SDK
You can also use the Go SDK to interact with Deadcheck:
Step 1: Install the SDK
go get github.com/adamdecaf/deadcheck
Step 2: Example Go Code
package main
import (
"context"
"log"
"time"
"github.com/adamdecaf/deadcheck/pkg/deadcheck"
)
func main() {
client, err := deadcheck.NewClient(deadcheck.Config{
BaseAddress: "http://localhost:8080",
})
if err != nil {
log.Fatalf("creating deadcheck client: %v", err)
}
ctx := context.Background()
response, err := client.CheckIn(ctx, "5pm-checkin")
if err != nil {
log.Fatalf("Error checking in: %v", err)
} else {
log.Printf("Successfully checked in, next check-in expected by %v", response.NextExpectedCheckIn.Format(time.RFC3339))
}
}