Documentation
¶
Index ¶
- Constants
- type Package
- type Store
- func (s *Store) Delete(name string) bool
- func (s *Store) GetPendingSettings(name string) addonutils.Values
- func (s *Store) HandleEvent(event int, name string) context.Context
- func (s *Store) NeedUpdate(name, version, checksum string) bool
- func (s *Store) Update(name, version string, settings addonutils.Values) context.Context
Constants ¶
const ( EventUpdate = iota EventRemove EventSchedule )
Event types determine context cancellation behavior in newContext.
Root events (EventUpdate, EventRemove) cancel the entire context tree and create a fresh root. All in-flight tasks for the package see ctx.Done().
Child events (EventSchedule) cancel only the previous context for the same event key, then create a new child of the current root.
EventSchedule is shared by both enable and disable flows, providing mutual cancellation: enabling cancels a pending disable and vice versa.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package holds the lifecycle state for a single runtime package: version tracking, pending settings, and a tree of cancellable contexts for coordinating concurrent operations.
Package does not hold the loaded runtime instance (Application/Module) — those live in plain maps on Runtime. This keeps the Store type-agnostic.
Context hierarchy:
root (ctx/cancel) — created by EventUpdate or EventRemove └── EventSchedule child — cancelled on enable↔disable transition
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages lifecycle contexts and pending settings for all runtime packages. It is type-agnostic — it does not hold the loaded Application/Module instances, only the version, settings, and context tree needed for change detection and cancellation. The actual runtime instances live in plain maps on Runtime.
Store is not thread-safe; callers must hold Runtime.mu before calling any method.
func (*Store) Delete ¶
Delete removes a package entry from the store if it still exists and is in the removed state (version cleared by HandleEvent(EventRemove)). Returns true if the entry was deleted.
Safe against re-creation races: if Update has already set a new version between the remove and this cleanup, the version is non-empty and Delete returns false, preserving the re-created entry.
func (*Store) GetPendingSettings ¶ added in v1.76.0
func (s *Store) GetPendingSettings(name string) addonutils.Values
GetPendingSettings returns the latest settings stored for a package. Called by schedulePackage to pass current settings into the Configure task. This late-binding approach ensures settings changes that arrive between Update and schedule are automatically picked up.
func (*Store) HandleEvent ¶
HandleEvent renews the context for the given event type and returns it.
For EventRemove: clears version and settings before renewing context, so a subsequent Update sees the package as new (enabling re-create after remove).
Returns nil if the package doesn't exist in the store.
func (*Store) NeedUpdate ¶ added in v1.76.0
NeedUpdate reports whether the package needs processing: true if the package is new, the version changed, or the settings checksum differs. Used as a fast-path check before the more expensive Update call.
func (*Store) Update ¶
Update registers a new package or processes a version change.
Returns a new root context (EventUpdate) when:
- Package not in store → creates entry, returns root context
- Version differs → cancels all in-flight tasks, returns new root context
Returns nil when only settings changed (no new context needed — settings are stored and will be picked up by the scheduler via GetPendingSettings on next Reschedule, or by the next Configure task in the schedule pipeline).
Callers should check for nil: a nil return with a settings-only change means the caller should trigger Reschedule to re-apply settings through the scheduler.