Files
mesh-delivery/modules/mesh-delivery-builder/internal/build/drop.go
T
jschoubben 905a055a1e B2: the builder serves the seat mesh-builds' drop and its queue's tools
A caller whose step ended by its bound could not stop the builder working on
its ask, and nobody could see what waited on the seat's work queue. The
builder now serves the seat's verb drop: an ask it runs is cancelled, one not
pulled yet is kept dropped in its state taken (dropped.<ask>, for
ask-taken-bound); both end the step could-not-run naming the drop and who
asked it. builder_asks reads the waiting asks through the runtime and the
taken ones and the drops from the state taken; builder_ask_drop asks the
seat's drop once the hand act is recorded.

Builds: design 47 H2 §777, §778; H-A-401, H-A-404, H-A-410
2026-11-22 01:08:30 +01:00

49 lines
1.6 KiB
Go

package build
import (
"context"
"errors"
"fmt"
)
// **A dropped ask ends its step could-not-run, naming the drop** (design 47 H2 §777, §778; H-A-401, H-A-404; ADR 0664 §4):
// the seat mesh-builds' drop ends an ask its caller no longer waits for. A taken ask that runs is cancelled with a Dropped
// cause; one not pulled yet is kept in the state taken under DroppedKey, and its pull ends it the same way. Either way the
// build step's finish answers it could-not-run with Dropped's words, so no build runs for it after.
// The tools of the seat's queue (§777's tools table): AsksTool reads what waits and what is taken, AskDropTool ends one
// ask through the seat's verb drop, the hand act recorded first.
const (
AsksTool = "builder_asks"
AskDropTool = "builder_ask_drop"
)
// DroppedPrefix is the key prefix in the state taken of a drop of an ask not pulled yet (H-A-404).
const DroppedPrefix = "dropped."
// DroppedKey is the key in the state taken of the drop of the ask id.
func DroppedKey(id string) string { return DroppedPrefix + id }
// Dropped is why a step's context was cancelled by the seat's verb drop, and the value its key keeps: who asked it and why.
type Dropped struct {
By string `json:"by,omitempty"`
Why string `json:"why"`
}
func (d *Dropped) Error() string {
by := d.By
if by == "" {
by = "its asker"
}
return fmt.Sprintf("the ask was dropped by %s through the seat mesh-builds' drop: %s", by, d.Why)
}
// DroppedOf is the drop that cancelled ctx, nil when none did.
func DroppedOf(ctx context.Context) *Dropped {
var d *Dropped
if errors.As(context.Cause(ctx), &d) {
return d
}
return nil
}