Skip to content

l0.DependencyControl.Updater

Updater = require "l0.DependencyControl.Updater"
local Updater = require("l0.DependencyControl.Updater")

Updater

Coordinates background update checks and update task lifecycle.

Constructor

updater = Updater host, config, logger
local updater = Updater(host, config, logger)

Creates an updater coordinator for one host script context.

param type description
host? string Host script namespace (default script_namespace).
config ConfigView The global DependencyControl config view.
logger? Logger

Instance methods

addTask

updater\addTask record, targetVersion, addFeeds, optional, channel, reason
updater:addTask(record, targetVersion, addFeeds, optional, channel, reason)

Creates or updates a queued update task for a record.

param type description
record PackageRecord|table A record, or a plain table to construct one from.
targetVersion? number|string Minimum version to install.
addFeeds? string[]
optional? boolean Treat this as an optional dependency.
channel? string Update channel to use.
reason? UpdateReason Why the task runs; the configured update mode must allow it, and it gates interactive prompts. Defaults to AutoUpdate, the least interactive.

Returns:

require

updater\require record, targetVersion, addFeeds, optional, channel, reason
updater:require(record, targetVersion, addFeeds, optional, channel, reason)

Ensures a module dependency is installed/updated and loadable.

param type description
record PackageRecord
targetVersion? number|string Minimum version to install.
addFeeds? string[]
optional? boolean Treat this as an optional dependency.
channel? string Update channel to use.
reason? UpdateReason Defaults to DependencyResolution — the reason this method exists; a caller (e.g. an installed provider) may pass another to carry its own reason through.

Returns:

  • ref any — The loaded module reference, or nil when the module couldn't be provided.
  • code UpdateStatus? — Outcome of the update run; always present when the ref is nil, with SkippedOptional marking a skipped optional dependency rather than a failure.
  • detail string? — Error detail for a failing code, or the paradox reason when an up-to-date module then can't be loaded.

scheduleUpdate

updater\scheduleUpdate record
updater:scheduleUpdate(record)

Performs a periodic non-blocking update check for a managed record.

param type description
record PackageRecord

Returns:

  • status UpdateStatus — The status code (the task's run result when an update actually runs).
  • entryPath string? — The resolved entry-point path, returned only with a ProtectedInstall status.

acquireLock

updater\acquireLock doWait, waitTimeout
updater:acquireLock(doWait, waitTimeout)

Acquires the global updater lock shared across scripts and processes.

param type description
doWait boolean Wait for a concurrent update to finish instead of bailing out.
waitTimeout? number Seconds to wait when doWait is set.

Returns:

  • acquired boolean
  • lockOwner string? — The holder script's name when acquisition failed.

renewLock

updater\renewLock!
updater:renewLock()

Renews the updater lock's lease if we currently hold it.

releaseLock

updater\releaseLock!
updater:releaseLock()

Releases the global updater lock.

Returns:

  • released boolean

Class methods

isRunning

Updater\isRunning!
Updater:isRunning()

Reports whether an update is currently running in any script or process.

Returns:

  • running boolean
  • holderName string? — The name of the script holding the updater lock.

Fields

field type description
feedTrust FeedTrust The feed-trust model (official + user trust merge, trust queries, mutations).
feedLoader FeedLoader The shared feed loader (owns the feed cache; builds every UpdateFeed).
defaultMode UpdateContextCeiling
defaultCheckInterval integer
defaultWaitTimeout integer
defaultOrphanTimeout integer