The ledger account's subjects come from mesh-sdk's one naming of them (issue 1966 D5)
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
sdk "git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
)
|
||||
|
||||
// A module's ledger and the one account that writes it (issue 1966 D5; novox/hq ADR 0597 §9, design 25 § 12.4).
|
||||
@@ -12,27 +14,16 @@ import (
|
||||
// **Only the tool runner's ledger credential publishes on a ledger's history** (ADR 0597 §9): one per module assignment,
|
||||
// named ledger.<machine>.<module> (KindLedger), scoped to the subjects of that module's ledger histories and snapshots, and
|
||||
// gone when the module is unassigned from the machine. The module's own account, its processes and the machine's tool
|
||||
// runner hold no publish there, so a raw publish on a history is refused by the bus. The subjects are `mesh.ledger.<module>.
|
||||
// <local name>.history.<instance>` and `mesh.ledger.<module>.<local name>.snapshot.<instance>`, one subject per instance
|
||||
// (design 25 § 12.4); the bus module that creates the ledger's history stream (B2) takes them from here.
|
||||
|
||||
// LedgerHistorySubject is the subject a ledger's history is on, without the instance: an operation on instance I is on
|
||||
// `<LedgerHistorySubject>.<I>`.
|
||||
func LedgerHistorySubject(module, local string) string {
|
||||
return "mesh.ledger." + module + "." + local + ".history"
|
||||
}
|
||||
|
||||
// LedgerSnapshotSubject is the subject a ledger's instances' snapshots are on, without the instance.
|
||||
func LedgerSnapshotSubject(module, local string) string {
|
||||
return "mesh.ledger." + module + "." + local + ".snapshot"
|
||||
}
|
||||
// runner hold no publish there, so a raw publish on a history is refused by the bus. The subjects are named in one place, mesh-sdk's
|
||||
// buscompose (LedgerHistorySubject, LedgerSnapshotSubject), `mesh.ledger.<module>.<local name>.history|snapshot` and
|
||||
// one subject per instance below it (design 25 § 12.4).
|
||||
|
||||
// LedgerPublishGrants are the publish patterns a module's ledger account is granted: the histories and the snapshots of the
|
||||
// ledgers named, every instance of each, and nothing else. Sorted.
|
||||
func LedgerPublishGrants(module string, locals []string) []string {
|
||||
var out []string
|
||||
for _, local := range locals {
|
||||
out = append(out, LedgerHistorySubject(module, local)+".>", LedgerSnapshotSubject(module, local)+".>")
|
||||
out = append(out, sdk.LedgerHistorySubject(module, local)+".>", sdk.LedgerSnapshotSubject(module, local)+".>")
|
||||
}
|
||||
sort.Strings(out)
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user