Publish queue: retire builder_publish_first, list in stream order (H-A-483)
With one consumer per holder an item has no class to move ahead of, so builder_publish_first, its mode and its act go. The verb publish-queue lists the items in stream order, the order the one consumer gives them, and its description says so. A holder is a module name, so one ending in -live or -again (an earlier release's class durable) is refused at the learn, said, instead of having another holder's durable deleted. Builds: design 47 H2 H-A-483 third addendum, §793
This commit is contained in:
@@ -73,7 +73,7 @@ func publishQueueVia(ask func(key string, body any) (json.RawMessage, error)) fu
|
||||
}
|
||||
}
|
||||
|
||||
// publishActTools are builder_publish_drop and builder_publish_first (design 47 H2 §793): hand acts, recorded in the hand-act log
|
||||
// publishActTools are builder_publish_drop (design 47 H2 §793; builder_publish_first is retired, H-A-483 third addendum): hand acts, recorded in the hand-act log
|
||||
// first, then written to reasks for the builder, which owns the work queue, to perform and answer.
|
||||
func publishActTools(ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
||||
str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
|
||||
@@ -108,7 +108,6 @@ func publishActTools(ask queueAsker, now func() time.Time, acts meshhandactsclie
|
||||
}
|
||||
return []stdio.Tool{
|
||||
tool(versions.PublishDropTool, build.ModePublishDrop, versions.PublishDropDescription, "dropped the publish of"),
|
||||
tool(versions.PublishFirstTool, build.ModePublishFirst, versions.PublishFirstDescription, "put first the publish of"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
||||
}
|
||||
})
|
||||
// Design 47 H2 §793, H-A-454: builder_publish_queue asks the seat mesh-builds' verb publish-queue, which the builder serves from
|
||||
// its own stream, and answers its counts, list and cap with the states beside them; builder_publish_drop and
|
||||
// builder_publish_first record the hand act first, then write their reasks value.
|
||||
// its own stream, and answers its counts, list and cap with the states beside them; builder_publish_drop records the hand act
|
||||
// first, then writes its reasks value; builder_publish_first is retired (H-A-483, third addendum).
|
||||
t.Run("the queue is the builder's verb publish-queue", func(t *testing.T) {
|
||||
var asked []string
|
||||
ask := func(key string, body any) (json.RawMessage, error) {
|
||||
@@ -123,7 +123,7 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
||||
t.Errorf("asked %v, answered %+v (%v): want each holder asked in turn at its node, answered together, the silent one with why", asked, hs, err)
|
||||
}
|
||||
})
|
||||
t.Run("drop and first record the hand act, then ask the builder", func(t *testing.T) {
|
||||
t.Run("drop records the hand act, then asks the builder; first is retired", func(t *testing.T) {
|
||||
var order []string
|
||||
ask := func(key string, value []byte) (json.RawMessage, error) {
|
||||
order = append(order, "ask "+key)
|
||||
@@ -141,8 +141,8 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
||||
t.Fatalf("%s: %v", tool.Name, err)
|
||||
}
|
||||
}
|
||||
if len(tools) != 2 || fmt.Sprint(order) != "[record ask publish-drop.5000000000 record ask publish-first.5000000000]" {
|
||||
t.Errorf("tools %d, order %v: want each hand act recorded before its reasks value", len(tools), order)
|
||||
if len(tools) != 1 || tools[0].Name != versions.PublishDropTool || fmt.Sprint(order) != "[record ask publish-drop.5000000000]" {
|
||||
t.Errorf("tools %d, order %v: want builder_publish_drop alone, its hand act recorded before its reasks value", len(tools), order)
|
||||
}
|
||||
if _, err := tools[0].Run(map[string]any{"module": "m", "why": "no version"}); err == nil {
|
||||
t.Error("a drop naming no version is not refused")
|
||||
|
||||
@@ -273,7 +273,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
Entry: entryVia(calls.Call), Send: sendVia(calls.CallKeptAsk),
|
||||
Unreleased: reserved.unreleasedWords, Logf: logger.Printf,
|
||||
Holders: holders, // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a)
|
||||
Started: time.Now()} // a build ended from now on is of the live class, sent first (H-A-290 (1))
|
||||
Started: time.Now()} // a build ended from now on is of the live class (H-A-290 (1))
|
||||
// A number a registry seat already holds is never reserved (H-A-275): read before reserving, through the seats' verb versions.
|
||||
reserved.r.HeldNumbers = func(ctx context.Context, module, fp string, refs []string) ([]string, error) {
|
||||
return republish.HeldNumbers(ctx, module, fp, refs, registryVersionsVia(calls.Call))
|
||||
@@ -328,9 +328,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
acts.PublishDrop = func(ctx context.Context, module, version, by, why string) (string, error) {
|
||||
return pq.drop(ctx, items, module, version, by, why)
|
||||
}
|
||||
acts.PublishFirst = func(ctx context.Context, module, version, _, _ string) (string, error) {
|
||||
return pq.first(ctx, items, module, version)
|
||||
}
|
||||
// builder_reserve_done: a done trunk build that reserved none is given a version, and its publish queued as publish again does.
|
||||
acts.ReserveDone = reserveDoneAct(b.ReserveDone, republish.Republish, logger.Printf)
|
||||
// The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel.
|
||||
|
||||
+4
-4
@@ -33,8 +33,8 @@ import (
|
||||
// its pause behind an item put meanwhile, and a dropped item never comes back; 100 again items and a live one put while the
|
||||
// builder was away are all sent, the dropped one never, and put again within the duplicates window it is not stored; the move
|
||||
// of the old state run twice puts each item once, and the builder removes the old state's bucket itself (H-A-461 (1)). The seat
|
||||
// mesh-builds' verb publish-queue reads the stream: counts per holder and class, the oldest and newest, the live item listed
|
||||
// first (H-A-454). Then §796's tag at another commit, its reservation's version-reserved waited on by name (§821), and §794's
|
||||
// mesh-builds' verb publish-queue reads the stream: counts per holder and class, the oldest and newest, the items listed in
|
||||
// stream order (H-A-454; H-A-483, third addendum). Then §796's tag at another commit, its reservation's version-reserved waited on by name (§821), and §794's
|
||||
// backlog held six minutes, as steps (H-A-453 (3)).
|
||||
func TestThePublishQueueLosesNoItemAndNeverSendsADroppedItem(t *testing.T) {
|
||||
b := startBed(t)
|
||||
@@ -242,8 +242,8 @@ func TestThePublishQueueLosesNoItemAndNeverSendsADroppedItem(t *testing.T) {
|
||||
raw, err := publishQueueVerb(ctx, pq)("op@node", json.RawMessage(`{}`))
|
||||
if a, ok := raw.(meshbuilds.PublishQueueAnswer); err != nil || !ok || a.Total != 101 || len(a.Counts) != 2 || a.Counts[0].Class != versions.PublishClassStart ||
|
||||
a.Counts[0].Count != 100 || a.Counts[1].Count != 1 || a.Counts[0].Oldest.After(a.Counts[0].Newest) || len(a.Queue) != versions.PublishQueueListCap ||
|
||||
a.Queue[0].Module != "live" || a.Capped {
|
||||
t.Errorf("publish-queue answered %+v (%v), want 101 items, oci's 100 again and 1 live, fifty listed, the live first", raw, err)
|
||||
a.Queue[0].Module != "a000" || a.Capped {
|
||||
t.Errorf("publish-queue answered %+v (%v), want 101 items, oci's 100 again and 1 live, fifty listed in stream order, a000 first", raw, err)
|
||||
}
|
||||
if err := pq.learnAll(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -616,8 +615,15 @@ func (pq *publishQueue) learnAll(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// learn starts holder's pull once.
|
||||
// learn starts holder's pull once. A holder is a module name, so one ending in -live or -again, the class durables an earlier
|
||||
// release made, is refused, said (H-A-483, third addendum): its consumer would be another holder's old durable.
|
||||
func (pq *publishQueue) learn(ctx context.Context, holder string) {
|
||||
for _, class := range []string{versions.PublishClassLive, versions.PublishClassStart} {
|
||||
if strings.HasSuffix(holder, "-"+class) {
|
||||
pq.logf("the publishes of %s are refused: a holder is a module name, and one ending in -%s names the class durable of an earlier release (H-A-483)", holder, class)
|
||||
return
|
||||
}
|
||||
}
|
||||
pq.mu.Lock()
|
||||
if pq.pulling == nil {
|
||||
pq.pulling = map[string]bool{}
|
||||
@@ -804,45 +810,6 @@ func (pq *publishQueue) drop(ctx context.Context, items *publishItems, module, v
|
||||
return fmt.Sprintf("the publish of %s %s is dropped: %d items terminated, and none is sent or put again", module, version, len(qs)), nil
|
||||
}
|
||||
|
||||
// first is builder_publish_first (§793): each again item of the version is put again as live, under the message id
|
||||
// `<holder>.live.<module>.<version>`, and the old terminated; a live id the queue holds within its window takes nothing, and the
|
||||
// old stays, said.
|
||||
func (pq *publishQueue) first(ctx context.Context, items *publishItems, module, version string) (string, error) {
|
||||
qs, st, err := pq.itemsOf(ctx, module, version, versions.PublishClassStart)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("the work queue %s cannot be read: %w", versions.PublishesLocal, err)
|
||||
}
|
||||
if len(qs) == 0 {
|
||||
return "", fmt.Errorf("the work queue %s holds no again item of %s %s", versions.PublishesLocal, module, version)
|
||||
}
|
||||
var moved, kept []string
|
||||
for subj, q := range qs {
|
||||
q.Class = versions.PublishClassLive
|
||||
dup, err := pq.put(ctx, q)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s %s is not put again as live at %s: %w", module, version, q.Holder, err)
|
||||
}
|
||||
if dup {
|
||||
kept = append(kept, q.Holder)
|
||||
continue
|
||||
}
|
||||
if err := st.Purge(ctx, jetstream.WithPurgeSubject(subj)); err != nil {
|
||||
return "", fmt.Errorf("the again item of %s %s at %s is not terminated: %w", module, version, q.Holder, err)
|
||||
}
|
||||
moved = append(moved, q.Holder)
|
||||
}
|
||||
for _, h := range items.settle(module, version, func(h heldItem) bool { return h.q.Class == versions.PublishClassStart }) {
|
||||
_ = h.m.Term()
|
||||
}
|
||||
sort.Strings(moved)
|
||||
answer := fmt.Sprintf("%s %s is put first as live at %s, its again item terminated", module, version, strings.Join(moved, ", "))
|
||||
if len(kept) > 0 {
|
||||
sort.Strings(kept)
|
||||
answer += fmt.Sprintf("; at %s the work queue holds its live id within the duplicates window, so its again item stays", strings.Join(kept, ", "))
|
||||
}
|
||||
return answer, nil
|
||||
}
|
||||
|
||||
// endItem writes the version's publish item ended with answer, made when none stands: Try and take then leave it, and a start
|
||||
// asks it no more.
|
||||
func (p *publishItems) endItem(ctx context.Context, module, version, answer string) error {
|
||||
|
||||
@@ -440,3 +440,17 @@ func TestAPublishIsNotAskedAgainWhileItsPublishedMayBeUnheard(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-483 (third addendum): a holder is a module name, so one ending in -live or -again, the class durables of an
|
||||
// earlier release, is refused at the learn, said, and nothing of it is pulled.
|
||||
func TestAHolderNamedLikeAClassDurableIsRefused(t *testing.T) {
|
||||
for _, holder := range []string{"oci-live", "oci-again"} {
|
||||
var said []string
|
||||
pq := &publishQueue{logf: func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) },
|
||||
binding: func() (publishesStream, error) { return publishesStream{}, errors.New("no bus in a unit test") }}
|
||||
pq.learn(context.Background(), holder)
|
||||
if len(said) != 1 || !strings.Contains(said[0], "the publishes of "+holder+" are refused") || pq.pulling[holder] {
|
||||
t.Errorf("%s: said %q, pulling %v, want it refused at the learn, said once, nothing pulled", holder, said, pq.pulling[holder])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, items *publi
|
||||
released(ctx, b, kv, e, r, logf)
|
||||
return
|
||||
}
|
||||
if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModePublishFirst || r.Mode == build.ModeFloorAgain || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone {
|
||||
if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeFloorAgain || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone {
|
||||
// A version's hand act (design 51 *Tools of the builder*) may build again, so it is answered beside the watch.
|
||||
go versionActed(ctx, acts, kv, e, r, logf)
|
||||
return
|
||||
@@ -208,11 +208,8 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue
|
||||
r.Answer = "queued " + fmt.Sprint(len(r.Queued)) + " versions to publish again: " + strings.Join(r.Queued, ", ") + "; builder_publish_queue shows them"
|
||||
}
|
||||
}
|
||||
} else if r.Mode == build.ModePublishDrop || r.Mode == build.ModePublishFirst {
|
||||
} else if r.Mode == build.ModePublishDrop {
|
||||
act := acts.PublishDrop
|
||||
if r.Mode == build.ModePublishFirst {
|
||||
act = acts.PublishFirst
|
||||
}
|
||||
if act == nil {
|
||||
err = errors.New("this builder keeps no work queue of publishes")
|
||||
} else {
|
||||
|
||||
@@ -74,14 +74,11 @@ const ModePublish = "publish"
|
||||
// optional, name what to publish again; the builder answers with the versions it queued (Queued).
|
||||
const ModeRepublish = "republish"
|
||||
|
||||
// ModePublishDrop and ModePublishFirst are the Modes of a reasks value of builder_publish_drop and builder_publish_first (design
|
||||
// 47 H2 §793): Module and Version name the item; the builder terminates it, or puts it again as live and terminates the old.
|
||||
const (
|
||||
ModePublishDrop = "publish-drop"
|
||||
ModePublishFirst = "publish-first"
|
||||
)
|
||||
// ModePublishDrop is the Mode of a reasks value of builder_publish_drop (design 47 H2 §793): Module and Version name the item;
|
||||
// the builder terminates it.
|
||||
const ModePublishDrop = "publish-drop"
|
||||
|
||||
// NewPublishAct is the value builder_publish_drop (mode ModePublishDrop) or builder_publish_first (ModePublishFirst) writes
|
||||
// NewPublishAct is the value builder_publish_drop (mode ModePublishDrop) writes
|
||||
// (§793): its key, `<mode>.<unix nanoseconds>` (a call is one value), and the value. Module, version and why are required.
|
||||
func NewPublishAct(mode, module, version, why, by string, at time.Time) (string, []byte, error) {
|
||||
module, version = strings.TrimSpace(module), strings.TrimSpace(version)
|
||||
|
||||
@@ -27,10 +27,8 @@ type Acts struct {
|
||||
ReserveDone func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error)
|
||||
// DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not.
|
||||
DropReserved func(ctx context.Context, module, series, by, why string, at time.Time) (string, error)
|
||||
// PublishDrop terminates one publish item, and PublishFirst puts it again as live and terminates the old (builder_publish_drop,
|
||||
// builder_publish_first, design 47 H2 §793): the answer, or why not.
|
||||
PublishDrop func(ctx context.Context, module, version, by, why string) (string, error)
|
||||
PublishFirst func(ctx context.Context, module, version, by, why string) (string, error)
|
||||
// PublishDrop terminates one publish item (builder_publish_drop, design 47 H2 §793): the answer, or why not.
|
||||
PublishDrop func(ctx context.Context, module, version, by, why string) (string, error)
|
||||
}
|
||||
|
||||
// FloorAgain is builder_floor_again of name: refused, since the builder numbers nothing of its own and no claim asks a floor
|
||||
|
||||
@@ -37,9 +37,8 @@ const (
|
||||
PublishQueueTool = "builder_publish_queue"
|
||||
// QueueFull is what version-unreleased says of a version the work queue's cap refused.
|
||||
QueueFull = "queue full"
|
||||
// PublishDropTool and PublishFirstTool are builder_publish_drop and builder_publish_first (§793).
|
||||
PublishDropTool = "builder_publish_drop"
|
||||
PublishFirstTool = "builder_publish_first"
|
||||
// PublishDropTool is builder_publish_drop (§793); builder_publish_first is retired (H-A-483, third addendum).
|
||||
PublishDropTool = "builder_publish_drop"
|
||||
// NotStoredWords opens what a refused artifact is said as.
|
||||
NotStoredWords = "not stored: "
|
||||
// VerbPublish is the registry seats' verb a publish again sends, VerbVersions the one whose record says what a seat holds
|
||||
@@ -97,21 +96,19 @@ type QueuedPublish struct {
|
||||
Class string `json:"class,omitempty"`
|
||||
}
|
||||
|
||||
// rank is the place of q's class in a holder's queue: the live first.
|
||||
func (q QueuedPublish) rank() int {
|
||||
if q.Class == PublishClassLive {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
// sortQueued sorts a holder's queued versions in the order they are sent: the live class first, each class oldest first.
|
||||
func sortQueued(qs []QueuedPublish) {
|
||||
sort.SliceStable(qs, func(i, j int) bool {
|
||||
if a, b := qs[i].rank(), qs[j].rank(); a != b {
|
||||
// streamOrder sorts the keys of the work queue's items in stream order: each key is its item's stream sequence (the builder's
|
||||
// reader, publishitem.go), compared as a number; a key that is no number sorts after them by its words.
|
||||
func streamOrder(keys []string) {
|
||||
sort.SliceStable(keys, func(i, j int) bool {
|
||||
a, aerr := strconv.ParseUint(keys[i], 10, 64)
|
||||
b, berr := strconv.ParseUint(keys[j], 10, 64)
|
||||
switch {
|
||||
case aerr == nil && berr == nil:
|
||||
return a < b
|
||||
case aerr == nil || berr == nil:
|
||||
return aerr == nil
|
||||
}
|
||||
return qs[i].Queued.Before(qs[j].Queued)
|
||||
return keys[i] < keys[j]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -456,7 +453,7 @@ func (r *Republisher) Republish(ctx context.Context, module, version string) ([]
|
||||
type Queued struct {
|
||||
Total int `json:"total"`
|
||||
Counts []QueueCount `json:"counts"`
|
||||
// Queue are the first queued versions, per holder in the order they are sent (the live class first, each class oldest first);
|
||||
// Queue are the first queued versions, in stream order, the order each holder's one consumer gives them (H-A-483);
|
||||
// with a module named, only that module's.
|
||||
Queue []QueuedPublish `json:"queue"`
|
||||
// Listed says how many of Total the answer lists.
|
||||
@@ -512,7 +509,8 @@ func PublishItemKey(module, version string) string {
|
||||
|
||||
// PublishQueueOf is the seat mesh-builds' verb publish-queue (design 47 H2 §793; H-A-454): the builder's read of its own work queue
|
||||
// publishes (queue, its items read in bulk, capped past its bound), small at any size of the queue (H-A-290 (5)): the items' count
|
||||
// per holder and class with the oldest and newest queue time, and the first PublishQueueListCap in the order they are sent; module
|
||||
// per holder and class with the oldest and newest queue time, and the first PublishQueueListCap in stream order, the order the
|
||||
// holder's one consumer gives them (H-A-483, third addendum); module
|
||||
// (and version) narrow the list to one module's (one version's), so an item's class can be read.
|
||||
func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQueueAnswer, error) {
|
||||
out := meshbuilds.PublishQueueAnswer{Counts: []meshbuilds.PublishQueueAnswerCountsItem{}, Queue: []meshbuilds.PublishQueueAnswerQueueItem{}}
|
||||
@@ -525,7 +523,13 @@ func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQue
|
||||
}
|
||||
counts := map[[2]string]*meshbuilds.PublishQueueAnswerCountsItem{}
|
||||
var listed []QueuedPublish
|
||||
for _, raw := range vals {
|
||||
keys := make([]string, 0, len(vals))
|
||||
for k := range vals {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
streamOrder(keys)
|
||||
for _, k := range keys {
|
||||
raw := vals[k]
|
||||
var q QueuedPublish
|
||||
if json.Unmarshal(raw, &q) != nil {
|
||||
continue
|
||||
@@ -559,25 +563,12 @@ func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQue
|
||||
}
|
||||
return out.Counts[i].Class < out.Counts[j].Class
|
||||
})
|
||||
sort.SliceStable(listed, func(i, j int) bool { return listed[i].Holder < listed[j].Holder })
|
||||
byHolder := map[string][]QueuedPublish{}
|
||||
var holders []string
|
||||
for _, q := range listed {
|
||||
if byHolder[q.Holder] == nil {
|
||||
holders = append(holders, q.Holder)
|
||||
}
|
||||
byHolder[q.Holder] = append(byHolder[q.Holder], q)
|
||||
}
|
||||
for _, h := range holders {
|
||||
qs := byHolder[h]
|
||||
sortQueued(qs)
|
||||
for _, q := range qs {
|
||||
if len(out.Queue) == PublishQueueListCap {
|
||||
break
|
||||
}
|
||||
out.Queue = append(out.Queue, meshbuilds.PublishQueueAnswerQueueItem{Holder: q.Holder, Module: q.Module, Version: q.Version,
|
||||
Class: q.Class, Artifacts: q.Artifacts, Queued: q.Queued})
|
||||
if len(out.Queue) == PublishQueueListCap {
|
||||
break
|
||||
}
|
||||
out.Queue = append(out.Queue, meshbuilds.PublishQueueAnswerQueueItem{Holder: q.Holder, Module: q.Module, Version: q.Version,
|
||||
Class: q.Class, Artifacts: q.Artifacts, Queued: q.Queued})
|
||||
}
|
||||
out.Listed = int64(len(out.Queue))
|
||||
return out, nil
|
||||
@@ -631,20 +622,17 @@ func AnswerQueue(q meshbuilds.PublishQueueAnswer, acted, reasks Reader) (Queued,
|
||||
|
||||
// PublishQueueDescription is builder_publish_queue's description.
|
||||
const PublishQueueDescription = "The versions the builder will publish again (its work queue " + PublishesLocal + ", design 47 G section 588, H2 section 793): " +
|
||||
"how many each registry seat holder's items hold per class (live, a build a pipeline's step waits on, pulled first, or again, asked again at a start) " +
|
||||
"with the oldest and newest queue time; the first 50 in the order they are pulled, each with its class, its artifacts' digests and when it was " +
|
||||
"how many each registry seat holder's items hold per class (live, a build a pipeline's step waits on, or again, asked again at a start) " +
|
||||
"with the oldest and newest queue time; the first 50 in stream order, the order each holder's one consumer pulls them, each with its class, its artifacts' digests and when it was " +
|
||||
"queued (module, and version, list only that module's, so one item's class can be read); the keys of the state " + ActedState + ", the last stream " +
|
||||
"sequence the builder acted on for each subject; and the publish items (design 47 G A-457a), counted, the first 50 by next try, each version's " +
|
||||
"tries and next try, and why one ended (its tries spent, or dropped). A read past its pages is answered capped, naming the items read and the " +
|
||||
"queue's size (H-A-293). Read-only."
|
||||
|
||||
// PublishDropDescription and PublishFirstDescription are builder_publish_drop's and builder_publish_first's (§793).
|
||||
// PublishDropDescription is builder_publish_drop's (§793).
|
||||
const PublishDropDescription = "Drop one version's publish (design 47 H2 section 793): its items on the work queue " + PublishesLocal + " are " +
|
||||
"terminated at every holder, and its publish item ended with who dropped it and why, so it is never sent or put again; builder_publish_again " +
|
||||
"asks it anew. A hand act, recorded in the hand-act log first."
|
||||
const PublishFirstDescription = "Put one version's publish first (design 47 H2 section 793): each of its again items on the work queue " +
|
||||
PublishesLocal + " is put again as live, under the message id <holder>.live.<module>.<version>, pulled before every again item, and the old " +
|
||||
"terminated. A hand act, recorded in the hand-act log first."
|
||||
|
||||
// PublishAgainDescription is builder_publish_again's description.
|
||||
const PublishAgainDescription = "Publish reserved versions again (design 47 G section 588), which builds nothing: with module and version, that reserved " +
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -404,8 +405,9 @@ func answerOf(queue, acted, reasks Reader, module, version string) (Queued, erro
|
||||
}
|
||||
|
||||
// TestThePublishQueueToolAnswersAtAnySize: design 47 H H-A-290 (5) — builder_publish_queue over two thousand queued versions answers
|
||||
// within a second and small: counts per holder and class with the oldest and newest queue time, a list capped at fifty in the
|
||||
// order they are sent, and one module's item with its class; each state read in bulk where the reader can.
|
||||
// within a second and small: counts per holder and class with the oldest and newest queue time, a list capped at fifty in stream
|
||||
// order (H-A-483, third addendum: each key is its item's stream sequence), and one module's item with its class; each state read
|
||||
// in bulk where the reader can.
|
||||
func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||
at := time.Date(2026, 11, 20, 17, 0, 0, 0, time.UTC)
|
||||
vals := map[string]json.RawMessage{}
|
||||
@@ -418,7 +420,7 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||
class = PublishClassLive
|
||||
}
|
||||
q := QueuedPublish{V: 1, Holder: holder, Module: fmt.Sprintf("m%d", i), Version: "0.1.0", Artifacts: map[string]string{"a": "sha256:aa"}, Queued: at.Add(time.Duration(i) * time.Second), Class: class}
|
||||
vals[QueueKey(holder, q.Module, q.Version)], _ = json.Marshal(q)
|
||||
vals[strconv.Itoa(i+1)], _ = json.Marshal(q) // the reader keys each item by its stream sequence
|
||||
}
|
||||
gets := 0
|
||||
queue := Reader{All: func() (StatePage, error) { return StatePage{Values: vals}, nil },
|
||||
@@ -435,8 +437,10 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||
if fmt.Sprintln(a.Counts[1].Holder, a.Counts[1].Class, a.Counts[1].Count, a.Counts[1].Oldest.Equal(at.Add(1991*time.Second)), a.Counts[1].Newest.Equal(at.Add(1999*time.Second))) != "go "+PublishClassLive+" 5 true true\n" || len(a.Counts) != 4 {
|
||||
t.Errorf("counts %+v, want per holder and class with their oldest and newest", a.Counts)
|
||||
}
|
||||
if a.Queue[0].Class != PublishClassLive || a.Queue[0].Holder != "go" {
|
||||
t.Errorf("the list opens with %+v, want the go holder's live class, sent first", a.Queue[0])
|
||||
for i, q := range a.Queue {
|
||||
if q.Module != fmt.Sprintf("m%d", i) {
|
||||
t.Fatalf("the list holds %s at %d, want m%d: the items in stream order, whatever their holder or class", q.Module, i, i)
|
||||
}
|
||||
}
|
||||
one, err := answerOf(queue, none, none, "m1995", "")
|
||||
if err != nil || len(one.Queue) != 1 || one.Queue[0].Class != PublishClassLive || one.Total != 2000 {
|
||||
|
||||
Reference in New Issue
Block a user