Documentation
¶
Overview ¶
Package compact is "etherpad-go compact": etherpad-lite's bin/compactPad, bin/compactAllPads and bin/compactStalePads as a command of the binary.
It talks to the running server through its HTTP API (listAllPads, getLastEdited, getRevisionsCount, compactPad), as etherpad-lite's scripts do: the server holds pads in memory, so changing their history behind its back in the database would leave it with a stale copy. Compacting is destructive; export what you cannot lose as .etherpad first.
Index ¶
Constants ¶
const MaxOlderThanDays = 100_000
MaxOlderThanDays is the most days --older-than takes: a time.Duration holds about 106751 days, beyond that the cutoff would wrap into the future and select freshly edited pads.
Variables ¶
This section is empty.
Functions ¶
func RunFromCLI ¶
func RunFromCLI(args []string)
RunFromCLI runs "etherpad-go compact" and exits: 0 when every pad was compacted, 1 when one failed, 2 on a usage error.
Types ¶
type API ¶
type API interface {
ListAllPads() ([]string, error)
// GetLastEdited is the time of the pad's last edit, in milliseconds.
GetLastEdited(padID string) (int64, error)
// GetRevisionsCount is the pad's head revision number.
GetRevisionsCount(padID string) (int, error)
// CompactPad collapses the history, or keeps its last keep revisions.
CompactPad(padID string, keep *int) error
}
API is the part of the HTTP API the command uses.
type HTTPAPI ¶
type HTTPAPI struct {
BaseURL string // e.g. http://localhost:9001
APIKey string
Client *http.Client
// contains filtered or unexported fields
}
HTTPAPI calls the server's HTTP API (/api/<version>/<function>) with an API key.
func (*HTTPAPI) ListAllPads ¶
type Options ¶
type Options struct {
// Pads to compact; empty: every pad of the instance.
Pads []string
// OlderThanDays > 0 compacts only pads not edited for that many days
// (bin/compactStalePads).
OlderThanDays int
// Keep the last Keep revisions; nil collapses all history.
Keep *int
DryRun bool
}
Options of a run.