H-A-458 (3): bind the taken write by the compose call's own context
The state taken's write was bound by a five-second bound of its own, whatever the ask's deadline, so an ask whose caller had gone could still be kept, and its repeat refused. takenWithin goes: Env.Taken carries the compose call's context, Session.TakeOnce binds the state with it and keeps nothing once it ended. Row: a take whose context ended is refused, and the same id is then taken the first time. Review round 1, finding: the taken bound. Builds: design 47 H2 §775; H-A-364 (a), H-A-458 (3)
This commit is contained in:
@@ -159,7 +159,7 @@ func (s *Shadow) ComposeCandidate(ctx context.Context, ask nodeengine.ComposeCan
|
||||
a, joined := s.asked.once(ctx, id, func() nodeengine.ComposeCandidateAnswer {
|
||||
took := ""
|
||||
if c.env.Taken != nil {
|
||||
switch first, err := c.env.Taken(nodeengine.Seat, id, c.composeAskBound()); {
|
||||
switch first, err := c.env.Taken(ctx, nodeengine.Seat, id, c.composeAskBound()); {
|
||||
case err != nil:
|
||||
took = fmt.Sprintf(", not kept in taken: %v", err)
|
||||
case !first:
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestTheNodeComposesACandidateOnAsk(t *testing.T) {
|
||||
// Design 47 H2 §775, H-A-364: an ask with an id is taken once in the state taken, for compose-ask-bound.
|
||||
var takes []string
|
||||
taken := map[string]bool{}
|
||||
env.Taken = func(seat, ask string, bound time.Duration) (bool, error) {
|
||||
env.Taken = func(_ context.Context, seat, ask string, bound time.Duration) (bool, error) {
|
||||
takes = append(takes, seat+"."+ask+" "+bound.String())
|
||||
first := !taken[ask]
|
||||
taken[ask] = true
|
||||
|
||||
@@ -154,8 +154,9 @@ type Env struct {
|
||||
// (design 08 control-verbs §1, H-A-314 (5)).
|
||||
ComposeAskBound time.Duration
|
||||
// Taken takes an ask of the seat seat once by its id (design 47 H2 §775, H-A-364 (a)): kept in the node-engine's state
|
||||
// `taken` under `<seat>.<ask>` for bound; false when it was taken before. Nil keeps nothing.
|
||||
Taken func(seat, ask string, bound time.Duration) (bool, error)
|
||||
// `taken` under `<seat>.<ask>` for bound; false when it was taken before. Nil keeps nothing. Its write is bound by ctx,
|
||||
// the compose call's own (H-A-458 (3)).
|
||||
Taken func(ctx context.Context, seat, ask string, bound time.Duration) (bool, error)
|
||||
// Registry asks the registry seats' verb versions (oci-artifact-registry, container-image-registry) in the engine's own
|
||||
// name: a want naming its version is resolved to its artifacts' digests through it (design 47 G A-430a).
|
||||
Registry meshcatalogclient.Call
|
||||
|
||||
Reference in New Issue
Block a user