stats

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStats added in v0.6.3

func GetStats(store *lib.InitStore) fiber.Handler

GetStats godoc @Summary Instance statistics @Description Returns the total number of pads, connected sessions and pads with connected users @Tags Stats @Produce json @Success 200 {object} StatsResponse @Failure 500 {object} errors.Error @Security BearerAuth @Router /admin/api/stats [get]

func Handler

func Handler(
	version string,
	releaseID string,
	serviceID string,
	checkers []Checker,
	detailed bool,
) fiber.Handler

Handler godoc @Summary Health check endpoint @Description Returns the health status of the service (RFC Health Check Draft) @Tags Health @Produce json @Success 200 {object} HealthResponse "Service is healthy" @Failure 503 {object} HealthResponse "Service is unhealthy" @Router /health [get]

With detailed false (the public /health, as in etherpad-lite) only status and releaseId are answered, with the same HTTP status: the checks name active pads, cluster members and database errors, which anonymous clients must not read. The admin API serves the detailed answer.

func Init

func Init(store *lib.InitStore)

func LiveHandler added in v0.7.0

func LiveHandler() fiber.Handler

LiveHandler answers the liveness probe: the process serves requests. It checks nothing else, so a database outage does not get every pod restarted at once.

func ReadyHandler added in v0.7.0

func ReadyHandler(state *lifecycle.State, db Checker) fiber.Handler

ReadyHandler answers the readiness probe: 200 while this instance should get traffic, 503 while it starts, shuts down or cannot reach the database.

Types

type Check

type Check struct {
	Status     HealthStatus `json:"status" example:"pass"`
	Component  string       `json:"component,omitempty" example:"database"`
	Observed   any          `json:"observedValue,omitempty"`
	ObservedAt string       `json:"observedAt,omitempty" example:"2024-01-15T10:30:00Z"`
	Output     string       `json:"output,omitempty" example:"ok"`
}

Check represents the result of a single health check @Description Result of a health check

type Checker

type Checker interface {
	Name() string
	Check() Check
}

Checker is the interface for health check implementations

type ClusterChecker added in v0.7.0

type ClusterChecker struct {
	Clustered       bool
	Bus             cluster.Bus
	RetentionLeader *cluster.Elector
}

ClusterChecker reports how this instance sees the cluster. A missing bus is only a warning: edits stay correct through the database, other instances just see them later.

func (ClusterChecker) Check added in v0.7.0

func (c ClusterChecker) Check() Check

func (ClusterChecker) Name added in v0.7.0

func (c ClusterChecker) Name() string

type ClusterObservation added in v0.7.0

type ClusterObservation struct {
	Enabled         bool `json:"enabled"`
	Members         int  `json:"members"`
	RetentionLeader bool `json:"retentionLeader"`
}

ClusterObservation is the observedValue of the cluster check.

type DBChecker

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

func (DBChecker) Check

func (d DBChecker) Check() Check

func (DBChecker) Name

func (d DBChecker) Name() string

type EtherpadChecker

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

func (EtherpadChecker) Check

func (e EtherpadChecker) Check() Check

func (EtherpadChecker) Name

func (e EtherpadChecker) Name() string

type HealthResponse

type HealthResponse struct {
	Status    HealthStatus       `json:"status" example:"pass"`
	Version   string             `json:"version,omitempty" example:"1.0.0"`
	ReleaseID string             `json:"releaseId,omitempty" example:"abc123"`
	ServiceID string             `json:"serviceId,omitempty" example:"etherpad-api"`
	Checks    map[string][]Check `json:"checks,omitempty"`
}

HealthResponse represents the response of the health endpoint @Description Complete health check response

type HealthStatus

type HealthStatus string

HealthStatus represents the status of a health check @Description Status of a health check (pass, warn, fail)

const (
	StatusPass HealthStatus = "pass"
	StatusWarn HealthStatus = "warn"
	StatusFail HealthStatus = "fail"
)

type StatsResponse added in v0.6.3

type StatsResponse struct {
	TotalPads       int `json:"totalPads"`
	TotalSessions   int `json:"totalSessions"`
	TotalActivePads int `json:"totalActivePads"`
}

StatsResponse mirrors the original getStats API payload.

Jump to

Keyboard shortcuts

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