spec

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertMessage

type AlertMessage struct {
	CheckName      string      `json:"check_name"`
	Status         CheckStatus `json:"status"`
	PreviousStatus CheckStatus `json:"previous_status"`
	Timestamp      time.Time   `json:"timestamp"`
	Detail         string      `json:"detail,omitempty"`
}

type AlertsConfig

type AlertsConfig struct {
	Webhooks  []WebhookConfig   `yaml:"webhooks,omitempty"`
	SMTP      *SMTPConfig       `yaml:"smtp,omitempty"`
	Discord   []DiscordConfig   `yaml:"discord,omitempty"`
	Teams     []TeamsConfig     `yaml:"teams,omitempty"`
	PagerDuty []PagerDutyConfig `yaml:"pagerduty,omitempty"`
	SMS       []SMSConfig       `yaml:"sms,omitempty"`
}

type CheckResult

type CheckResult struct {
	CheckName string         `json:"check_name"`
	Status    CheckStatus    `json:"status"`
	Duration  time.Duration  `json:"duration"`
	Error     string         `json:"error,omitempty"`
	Detail    map[string]any `json:"detail,omitempty"`
	Timestamp time.Time      `json:"timestamp"`
}

type CheckSpec

type CheckSpec struct {
	Name               string            `yaml:"name" json:"name"`
	Type               CheckType         `yaml:"type" json:"type"`
	Target             string            `yaml:"target,omitempty" json:"target,omitempty"`
	Interval           Duration          `yaml:"interval" json:"interval"`
	Timeout            Duration          `yaml:"timeout" json:"timeout"`
	Headers            map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
	ExpectedStatus     int               `yaml:"expected_status,omitempty" json:"expected_status,omitempty"`
	MaxSilence         Duration          `yaml:"max_silence,omitempty" json:"max_silence,omitempty"`
	Alerts             []string          `yaml:"alerts,omitempty" json:"alerts,omitempty"`
	LatencyThresholdMs int               `yaml:"latency_threshold_ms,omitempty" json:"latency_threshold_ms,omitempty"`
	WarnDays           int               `yaml:"warn_days,omitempty" json:"warn_days,omitempty"`
	RecordType         string            `yaml:"record_type,omitempty" json:"record_type,omitempty"`
	LastCheckInAt      *time.Time        `yaml:"-" json:"-"`
	LastCheckInStatus  string            `yaml:"-" json:"-"`
}

type CheckStatus

type CheckStatus string
const (
	StatusUp       CheckStatus = "up"
	StatusDown     CheckStatus = "down"
	StatusDegraded CheckStatus = "degraded"
	StatusUnknown  CheckStatus = "unknown"
)

type CheckType

type CheckType string
const (
	CheckHTTP    CheckType = "http"
	CheckTCP     CheckType = "tcp"
	CheckTLS     CheckType = "tls"
	CheckDNS     CheckType = "dns"
	CheckCheckIn CheckType = "checkin"
)

type ClientConfig

type ClientConfig struct {
	ServerAddress string `yaml:"server_address"`
	KeyID         string `yaml:"key_id"`
}

type Config

type Config struct {
	Server ServerConfig `yaml:"server,omitempty"`
	Checks []CheckSpec  `yaml:"checks"`
	Alerts AlertsConfig `yaml:"alerts,omitempty"`
	Worker WorkerConfig `yaml:"worker,omitempty"`
}

type DiscordConfig

type DiscordConfig struct {
	Name       string `yaml:"name"`
	WebhookURL string `yaml:"webhook_url"`
}

type Duration

type Duration struct {
	time.Duration
}

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

type JobSource

type JobSource interface {
	Poll(ctx context.Context, worker WorkerInfo) ([]Lease, error)
	Ack(ctx context.Context, lease Lease, result CheckResult) error
	Nack(ctx context.Context, lease Lease, reason string) error
	Heartbeat(ctx context.Context, lease Lease) error
}

type Lease

type Lease struct {
	ID        string    `json:"id"`
	MonitorID string    `json:"monitor_id"`
	OrgID     string    `json:"org_id"`
	Check     CheckSpec `json:"check"`
	IssuedAt  time.Time `json:"issued_at"`
	ExpiresAt time.Time `json:"expires_at"`
	Token     string    `json:"token"`
}

type PagerDutyConfig

type PagerDutyConfig struct {
	Name           string `yaml:"name"`
	IntegrationKey string `yaml:"integration_key"`
}

type PublicKeyEntry

type PublicKeyEntry struct {
	KeyID     string `yaml:"key_id"`
	PublicKey string `yaml:"public_key"`
	Label     string `yaml:"label,omitempty"`
}

type SMSConfig

type SMSConfig struct {
	Name  string `yaml:"name"`
	Phone string `yaml:"phone"`
}

type SMTPConfig

type SMTPConfig struct {
	Host       string   `yaml:"host"`
	Port       int      `yaml:"port"`
	Username   string   `yaml:"username,omitempty"`
	Password   string   `yaml:"password,omitempty"`
	From       string   `yaml:"from"`
	Recipients []string `yaml:"recipients"`
	TLS        bool     `yaml:"tls"`
}

type ServerConfig

type ServerConfig struct {
	BindAddress     string           `yaml:"bind_address,omitempty"`
	BindPort        int              `yaml:"bind_port,omitempty"`
	ExternalAddress string           `yaml:"external_address,omitempty"`
	ExternalPort    int              `yaml:"external_port,omitempty"`
	Concurrency     int              `yaml:"concurrency,omitempty"`
	JoinToken       string           `yaml:"join_token,omitempty"`
	AuthorizedUsers []PublicKeyEntry `yaml:"authorized_users,omitempty"`
}

func (ServerConfig) ExternalURL

func (s ServerConfig) ExternalURL() string

type TeamsConfig

type TeamsConfig struct {
	Name       string `yaml:"name"`
	WebhookURL string `yaml:"webhook_url"`
}

type WebhookConfig

type WebhookConfig struct {
	Name    string            `yaml:"name"`
	URL     string            `yaml:"url"`
	Method  string            `yaml:"method,omitempty"`
	Headers map[string]string `yaml:"headers,omitempty"`
	Timeout Duration          `yaml:"timeout,omitempty"`
}

type WorkerConfig

type WorkerConfig struct {
	Concurrency  int      `yaml:"concurrency,omitempty"`
	PollInterval Duration `yaml:"poll_interval,omitempty"`
	APIEndpoint  string   `yaml:"api_endpoint,omitempty"`
	APIToken     string   `yaml:"api_token,omitempty"`
}

type WorkerInfo

type WorkerInfo struct {
	ID           string   `json:"id"`
	Version      string   `json:"version"`
	Capabilities []string `json:"capabilities"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL