Entry Registry
Entry Registry
Section titled “Entry Registry”Query and modify registered entries. Access metadata, snapshots, and version history.
Loading
Section titled “Loading”local registry = require("registry")Entry Structure
Section titled “Entry Structure”{ id = "app.lib:assert", -- string: "namespace:name" kind = "function.lua", -- string: entry type meta = {type = "test"}, -- table: searchable metadata data = {...} -- any: entry payload}Get Entry
Section titled “Get Entry”local entry, err = registry.get("app.lib:assert")Permission: registry.get on entry ID
Find Entries
Section titled “Find Entries”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.
Parse ID
Section titled “Parse ID”local id = registry.parse_id("app.lib:assert")-- id.ns = "app.lib", id.name = "assert"Snapshots
Section titled “Snapshots”Point-in-time view of the registry:
local snap, err = registry.snapshot() -- current statelocal snap, err = registry.snapshot_at(5) -- at version 5Snapshot Methods
Section titled “Snapshot Methods”| Method | Returns | Description |
|---|---|---|
snap:entries() | Entry[], error | All accessible entries |
snap:get(id) | Entry, error | Single entry by ID |
snap:find(filter) | Entry[] | Filter entries |
snap:namespace(ns) | Entry[] | Entries in namespace |
snap:version() | Version | Snapshot version |
snap:changes() | Changes | Create changeset |
Versions
Section titled “Versions”local version, err = registry.current_version()local versions, err = registry.versions()
print(version:id()) -- numeric IDprint(version:string()) -- display stringlocal prev = version:previous() -- previous version or nillocal next = version:next() -- next version or nilHistory
Section titled “History”local hist, err = registry.history()local versions, err = hist:versions()local version, err = hist:get_version(5)local snap, err = hist:snapshot_at(version)Changesets
Section titled “Changesets”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()
Changes Methods
Section titled “Changes Methods”| Method | Description |
|---|---|
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 |
Apply Version
Section titled “Apply 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
Build Delta
Section titled “Build Delta”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"endPermissions
Section titled “Permissions”| Permission | Resource | Description |
|---|---|---|
registry.get | entry ID | Read entry (also filters find/entries results) |
registry.apply | - | Apply changeset |
registry.apply_version | - | Apply/rollback version |
Errors
Section titled “Errors”| Condition | Kind |
|---|---|
| Entry not found | errors.NOT_FOUND |
| Version not found | errors.NOT_FOUND |
| Permission denied | errors.PERMISSION_DENIED |
| Invalid parameter | errors.INVALID |
| No changes to apply | errors.INVALID |
| Registry not available | errors.INTERNAL |
See Error Handling for working with errors.