CAT-D3, D2: one mirror copy, said once; a refusal at the cap stays loud until the holder takes a publish again
A second tools process following mirrors would copy again and say published twice. The ask is claimed by compare-and-set before it is copied, and its outcome carries the ask's id as the event id, so a redelivery is one message. The cap's publish-refused finding stands on incoming, not on one file, and clears with the next publish taken. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -87,7 +89,7 @@ func (builderVersions) Recorded(name, version, digest string) (bool, string, err
|
||||
}
|
||||
|
||||
func say(seat, event string, body holder.Event) error {
|
||||
return stdio.SeatPublish("mesh.seat."+seat+".event."+event, eventBody(event, body), "")
|
||||
return stdio.SeatPublish("mesh.seat."+seat+".event."+event, eventBody(event, body), body.ID)
|
||||
}
|
||||
|
||||
func finding(kind, subject, words string, raised bool) {
|
||||
@@ -219,11 +221,22 @@ func (mirrors) Ask(key string, r holder.MirrorRequest) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mirrors) Claim(key string, r holder.MirrorRequest, revision uint64) (bool, error) {
|
||||
_, err := stdio.State(holder.MirrorsState).Update(key, r, revision)
|
||||
if errors.Is(err, stdio.ErrChanged) {
|
||||
return false, nil
|
||||
}
|
||||
return err == nil, err
|
||||
}
|
||||
func (mirrors) Delete(key string) error { return stdio.State(holder.MirrorsState).Delete(key) }
|
||||
|
||||
// followMirrors runs every copy `mirror` took on, on the state's watch: the asks kept when the bundle starts (a copy a
|
||||
// restart cut) and each new one, one at a time.
|
||||
// restart cut) and each new one, one at a time. Each is claimed first (Verbs.Take), so a second follower copies none
|
||||
// a first one took on.
|
||||
func followMirrors(v *holder.Verbs) {
|
||||
id := make([]byte, 8)
|
||||
_, _ = rand.Read(id)
|
||||
self := "distribution-tools-" + hex.EncodeToString(id)
|
||||
<-stdio.Served()
|
||||
stdio.State(holder.MirrorsState).Follow("", func(ch stdio.StateChange) error {
|
||||
if ch.Op != stdio.OpPut {
|
||||
@@ -234,7 +247,7 @@ func followMirrors(v *holder.Verbs) {
|
||||
logf("the mirror ask %s is no ask (%v): dropped", ch.Key, err)
|
||||
return stdio.State(holder.MirrorsState).Delete(ch.Key)
|
||||
}
|
||||
return v.Mirrored(r)
|
||||
return v.Take(ch.Key, r, ch.Revision, ch.Current, self)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user