Documentation
¶
Overview ¶
Package checkjobs provides read-only HTTP access to the check_jobs schedule table and aggregate stats over both the background jobs queue and the check schedule. It is admin-only and never exposes encrypted secret values.
Index ¶
- Variables
- type CheckJobStats
- type CheckJobView
- type DerivedState
- type Handler
- func (h *Handler) GetCheckJob(writer http.ResponseWriter, req *http.Request) error
- func (h *Handler) GetSystemCheckJob(writer http.ResponseWriter, req *http.Request) error
- func (h *Handler) ListCheckJobs(writer http.ResponseWriter, req *http.Request) error
- func (h *Handler) ListSystemCheckJobs(writer http.ResponseWriter, req *http.Request) error
- func (h *Handler) Stats(writer http.ResponseWriter, req *http.Request) error
- func (h *Handler) SystemStats(writer http.ResponseWriter, req *http.Request) error
- type JobStats
- type ListOptions
- type Service
- type Stats
Constants ¶
This section is empty.
Variables ¶
var ErrCheckJobNotFound = errors.New("check job not found")
ErrCheckJobNotFound is returned when a check job cannot be found.
Functions ¶
This section is empty.
Types ¶
type CheckJobStats ¶
type CheckJobStats struct {
Total int `json:"total"`
DueNow int `json:"dueNow"`
InFlight int `json:"inFlight"`
Stalled int `json:"stalled"`
CrashLooping int `json:"crashLooping"`
}
CheckJobStats holds check-schedule counts.
type CheckJobView ¶
type CheckJobView struct {
UID string `json:"uid"`
OrganizationUID string `json:"organizationUid"`
CheckUID string `json:"checkUid"`
CheckName *string `json:"checkName"`
Region *string `json:"region"`
Type string `json:"type"`
Config models.JSONMap `json:"config"`
EncryptedKeys []string `json:"encryptedKeys"`
Encrypted bool `json:"encrypted"`
PeriodSeconds int64 `json:"periodSeconds"`
ScheduledAt *time.Time `json:"scheduledAt"`
LeaseWorkerUID *string `json:"leaseWorkerUid"`
LeaseExpiresAt *time.Time `json:"leaseExpiresAt"`
LeaseStarts int `json:"leaseStarts"`
UpdatedAt time.Time `json:"updatedAt"`
State DerivedState `json:"state"`
}
CheckJobView is the redacted, API-facing representation of a check_jobs row. It deliberately omits config_private / config_private_keys values and only exposes the *names* of encrypted keys.
type DerivedState ¶
type DerivedState string
DerivedState describes the lease-derived health of a check job.
const ( // StateIdle means the row has no active lease. StateIdle DerivedState = "idle" // StateInFlight means the row is leased and the lease has not expired. StateInFlight DerivedState = "inFlight" // StateStalled means the row is leased but the lease has expired. StateStalled DerivedState = "stalled" // StateCrashLooping means the row has been claimed too many times. StateCrashLooping DerivedState = "crashLooping" )
type Handler ¶
type Handler struct {
base.HandlerBase
// contains filtered or unexported fields
}
Handler exposes read-only check-job and stats endpoints.
func NewHandler ¶
NewHandler creates a new check-jobs handler.
func (*Handler) GetCheckJob ¶
GetCheckJob returns a single check job (org-scoped). GET /api/v1/orgs/:org/check-jobs/:uid.
func (*Handler) GetSystemCheckJob ¶
GetSystemCheckJob returns a single check job across all orgs (super-admin). GET /api/v1/system/check-jobs/:uid.
func (*Handler) ListCheckJobs ¶
ListCheckJobs lists check jobs for the org (org-scoped). GET /api/v1/orgs/:org/check-jobs.
func (*Handler) ListSystemCheckJobs ¶
ListSystemCheckJobs lists check jobs across all orgs (super-admin). GET /api/v1/system/check-jobs.
func (*Handler) Stats ¶
Stats returns aggregate counts for the org (org-scoped). GET /api/v1/orgs/:org/jobs/stats.
func (*Handler) SystemStats ¶
SystemStats returns aggregate counts across all orgs (super-admin). GET /api/v1/system/jobs/stats.
type JobStats ¶
type JobStats struct {
Pending int `json:"pending"`
Running int `json:"running"`
Failed24h int `json:"failed24h"`
}
JobStats holds background-jobs queue counts.
type ListOptions ¶
ListOptions holds pagination options for listing check jobs.
type Service ¶
type Service interface {
// ListCheckJobs lists check jobs. When orgUID is empty, all orgs are
// returned (system / super-admin mode).
ListCheckJobs(ctx context.Context, orgUID string, opts ListOptions) ([]*CheckJobView, error)
// GetCheckJob returns a single check job. When orgUID is non-empty, the
// row must belong to that org or ErrCheckJobNotFound is returned.
GetCheckJob(ctx context.Context, orgUID, uid string) (*CheckJobView, error)
// Stats computes aggregate counts for the overview strip. When orgUID is
// empty, counts span all orgs.
Stats(ctx context.Context, orgUID string) (*Stats, error)
}
Service provides read-only check-job queries.
func NewService ¶
NewService creates a new check-jobs read service.
type Stats ¶
type Stats struct {
Jobs JobStats `json:"jobs"`
Checks CheckJobStats `json:"checks"`
}
Stats holds aggregate counts over background jobs and the check schedule.