Grant a bus process an account scoped to its own declaration (issue 1180)
This commit is contained in:
@@ -190,6 +190,9 @@ func declaredFor(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaratio
|
||||
// And its own work-queue streams, each with the one process its bus.queues names as the
|
||||
// consumer (novox/hq ADR 0436 §1, §2, §6).
|
||||
Queues: queueOwnersOf(m),
|
||||
// And every process of its own that declares bus, each granted a bus account of its own (novox/hq
|
||||
// ADR 0436 §1, §2).
|
||||
Processes: processesOf(m),
|
||||
// And the tools its health asks (novox/hq ADR 0240): the machine's node-engine is granted them.
|
||||
Checks: catalogue.HealthChecks(m),
|
||||
// And whether it runs as an account of its own (novox/hq ADR 0259 §8).
|
||||
@@ -462,6 +465,34 @@ func queueOwnersOf(m catalogue.Manifest) []broker.QueueOwner {
|
||||
return out
|
||||
}
|
||||
|
||||
// processesOf is every process of a module that declares bus, as the broker composes its own account from
|
||||
// (novox/hq ADR 0436 §1, §2): its own emits, its own work-queue consumers (queueOwnersOf, filtered to each
|
||||
// process's own), its own state, whether it reads its module's own asks, and the tools and seat verbs it
|
||||
// calls.
|
||||
func processesOf(m catalogue.Manifest) []broker.ProcessPrincipal {
|
||||
buses := m.ProcessBuses()
|
||||
if len(buses) == 0 {
|
||||
return nil
|
||||
}
|
||||
queues := queueOwnersOf(m)
|
||||
var out []broker.ProcessPrincipal
|
||||
for _, r := range m.Resources {
|
||||
id := fmt.Sprint(r["id"])
|
||||
b, declared := buses[id]
|
||||
if !declared {
|
||||
continue
|
||||
}
|
||||
pr := broker.ProcessPrincipal{Process: id, Emits: b.Emits, State: b.State, Asks: b.Asks, Invokes: b.Invokes}
|
||||
for _, q := range queues {
|
||||
if q.Process == id {
|
||||
pr.Queues = append(pr.Queues, q)
|
||||
}
|
||||
}
|
||||
out = append(out, pr)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// DeclaredStreams is every module stream the catalogue declares, registered modules assigned or not: a
|
||||
// stream exists from registration, as a log does (novox/hq ADR 0363 §1).
|
||||
func (i *Inventory) DeclaredStreams(ctx context.Context) ([]broker.ModuleStream, error) {
|
||||
|
||||
Reference in New Issue
Block a user