server

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: BSD-2-Clause Imports: 27 Imported by: 0

Documentation

Overview

Package server implements the Gonemaster HTTP API, in-memory queue/store backends, worker orchestration, and runtime metrics endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecoverJobs added in v1.0.1

func RecoverJobs(store JobStore, queue Queue) error

RecoverJobs is called at startup to handle an unclean previous shutdown. Jobs left in "running" state are transitioned to "failed". Jobs still "queued" are re-enqueued so workers can pick them up.

For in-memory stores this is a no-op because data does not survive restarts.

Types

type BatchSummary

type BatchSummary struct {
	BatchID      string         `json:"batch_id"`
	Total        int            `json:"total"`
	StatusCounts map[string]int `json:"status_counts"`
	Items        []Job          `json:"items"`
	Limit        int            `json:"limit,omitempty"`
	Offset       int            `json:"offset,omitempty"`
	NextCursor   string         `json:"next_cursor,omitempty"`
	PrevCursor   string         `json:"prev_cursor,omitempty"`
	Sort         string         `json:"sort,omitempty"`
	CreatedAt    time.Time      `json:"created_at"`
	StartedAt    *time.Time     `json:"started_at,omitempty"`
	FinishedAt   *time.Time     `json:"finished_at,omitempty"`
}

BatchSummary aggregates jobs for a batch.

type Config

type Config struct {
	ListenAddr  string
	MaxBodySize int64
	Debug       bool
	WorkerCount int
	// MaxConcurrentJobs caps engine runs across workers when >0.
	MaxConcurrentJobs int
	// PositiveCacheTTL overrides resolver.defaults.positive_cache_ttl when set.
	PositiveCacheTTL *int
	// NegativeCacheTTL overrides resolver.defaults.negative_cache_ttl when set.
	NegativeCacheTTL *int
	// Timeout overrides resolver.defaults.timeout when set (seconds).
	Timeout *int
	// Retry overrides resolver.defaults.retry when set.
	Retry *int
	// Retrans overrides resolver.defaults.retrans when set (seconds).
	Retrans *int
	// Fallback overrides resolver.defaults.fallback when set.
	Fallback *bool
	// SourceAddr4 overrides resolver.source4 when set.
	SourceAddr4 *string
	// SourceAddr6 overrides resolver.source6 when set.
	SourceAddr6 *string
	MinLevel    string
	ProfilePath string
	Database    DatabaseConfig
}

Config controls HTTP server behavior.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns baseline config values.

func (*Config) ApplyFileConfig

func (c *Config) ApplyFileConfig(file FileConfig)

ApplyFileConfig overwrites config fields when provided by file.

type DatabaseConfig added in v1.0.1

type DatabaseConfig struct {
	// Driver selects the storage backend: "memory" (default), "sqlite",
	// "postgres", or "mariadb".
	Driver string
	// DSN is the data source name. For sqlite this is a file path.
	// For postgres/mariadb this is a connection string. Empty for memory.
	DSN string
}

DatabaseConfig controls the persistence backend.

type DatabaseFileConfig added in v1.0.1

type DatabaseFileConfig struct {
	Driver string `json:"driver,omitempty"`
	DSN    string `json:"dsn,omitempty"`
}

DatabaseFileConfig holds optional database configuration from JSON. An empty string for Driver or DSN means "not set" (inherit from default).

type ErrorBody

type ErrorBody struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

ErrorBody contains error details.

type ErrorResponse

type ErrorResponse struct {
	Error ErrorBody `json:"error"`
}

ErrorResponse is the standard error response body.

type FileConfig

type FileConfig struct {
	ListenAddr        *string             `json:"listen_addr"`
	MaxBodySize       *int64              `json:"max_body_size"`
	Debug             *bool               `json:"debug"`
	WorkerCount       *int                `json:"worker_count"`
	MaxConcurrentJobs *int                `json:"max_concurrent_jobs"`
	PositiveCacheTTL  *int                `json:"positive_cache_ttl"`
	NegativeCacheTTL  *int                `json:"negative_cache_ttl"`
	Timeout           *int                `json:"timeout"`
	Retry             *int                `json:"retry"`
	Retrans           *int                `json:"retrans"`
	Fallback          *bool               `json:"fallback"`
	SourceAddr4       *string             `json:"source_addr4"`
	SourceAddr6       *string             `json:"source_addr6"`
	MinLevel          *string             `json:"min_level"`
	ProfilePath       *string             `json:"profile_path"`
	Database          *DatabaseFileConfig `json:"database,omitempty"`
}

FileConfig captures optional configuration fields from JSON.

func LoadFileConfig

func LoadFileConfig(path string) (FileConfig, error)

LoadFileConfig loads configuration overrides from a JSON file.

type InMemoryJobStore

type InMemoryJobStore struct {
	// contains filtered or unexported fields
}

InMemoryJobStore stores jobs in memory.

func NewInMemoryJobStore

func NewInMemoryJobStore() *InMemoryJobStore

NewInMemoryJobStore creates an empty in-memory job store.

func (*InMemoryJobStore) Create

func (s *InMemoryJobStore) Create(job Job) (Job, error)

Create inserts a new job and fails if the id already exists.

func (*InMemoryJobStore) Get

func (s *InMemoryJobStore) Get(id string) (Job, bool)

Get returns a job by id.

func (*InMemoryJobStore) GetResult

func (s *InMemoryJobStore) GetResult(jobID string) (JobResult, bool)

GetResult returns a stored result payload by job id.

func (*InMemoryJobStore) List

func (s *InMemoryJobStore) List(filter JobFilter) JobList

List returns jobs matching filter with sorting and pagination applied.

func (*InMemoryJobStore) SetResult

func (s *InMemoryJobStore) SetResult(jobID string, result JobResult) error

SetResult stores a result payload for an existing job.

func (*InMemoryJobStore) Update

func (s *InMemoryJobStore) Update(job Job) error

Update replaces an existing job by id.

type InMemoryQueue

type InMemoryQueue struct {
	// contains filtered or unexported fields
}

InMemoryQueue is a simple in-memory queue.

func NewInMemoryQueue

func NewInMemoryQueue() *InMemoryQueue

NewInMemoryQueue creates an empty in-memory queue.

func (*InMemoryQueue) Close

func (q *InMemoryQueue) Close() error

Close permanently closes the queue and wakes blocked dequeuers.

func (*InMemoryQueue) Dequeue

func (q *InMemoryQueue) Dequeue(ctx context.Context) (string, error)

Dequeue blocks until a job id is available or ctx is canceled.

func (*InMemoryQueue) Enqueue

func (q *InMemoryQueue) Enqueue(jobID string) error

Enqueue adds a job id to the tail of the queue.

func (*InMemoryQueue) Pause

func (q *InMemoryQueue) Pause() error

Pause stops dequeuing while keeping queued jobs intact.

func (*InMemoryQueue) Remove

func (q *InMemoryQueue) Remove(jobID string) error

Remove deletes a queued job id.

func (*InMemoryQueue) Reorder

func (q *InMemoryQueue) Reorder(jobIDs []string) error

Reorder replaces queued job order with the provided ids.

func (*InMemoryQueue) Resume

func (q *InMemoryQueue) Resume() error

Resume re-enables dequeuing after Pause.

type Job

type Job struct {
	ID             string                         `json:"id"`
	BatchID        string                         `json:"batch_id,omitempty"`
	Domain         string                         `json:"domain"`
	SeverityTotals map[string]int                 `json:"severity_totals,omitempty"`
	Tests          []string                       `json:"-"`
	Overrides      map[string]any                 `json:"-"`
	UndelegatedNS  []engine.UndelegatedNameserver `json:"-"`
	UndelegatedDS  []engine.UndelegatedDSInfo     `json:"-"`
	MinLevel       string                         `json:"-"`
	Status         JobStatus                      `json:"status"`
	CreatedAt      time.Time                      `json:"created_at"`
	StartedAt      time.Time                      `json:"started_at,omitempty"`
	FinishedAt     time.Time                      `json:"finished_at,omitempty"`
	Progress       int                            `json:"progress"`
	ResultURL      string                         `json:"result_url,omitempty"`
	Error          string                         `json:"error,omitempty"`
}

Job represents a single test job.

type JobBatchRequest

type JobBatchRequest struct {
	Domains          []string                      `json:"domains"`
	Tests            []string                      `json:"tests,omitempty"`
	ProfileOverrides map[string]any                `json:"profile_overrides,omitempty"`
	Nameservers      *[]UndelegatedNameserverInput `json:"nameservers,omitempty"`
	DSInfo           *[]UndelegatedDSInput         `json:"ds_info,omitempty"`
	MinLevel         string                        `json:"min_level,omitempty"`
}

JobBatchRequest is the payload for a batch submission.

type JobBatchResponse

type JobBatchResponse struct {
	BatchID string   `json:"batch_id"`
	JobIDs  []string `json:"job_ids"`
}

JobBatchResponse describes the batch submission result.

type JobCreateRequest

type JobCreateRequest struct {
	Domain           string                       `json:"domain"`
	Tests            []string                     `json:"tests,omitempty"`
	ProfileOverrides map[string]any               `json:"profile_overrides,omitempty"`
	Nameservers      []UndelegatedNameserverInput `json:"nameservers,omitempty"`
	DSInfo           []UndelegatedDSInput         `json:"ds_info,omitempty"`
	MinLevel         string                       `json:"min_level,omitempty"`
}

JobCreateRequest is the payload for a single job.

type JobFilter

type JobFilter struct {
	Status        JobStatus
	BatchID       string
	Domain        string
	Severity      JobSeverityFilter
	CreatedAfter  time.Time
	CreatedBefore time.Time
	Limit         int
	Offset        int
	Sort          JobSort
}

JobFilter controls listing behavior.

type JobList

type JobList struct {
	Items      []Job  `json:"items"`
	Total      int    `json:"total"`
	Limit      int    `json:"limit,omitempty"`
	Offset     int    `json:"offset,omitempty"`
	NextCursor string `json:"next_cursor,omitempty"`
	PrevCursor string `json:"prev_cursor,omitempty"`
	Sort       string `json:"sort,omitempty"`
}

JobList represents list results.

type JobResult

type JobResult struct {
	JobID   string         `json:"job_id"`
	BatchID string         `json:"batch_id,omitempty"`
	Status  JobStatus      `json:"status"`
	Summary map[string]any `json:"summary,omitempty"`
	Raw     *JobResultRaw  `json:"raw,omitempty"`
}

JobResult holds output for a job.

type JobResultEntry

type JobResultEntry struct {
	Timestamp float64        `json:"timestamp"`
	Module    string         `json:"module"`
	Testcase  string         `json:"testcase"`
	Tag       string         `json:"tag"`
	Level     string         `json:"level"`
	Args      map[string]any `json:"args,omitempty"`
	Message   string         `json:"message,omitempty"`
	Raw       string         `json:"raw,omitempty"`
}

JobResultEntry is a single log entry for API consumers.

type JobResultRaw

type JobResultRaw struct {
	Locale  string           `json:"locale,omitempty"`
	Entries []JobResultEntry `json:"entries,omitempty"`
}

JobResultRaw contains the raw log entries for a job.

type JobSeverityFilter added in v0.9.16

type JobSeverityFilter string

JobSeverityFilter controls severity-based list filtering.

const (
	// Job severity filter values for list endpoints.
	JobSeverityWarningsPlus JobSeverityFilter = "warnings_plus"
	// JobSeverityErrorsOnly filters to jobs with errors or criticals.
	JobSeverityErrorsOnly JobSeverityFilter = "errors_only"
)

type JobSort added in v0.9.15

type JobSort string

JobSort controls ordering in list responses.

const (
	// Job sort values for list and batch endpoints.
	JobSortCreatedAtDesc JobSort = "created_at_desc"
	// JobSortCreatedAtAsc sorts by creation time ascending.
	JobSortCreatedAtAsc JobSort = "created_at_asc"
	// JobSortStartedAtDesc sorts by start time descending.
	JobSortStartedAtDesc JobSort = "started_at_desc"
	// JobSortStartedAtAsc sorts by start time ascending.
	JobSortStartedAtAsc JobSort = "started_at_asc"
	// JobSortDomainAsc sorts by domain ascending.
	JobSortDomainAsc JobSort = "domain_asc"
	// JobSortDomainDesc sorts by domain descending.
	JobSortDomainDesc JobSort = "domain_desc"
	// JobSortBatchIDAsc sorts by batch id ascending.
	JobSortBatchIDAsc JobSort = "batch_id_asc"
	// JobSortBatchIDDesc sorts by batch id descending.
	JobSortBatchIDDesc JobSort = "batch_id_desc"
	// JobSortErrorDesc sorts by error-heavy jobs first.
	JobSortErrorDesc JobSort = "error_desc"
	// JobSortCriticalDesc sorts by critical-heavy jobs first.
	JobSortCriticalDesc JobSort = "critical_desc"
)

type JobStatus

type JobStatus string

JobStatus describes the current state of a job.

const (
	// Job status values.
	JobQueued JobStatus = "queued"
	// JobRunning indicates a job currently executing.
	JobRunning JobStatus = "running"
	// JobSucceeded indicates a job completed successfully.
	JobSucceeded JobStatus = "succeeded"
	// JobFailed indicates a job completed with an error.
	JobFailed JobStatus = "failed"
	// JobCanceled indicates a job was canceled.
	JobCanceled JobStatus = "canceled"
	// JobExpired indicates a job expired before completion.
	JobExpired JobStatus = "expired"
	// JobPaused indicates a job is paused in the queue.
	JobPaused JobStatus = "paused"
)

type JobStore

type JobStore interface {
	Create(job Job) (Job, error)
	Get(id string) (Job, bool)
	Update(job Job) error
	List(filter JobFilter) JobList
	SetResult(jobID string, result JobResult) error
	GetResult(jobID string) (JobResult, bool)
}

JobStore persists job metadata and results.

type MetricsAPIRouteMetrics added in v0.9.16

type MetricsAPIRouteMetrics struct {
	Route             string            `json:"route"`
	Method            string            `json:"method"`
	RequestsTotal     int64             `json:"requests_total"`
	StatusClassCounts map[string]int64  `json:"status_class_counts"`
	LatencyMs         MetricsPercentile `json:"latency_ms"`
}

MetricsAPIRouteMetrics captures per-route API request statistics.

type MetricsAPISnapshot added in v0.9.16

type MetricsAPISnapshot struct {
	RequestsTotal     int64                    `json:"requests_total"`
	StatusClassCounts map[string]int64         `json:"status_class_counts"`
	ErrorCodeCounts   map[string]int64         `json:"error_code_counts"`
	Routes            []MetricsAPIRouteMetrics `json:"routes"`
}

MetricsAPISnapshot captures aggregate API request statistics.

type MetricsBatchInsight added in v0.9.16

type MetricsBatchInsight struct {
	BatchID        string           `json:"batch_id"`
	SizeTotal      int64            `json:"size_total"`
	ProcessedTotal int64            `json:"processed_total"`
	Outcomes       map[string]int64 `json:"outcomes"`
	SeverityTotals map[string]int64 `json:"severity_totals"`
}

MetricsBatchInsight captures outcome/severity totals for one batch.

type MetricsBatchInsightsSnapshot added in v0.9.16

type MetricsBatchInsightsSnapshot struct {
	Limit int                   `json:"limit"`
	Cap   int                   `json:"cap"`
	Items []MetricsBatchInsight `json:"items"`
	Other *MetricsBatchInsight  `json:"other,omitempty"`
}

MetricsBatchInsightsSnapshot summarizes batch-level quality outliers.

type MetricsCollector added in v0.9.16

type MetricsCollector struct {
	// contains filtered or unexported fields
}

MetricsCollector stores low-overhead in-memory counters and gauges.

func NewMetricsCollector added in v0.9.16

func NewMetricsCollector(cfg Config) *MetricsCollector

NewMetricsCollector creates a metrics collector initialized from server config.

func (*MetricsCollector) ObserveAPIRequest added in v0.9.16

func (m *MetricsCollector) ObserveAPIRequest(route string, method string, statusCode int, duration time.Duration, errorCode string)

ObserveAPIRequest records one API request observation.

func (*MetricsCollector) ObserveDNSQueries added in v0.9.17

func (m *MetricsCollector) ObserveDNSQueries(ipv4Queries int64, ipv6Queries int64)

ObserveDNSQueries records DNS query counters split by IP family.

func (*MetricsCollector) ObserveJobCompletion added in v0.9.16

func (m *MetricsCollector) ObserveJobCompletion(status JobStatus, duration time.Duration, severityTotals map[string]int64)

ObserveJobCompletion records completion data for a terminal job.

func (*MetricsCollector) ObserveJobCompletionWithContext added in v0.9.16

func (m *MetricsCollector) ObserveJobCompletionWithContext(batchID string, domain string, status JobStatus, duration time.Duration, severityTotals map[string]int64)

ObserveJobCompletionWithContext records completion data with batch/domain context.

func (*MetricsCollector) ObserveJobStatusTransition added in v0.9.16

func (m *MetricsCollector) ObserveJobStatusTransition(fromStatus, toStatus JobStatus)

ObserveJobStatusTransition records a job state transition.

func (*MetricsCollector) ObserveJobSubmitted added in v0.9.16

func (m *MetricsCollector) ObserveJobSubmitted(initialStatus JobStatus)

ObserveJobSubmitted records a submitted job without batch/domain context.

func (*MetricsCollector) ObserveJobSubmittedWithContext added in v0.9.16

func (m *MetricsCollector) ObserveJobSubmittedWithContext(batchID string, domain string, initialStatus JobStatus)

ObserveJobSubmittedWithContext records a submitted job with batch/domain context.

func (*MetricsCollector) ObserveQueuePaused added in v0.9.16

func (m *MetricsCollector) ObserveQueuePaused(paused bool)

ObserveQueuePaused records whether queue processing is paused.

func (*MetricsCollector) ObserveResultLocale added in v0.9.16

func (m *MetricsCollector) ObserveResultLocale(locale string)

ObserveResultLocale records locale usage when rendering results.

func (*MetricsCollector) Snapshot added in v0.9.16

func (m *MetricsCollector) Snapshot() MetricsSnapshot

Snapshot returns a metrics snapshot using default insight limits.

func (*MetricsCollector) SnapshotWithLimits added in v0.9.16

func (m *MetricsCollector) SnapshotWithLimits(domainLimit int, batchLimit int) MetricsSnapshot

SnapshotWithLimits returns a metrics snapshot with explicit insight limits.

type MetricsDomainInsight added in v0.9.16

type MetricsDomainInsight struct {
	Domain         string           `json:"domain"`
	RunsTotal      int64            `json:"runs_total"`
	LastStatus     JobStatus        `json:"last_status"`
	AvgDurationMs  float64          `json:"avg_duration_ms"`
	SeverityTotals map[string]int64 `json:"severity_totals"`
}

MetricsDomainInsight captures aggregated outcomes for one domain.

type MetricsDomainInsightsSnapshot added in v0.9.16

type MetricsDomainInsightsSnapshot struct {
	Limit int                    `json:"limit"`
	Cap   int                    `json:"cap"`
	Items []MetricsDomainInsight `json:"items"`
	Other *MetricsDomainInsight  `json:"other,omitempty"`
}

MetricsDomainInsightsSnapshot summarizes domain-level quality outliers.

type MetricsDurationSnapshot added in v0.9.16

type MetricsDurationSnapshot struct {
	Count int64             `json:"count"`
	Avg   float64           `json:"avg"`
	Pctl  MetricsPercentile `json:"percentiles"`
}

MetricsDurationSnapshot captures latency histogram summaries.

type MetricsHealthSnapshot added in v0.9.16

type MetricsHealthSnapshot struct {
	StartedAt         time.Time `json:"started_at"`
	UptimeSeconds     int64     `json:"uptime_seconds"`
	WorkerCount       int       `json:"worker_count"`
	ActiveWorkers     int       `json:"active_workers"`
	MaxConcurrentJobs int       `json:"max_concurrent_jobs"`
	QueuePaused       bool      `json:"queue_paused"`
	QueueDepth        int64     `json:"queue_depth"`
	InFlightJobs      int64     `json:"in_flight_jobs"`
	DNSQueriesTotal   int64     `json:"dns_queries_total"`
	DNSQueriesIPv4    int64     `json:"dns_queries_ipv4_total"`
	DNSQueriesIPv6    int64     `json:"dns_queries_ipv6_total"`
}

MetricsHealthSnapshot captures queue/worker runtime health.

type MetricsInsightsSnapshot added in v0.9.16

type MetricsInsightsSnapshot struct {
	Batches MetricsBatchInsightsSnapshot  `json:"batches"`
	Domains MetricsDomainInsightsSnapshot `json:"domains"`
}

MetricsInsightsSnapshot groups derived batch/domain insight tables.

type MetricsJobsSnapshot added in v0.9.16

type MetricsJobsSnapshot struct {
	SubmittedTotal int64            `json:"submitted_total"`
	StartedTotal   int64            `json:"started_total"`
	CompletedTotal int64            `json:"completed_total"`
	CanceledTotal  int64            `json:"canceled_total"`
	StatusCounts   map[string]int64 `json:"status_counts"`
}

MetricsJobsSnapshot captures lifecycle counters for submitted jobs.

type MetricsLocaleSnapshot added in v0.9.16

type MetricsLocaleSnapshot struct {
	Counts map[string]int64 `json:"counts"`
}

MetricsLocaleSnapshot captures requested result locales.

type MetricsOutcomesSnapshot added in v0.9.16

type MetricsOutcomesSnapshot struct {
	SuccessTotal  int64   `json:"success_total"`
	FailedTotal   int64   `json:"failed_total"`
	CanceledTotal int64   `json:"canceled_total"`
	SuccessRate   float64 `json:"success_rate"`
	FailedRate    float64 `json:"failed_rate"`
	CanceledRate  float64 `json:"canceled_rate"`
}

MetricsOutcomesSnapshot captures terminal outcome counters and ratios.

type MetricsPercentile added in v0.9.16

type MetricsPercentile struct {
	P50 int64 `json:"p50"`
	P90 int64 `json:"p90"`
	P99 int64 `json:"p99"`
}

MetricsPercentile stores P50/P90/P99 values.

type MetricsQualitySnapshot added in v0.9.16

type MetricsQualitySnapshot struct {
	JobDurationMs MetricsDurationSnapshot `json:"job_duration_ms"`
	Outcomes      MetricsOutcomesSnapshot `json:"outcomes"`
	Severity      MetricsSeveritySnapshot `json:"severity"`
	LocaleUsage   MetricsLocaleSnapshot   `json:"locale_usage"`
}

MetricsQualitySnapshot captures result-quality-oriented metrics.

type MetricsSeveritySnapshot added in v0.9.16

type MetricsSeveritySnapshot struct {
	Totals            map[string]int64   `json:"totals"`
	PerCompletedRates map[string]float64 `json:"per_completed_rates"`
}

MetricsSeveritySnapshot captures severity totals and per-completed ratios.

type MetricsSnapshot added in v0.9.16

type MetricsSnapshot struct {
	SchemaVersion string                  `json:"schema_version"`
	ServerVersion string                  `json:"server_version"`
	GeneratedAt   time.Time               `json:"generated_at"`
	Health        MetricsHealthSnapshot   `json:"health"`
	Jobs          MetricsJobsSnapshot     `json:"jobs"`
	API           MetricsAPISnapshot      `json:"api"`
	Quality       MetricsQualitySnapshot  `json:"quality"`
	Insights      MetricsInsightsSnapshot `json:"insights"`
	Trends        MetricsTrendsSnapshot   `json:"trends"`
}

MetricsSnapshot is the top-level payload returned by the metrics endpoint.

type MetricsTrendPoint added in v0.9.16

type MetricsTrendPoint struct {
	Timestamp               time.Time        `json:"timestamp"`
	Throughput              int64            `json:"throughput"`
	Failed                  int64            `json:"failed"`
	QueueDepth              int64            `json:"queue_depth"`
	DNSQueriesPerSecond     float64          `json:"dns_queries_per_second"`
	DNSQueriesIPv4PerSecond float64          `json:"dns_queries_ipv4_per_second"`
	DNSQueriesIPv6PerSecond float64          `json:"dns_queries_ipv6_per_second"`
	Severity                map[string]int64 `json:"severity"`
	APIP90Ms                map[string]int64 `json:"api_p90_ms,omitempty"`
}

MetricsTrendPoint contains one sampled trend datapoint.

type MetricsTrendWindowSnapshot added in v0.9.16

type MetricsTrendWindowSnapshot struct {
	ResolutionSeconds int64               `json:"resolution_seconds"`
	Points            []MetricsTrendPoint `json:"points"`
}

MetricsTrendWindowSnapshot contains sampled trend points for one window.

type MetricsTrendsSnapshot added in v0.9.16

type MetricsTrendsSnapshot struct {
	Windows map[string]MetricsTrendWindowSnapshot `json:"windows"`
}

MetricsTrendsSnapshot contains windowed trend series keyed by window name.

type Queue

type Queue interface {
	Enqueue(jobID string) error
	Dequeue(ctx context.Context) (string, error)
	Remove(jobID string) error
	Pause() error
	Resume() error
	Reorder(jobIDs []string) error
	Close() error
}

Queue holds queued job ids.

type QueueRemoveRequest

type QueueRemoveRequest struct {
	JobIDs []string `json:"job_ids"`
}

QueueRemoveRequest removes queued jobs by id.

type QueueRemoveResponse

type QueueRemoveResponse struct {
	Removed []string `json:"removed"`
}

QueueRemoveResponse reports removed jobs.

type QueueReorderRequest

type QueueReorderRequest struct {
	JobIDs []string `json:"job_ids"`
}

QueueReorderRequest reorders queued jobs.

type SQLJobStore added in v1.0.1

type SQLJobStore struct {
	// contains filtered or unexported fields
}

SQLJobStore implements JobStore using a SQL database.

func NewSQLJobStore added in v1.0.1

func NewSQLJobStore(db *sql.DB, dialect sqlDialect) *SQLJobStore

NewSQLJobStore creates a SQLJobStore backed by db using dialect.

func (*SQLJobStore) Create added in v1.0.1

func (s *SQLJobStore) Create(job Job) (Job, error)

Create inserts a new job and fails if the id already exists.

func (*SQLJobStore) Get added in v1.0.1

func (s *SQLJobStore) Get(id string) (Job, bool)

Get returns the job with the given id.

func (*SQLJobStore) GetResult added in v1.0.1

func (s *SQLJobStore) GetResult(jobID string) (JobResult, bool)

GetResult returns the stored result for jobID.

func (*SQLJobStore) List added in v1.0.1

func (s *SQLJobStore) List(filter JobFilter) JobList

List returns jobs matching filter with sorting and pagination applied.

func (*SQLJobStore) SetResult added in v1.0.1

func (s *SQLJobStore) SetResult(jobID string, result JobResult) error

SetResult stores a result for an existing job and updates severity totals atomically in a single transaction.

func (*SQLJobStore) Update added in v1.0.1

func (s *SQLJobStore) Update(job Job) error

Update replaces a job's mutable fields. Returns an error if the job does not exist. The sev_* columns are managed exclusively by SetResult.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds the HTTP API and supporting services.

func New

func New(cfg Config) *Server

New builds a server with in-memory components.

func NewWithOptions added in v1.0.1

func NewWithOptions(cfg Config) (*Server, error)

NewWithOptions builds a server using the configured storage backend. When cfg.Database.Driver is set, a SQL store is opened, schema migrations are run, and any jobs from an unclean shutdown are recovered. An error is returned if the database cannot be opened or migrated.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root HTTP handler.

func (*Server) Start

func (s *Server) Start()

Start launches background workers that consume queued jobs.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop requests worker shutdown and waits for completion.

type UndelegatedDSInput added in v1.0.0

type UndelegatedDSInput struct {
	KeyTag    int    `json:"keytag"`
	Algorithm int    `json:"algorithm"`
	DigType   int    `json:"digtype"`
	Digest    string `json:"digest"`
}

UndelegatedDSInput represents one undelegated DS row.

type UndelegatedNameserverInput added in v1.0.0

type UndelegatedNameserverInput struct {
	NS string `json:"ns"`
	IP string `json:"ip,omitempty"`
}

UndelegatedNameserverInput represents one undelegated nameserver row.

Directories

Path Synopsis
Package ui serves the embedded web UI assets for the API server.
Package ui serves the embedded web UI assets for the API server.

Jump to

Keyboard shortcuts

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