Skip to content

Entry Registry

Query and modify registered entries. Access metadata, snapshots, and version history.

local registry = require("registry")
{
id = "app.lib:assert", -- string: "namespace:name"
kind = "function.lua", -- string: entry type
meta = {type = "test"}, -- table: searchable metadata
data = {...} -- any: entry payload
}
local entry, err = registry.get("app.lib:assert")

Permission: registry.get on entry ID

local entries, err = registry.find({[".kind"] = "function.lua"})
local entries, err = registry.find({[".kind"] = "http.endpoint", [".ns"] = "app.api"})

Filter fields match against entry metadata.

local id = registry.parse_id("app.lib:assert")
-- id.ns = "app.lib", id.name = "assert"

Point-in-time view of the registry:

local snap, err = registry.snapshot() -- current state
local snap, err = registry.snapshot_at(5) -- at version 5
MethodReturnsDescription
snap:entries()Entry[], errorAll accessible entries
snap:get(id)Entry, errorSingle entry by ID
snap:find(filter)Entry[]Filter entries
snap:namespace(ns)Entry[]Entries in namespace
snap:version()VersionSnapshot version
snap:changes()ChangesCreate changeset
local version, err = registry.current_version()
local versions, err = registry.versions()
print(version:id()) -- numeric ID
print(version:string()) -- display string
local prev = version:previous() -- previous version or nil
local next = version:next() -- next version or nil
local hist, err = registry.history()
local versions, err = hist:versions()
local version, err = hist:get_version(5)
local snap, err = hist:snapshot_at(version)

Build and apply modifications:

local snap, err = registry.snapshot()
local changes = snap:changes()
changes:create({
id = "test:new_entry",
kind = "test.kind",
meta = {type = "test"},
data = {config = "value"}
})
changes:update({
id = "test:existing",
kind = "test.kind",
meta = {updated = true},
data = {new_value = true}
})
changes:delete("test:old_entry")
local new_version, err = changes:apply()

Permission: registry.apply for changes:apply()

MethodDescription
changes:create(entry)Add create operation
changes:update(entry)Add update operation
changes:delete(id)Add delete operation (string or {ns, name})
changes:ops()Get pending operations
changes:apply()Apply changes, returns new Version

Roll back or forward to a specific version:

local prev = current_version:previous()
local ok, err = registry.apply_version(prev)

Permission: registry.apply_version

Compute operations to transition between states:

local from = {{id = "test:a", kind = "test", meta = {}, data = {}}}
local to = {{id = "test:b", kind = "test", meta = {}, data = {}}}
local ops, err = registry.build_delta(from, to)
for _, op in ipairs(ops) do
print(op.kind, op.entry.id) -- "entry.create", "entry.update", "entry.delete"
end
PermissionResourceDescription
registry.getentry IDRead entry (also filters find/entries results)
registry.apply-Apply changeset
registry.apply_version-Apply/rollback version
ConditionKind
Entry not founderrors.NOT_FOUND
Version not founderrors.NOT_FOUND
Permission deniederrors.PERMISSION_DENIED
Invalid parametererrors.INVALID
No changes to applyerrors.INVALID
Registry not availableerrors.INTERNAL

See Error Handling for working with errors.