Documentation
¶
Index ¶
- Variables
- func ApplyBatch(ctx context.Context, store *storage.Store, log *logger.Logger, ...) error
- func CommitNextRestartFiles(ctx context.Context, store *storage.Store, server *storage.Server, ...) (func(), error)
- func FinishNextRestartBatch(ctx context.Context, store *storage.Store, serverID string) error
- func StageModpackTree(ctx context.Context, store *storage.Store, server *storage.Server, ...) (*storage.StagedContentChange, error)
- func StageModuleChange(ctx context.Context, store *storage.Store, server *storage.Server, ...) (*storage.StagedContentChange, error)
- func Sweep(ctx context.Context, store *storage.Store, log *logger.Logger, now time.Time, ...) error
- type Decision
- type ModuleField
- type Plan
- type PlayerSample
- type Publisher
Constants ¶
This section is empty.
Variables ¶
var ErrStagedModuleMoved = errors.New("staged module field changed after it was staged")
ErrStagedModuleMoved means a module field changed after it was staged.
Functions ¶
func ApplyBatch ¶
func ApplyBatch(ctx context.Context, store *storage.Store, log *logger.Logger, server *storage.Server, batch storage.ServerUpdateBatch, publish Publisher) error
ApplyBatch publishes one due batch. Files and config are restored when the container mutation fails, and the batch stays open. A live config field that moved after staging stops the apply before anything is written.
func CommitNextRestartFiles ¶
func CommitNextRestartFiles(ctx context.Context, store *storage.Store, server *storage.Server, recreateModule func(context.Context, string) error) (func(), error)
CommitNextRestartFiles copies content for a next-restart batch onto the live tree. A batch waiting for a time or an idle window is left untouched, so an incidental restart does not publish it. recreateModule runs for a staged module whose container spec changed. The returned function puts the files and module fields back and returns the rows to staged.
func FinishNextRestartBatch ¶
FinishNextRestartBatch closes a next-restart batch once nothing in it is still staged. Time and idle batches are left open.
func StageModpackTree ¶
func StageModpackTree(ctx context.Context, store *storage.Store, server *storage.Server, srcDir, summary string) (*storage.StagedContentChange, error)
StageModpackTree copies a fetched pack into the open batch. The live pack and the container are left as they are. A later window copies the tree.
func StageModuleChange ¶
func StageModuleChange(ctx context.Context, store *storage.Store, server *storage.Server, moduleID, summary string, needsRecreate bool, fields map[string]ModuleField) (*storage.StagedContentChange, error)
StageModuleChange records a module config or container-spec change on the server's open batch. The live module row and its container stay as they are.
func Sweep ¶
func Sweep(ctx context.Context, store *storage.Store, log *logger.Logger, now time.Time, players func(serverID string) (int, bool), publish Publisher) error
Sweep updates idle clocks and publishes batches whose window has arrived. A lock held by another lifecycle mutation is left for the next sweep.
Types ¶
type Decision ¶
Decision is what a sweep should do with one open batch. SetIdle persists IdleSince, including a nil value that clears a stretch after a player joins.
func Decide ¶
func Decide(now time.Time, batch storage.ServerUpdateBatch, players PlayerSample) Decision
Decide reports whether a batch should be published now. A next-restart batch is never due here: an incidental start must not publish a future time or an idle window, and a next-restart batch waits for that explicit restart. A missing player provider does not start or fire an idle window.
type ModuleField ¶
ModuleField is one staged module column. Base is the live value at stage time. Value is what apply writes when Base still matches.
type Plan ¶
Plan is the container work that publishes a batch after its files and config are on the server. Deep sleep commits onto the stopped server and does not start the JVM. A frozen server gets a real stop and start so the new process is the one left running.
func PlanFor ¶
func PlanFor(status storage.ServerStatus, configChanged bool) Plan
PlanFor chooses the container action for a server status. configChanged means the batch merged ServerConfig, so the container spec has to be rebuilt.
func (Plan) NeedsPublish ¶
NeedsPublish reports whether the window has server or module container work.
func (Plan) TouchesContainer ¶
TouchesContainer reports whether publishing the plan stops, starts, or replaces the server container.
type PlayerSample ¶
PlayerSample is one reading from the same player-count provider freeze and deep sleep use. Known is false when that provider is not installed.