Distribution: the incoming-full finding is said off the publish's path
Builds: design 47 G (publish path of oci-artifact-registry; no design line covers it)
This commit is contained in:
@@ -94,9 +94,25 @@ func boundedArm(a func(string, time.Duration) error) func(string, time.Duration)
|
||||
}
|
||||
}
|
||||
|
||||
// boundedFinding is the findings writer's say, bounded and logged: the receiver says the incoming fill through it on an open.
|
||||
// boundedFinding is the findings writer's say moved off the publish's path: the receiver says the incoming fill on every
|
||||
// open, and a publish never waits for it. One worker says them in order, each bounded and logged; one said while the worker
|
||||
// is full is dropped and logged (the next open says the fill again).
|
||||
func boundedFinding(f holder.Finding) holder.Finding {
|
||||
type said struct {
|
||||
kind, subject, words string
|
||||
raised bool
|
||||
}
|
||||
queue := make(chan said, 64)
|
||||
go func() {
|
||||
for s := range queue {
|
||||
_ = stepErr(stepBound, "the finding "+s.kind+" of "+s.subject, func() error { f(s.kind, s.subject, s.words, s.raised); return nil })
|
||||
}
|
||||
}()
|
||||
return func(kind, subject, words string, raised bool) {
|
||||
_ = stepErr(stepBound, "the finding "+kind+" of "+subject, func() error { f(kind, subject, words, raised); return nil })
|
||||
select {
|
||||
case queue <- said{kind, subject, words, raised}:
|
||||
default:
|
||||
logf("the finding %s of %s is not said now: the writer is behind, the next open says it again", kind, subject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,3 +18,17 @@ func TestAHungStepAnswersWithItsName(t *testing.T) {
|
||||
t.Fatalf("%d %v", v, err)
|
||||
}
|
||||
}
|
||||
|
||||
// The finding is said off the caller's path: a writer that never answers does not hold the call that says it.
|
||||
func TestAFindingIsSaidOffThePath(t *testing.T) {
|
||||
block := make(chan struct{})
|
||||
defer close(block)
|
||||
say := boundedFinding(func(string, string, string, bool) { <-block })
|
||||
done := make(chan struct{})
|
||||
go func() { say("incoming-full", "incoming", "w", false); say("incoming-full", "incoming", "w", false); close(done) }()
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the call was held by the finding")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user