Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.6 kB ยท 64 lines
Go
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465package server
import ( "errors" "fmt"
"connectrpc.com/connect" private_locationv1 "github.com/openstatushq/openstatus/apps/private-location/proto/private_location/v1")
// Validation errorsvar ( ErrEmptyMonitorID = errors.New("monitor_id is required") ErrEmptyID = errors.New("id is required") ErrInvalidLatency = errors.New("latency must be non-negative") ErrInvalidTimestamp = errors.New("timestamp must be positive"))
// ValidateIngestHTTPRequest validates an HTTP ingest requestfunc ValidateIngestHTTPRequest(req *private_locationv1.IngestHTTPRequest) error { if req.MonitorId == "" { return ErrEmptyMonitorID } if req.Latency < 0 { return ErrInvalidLatency } if req.Timestamp <= 0 { return ErrInvalidTimestamp } return nil}
// ValidateIngestTCPRequest validates a TCP ingest requestfunc ValidateIngestTCPRequest(req *private_locationv1.IngestTCPRequest) error { if req.MonitorId == "" { return ErrEmptyMonitorID } if req.Latency < 0 { return ErrInvalidLatency } if req.Timestamp <= 0 { return ErrInvalidTimestamp } return nil}
// ValidateIngestDNSRequest validates a DNS ingest requestfunc ValidateIngestDNSRequest(req *private_locationv1.IngestDNSRequest) error { if req.MonitorId == "" { return ErrEmptyMonitorID } if req.Latency < 0 { return ErrInvalidLatency } if req.Timestamp <= 0 { return ErrInvalidTimestamp } return nil}
// NewValidationError creates a Connect error for validation failuresfunc NewValidationError(err error) *connect.Error { return connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("validation error: %w", err))}