mesh-grants: the part makes the build seats' named workers its composed holders name (A-413)
Builds: design 47 G A-413, A-414
This commit is contained in:
@@ -309,6 +309,19 @@ func AccountConsumers(users []Principal) []ModuleConsumer {
|
||||
out = append(out, mc)
|
||||
}
|
||||
}
|
||||
// A build seat's named workers (design 47 G §544, A-413): the seat traffic of each composed holder names them, and the part makes
|
||||
// them, never only names them in a membership. Main's workers are held already; only the named ones are made here.
|
||||
made := map[string]bool{}
|
||||
for _, p := range users {
|
||||
_, cs := SeatTrafficObjects([]Principal{p})
|
||||
for _, c := range cs {
|
||||
if !strings.HasSuffix(c.Name, "_named_worker") || made[c.Stream+"."+c.Name] {
|
||||
continue
|
||||
}
|
||||
made[c.Stream+"."+c.Name] = true
|
||||
out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: c})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package buscompose
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Design 47 G §543, §544, §600: a build seat's ask names its asker, each queue has a named worker beside main's, an asker
|
||||
// is granted the queues of its kinds under its own seat's name alone, and main's subject is the checker's and the builder's.
|
||||
@@ -66,6 +69,16 @@ func TestNamedAsks(t *testing.T) {
|
||||
if len(consumers) != 4 {
|
||||
t.Errorf("the work queue's consumers: %d, want 4 (a main and a named worker for each of two queues)", len(consumers))
|
||||
}
|
||||
// A-413: the part makes the named workers (AccountConsumers), never only names them in a membership.
|
||||
named := 0
|
||||
for _, mc := range AccountConsumers([]Principal{{Kind: KindModule, Node: "one", Module: "go-module", Holds: []Seat{held}}}) {
|
||||
if strings.HasSuffix(mc.Consumer.Name, "_named_worker") {
|
||||
named++
|
||||
}
|
||||
}
|
||||
if named != 2 {
|
||||
t.Errorf("account consumers hold %d named workers, want 2", named)
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 G §610, A-179 (test 60's case of §271): a user of a seat is granted a verb's call subject only where the verb's
|
||||
|
||||
@@ -136,6 +136,9 @@ func (p *Part) consumers(res *Result, recs buscompose.Records, match string) {
|
||||
for _, c := range byStream[stream] {
|
||||
key := stream + "." + c.Name
|
||||
h, ok := held[c.Name]
|
||||
if ok && strings.HasSuffix(c.Name, "_named_worker") {
|
||||
p.sayWorker(key + " is held already")
|
||||
}
|
||||
if ok {
|
||||
if h.Pending > BehindBound {
|
||||
if p.behindSeen[key] {
|
||||
@@ -190,6 +193,9 @@ func (p *Part) consumers(res *Result, recs buscompose.Records, match string) {
|
||||
switch err := p.Consumers.CreateConsumer(stream, buscompose.ConsumerConfig(c)); {
|
||||
case err == nil:
|
||||
st.Created = append(st.Created, key)
|
||||
if strings.HasSuffix(c.Name, "_named_worker") {
|
||||
p.sayWorker(key + " is created")
|
||||
}
|
||||
if p.Logf != nil {
|
||||
p.Logf("consumer %s created", key)
|
||||
}
|
||||
@@ -340,3 +346,18 @@ func (p *Part) sayBehind(st *ConsumersState) {
|
||||
p.behindSaid, p.behindKnown = why, true
|
||||
}
|
||||
}
|
||||
|
||||
// sayWorker logs one named seat worker's outcome (created, held already) once per change, so the journal names each worker the
|
||||
// pass considers (A-413).
|
||||
func (p *Part) sayWorker(line string) {
|
||||
p.holdMu.Lock()
|
||||
if p.workersSaid == nil {
|
||||
p.workersSaid = map[string]bool{}
|
||||
}
|
||||
done := p.workersSaid[line]
|
||||
p.workersSaid[line] = true
|
||||
p.holdMu.Unlock()
|
||||
if !done && p.Logf != nil {
|
||||
p.Logf("seat worker %s", line)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@ type Part struct {
|
||||
// leftOutSaid is the left-out and wanted-manifest lines last logged, so each change is said once (sayLeftOut).
|
||||
leftOutSaid string
|
||||
namedSaid string
|
||||
workersSaid map[string]bool
|
||||
heldKnown bool
|
||||
// differSaid is the account consumers' differences last said as a condition, once differKnown (consumers.go).
|
||||
differSaid string
|
||||
|
||||
Reference in New Issue
Block a user