Documentation
¶
Index ¶
Constants ¶
const ( OnlineWindow = 5 * time.Minute ActiveWindow = 7 * 24 * time.Hour )
OnlineWindow and ActiveWindow are how recent the use of a session or an API token is for an account to count as online now and as active.
const ProbeTimeout = 2 * time.Second
ProbeTimeout is how long a request to serve's API, MCP or web app waits.
const SiloTimeout = 3 * time.Second
SiloTimeout is how long the Silo check waits: an unreachable Silo is reported, it must not stall the command.
Variables ¶
This section is empty.
Functions ¶
func Process ¶
func Process(ctx context.Context, db bun.IDB, connect func(context.Context) (silo.Store, error)) *run
Process assembles the status. A failing query is an error: the base is unreachable, and the result keeps what was read (Silo is checked anyway). Silo is not an error: connect (silo.New) and the Ping of its store, within SiloTimeout, only set SiloOK and SiloError.
The counts cross the accounts: the admin's exception to "every query filters by account". No API route gives them.
Types ¶
type Postgres ¶
type Postgres struct {
Latency time.Duration `json:"latency_ns"` // one query, in nanoseconds in JSON
Version string `json:"version"`
Size int64 `json:"size"` // bytes, the whole database
Connections int64 `json:"connections"` // open ones on this database, this one included
}
Postgres is the base as the connection sees it.
type Probe ¶
type Probe struct {
Tried bool `json:"tried"`
OK bool `json:"ok"`
Latency time.Duration `json:"latency_ns"`
Error string `json:"error,omitempty"`
}
Probe is one request to serve: whether it answered as it should, and in how long. Not tried (serve stopped, the part off), it is zero.
type Silo ¶
type Silo struct {
OK bool `json:"ok"`
Latency time.Duration `json:"latency_ns"` // one Ping, zero when Silo does not answer
Error string `json:"error,omitempty"`
Bucket string `json:"bucket"`
// Endpoint is S3_ENDPOINT, where serve and this process reach Silo.
Endpoint string `json:"endpoint"`
}
Silo is the storage of the files: whether it answers, and the bucket it should hold.
type Status ¶
type Status struct {
Server *domain.ServerStatus `json:"server"` // nil when no serve ever ran on this base
Running bool `json:"running"` // its heartbeat is younger than domain.ServerStaleAfter
// API, MCP and Web are requests made to the running serve, on the address it listens on, else the published one.
API Probe `json:"api"`
MCP Probe `json:"mcp"`
Web Probe `json:"web"`
Postgres Postgres `json:"postgres"`
Silo Silo `json:"silo"`
Usage Usage `json:"usage"`
}
Status is what the admin sees of the server: the row serve publishes, the third parties it relies on and the usage of the base, made at the reading.
type Usage ¶
type Usage struct {
Accounts int64 `json:"accounts"`
Disabled int64 `json:"disabled"`
// Online and Active7d count the accounts with a session or an API token used within OnlineWindow and ActiveWindow.
Online int64 `json:"online"`
Active7d int64 `json:"active_7d" bun:"active_7d"`
Files int64 `json:"files"`
FilesSize int64 `json:"files_size"` // bytes
Orphans int64 `json:"orphans"` // files no note cites since the last cleanup: purgefiles deletes them in time
Trash int64 `json:"trash"` // items in the trash, notes and folders
// TrashSize is the stored text of the trashed notes, sealed: the files they cite are not counted, only the notes
// themselves say which they are, and they are sealed.
TrashSize int64 `json:"trash_size"`
// TrashRetentionDays is the retention most accounts have (it is a setting of each account), 0 when they keep it forever.
TrashRetentionDays int `json:"trash_retention_days"`
}
Usage is what the accounts hold, across all of them.