staging

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func FinishNextRestartBatch(ctx context.Context, store *storage.Store, serverID string) error

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

type Decision struct {
	Due       bool
	SetIdle   bool
	IdleSince *time.Time
}

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

type ModuleField struct {
	Base  any `json:"base"`
	Value any `json:"value"`
}

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

type Plan struct {
	SaveAll    bool
	Restart    bool
	Recreate   bool
	StartAfter bool
	ModuleIDs  []string
}

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

func (p Plan) NeedsPublish() bool

NeedsPublish reports whether the window has server or module container work.

func (Plan) TouchesContainer

func (p Plan) TouchesContainer() bool

TouchesContainer reports whether publishing the plan stops, starts, or replaces the server container.

type PlayerSample

type PlayerSample struct {
	Known bool
	Count int
}

PlayerSample is one reading from the same player-count provider freeze and deep sleep use. Known is false when that provider is not installed.

type Publisher

type Publisher func(ctx context.Context, server *storage.Server, plan Plan) error

Publisher performs the one container mutation for a due batch.

Jump to

Keyboard shortcuts

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