package host import ( "context" "github.com/carlosframework/platform/internal/hostbox" "github.com/carlosframework/platform/internal/hostclaim" execlease "github.com/carlosframework/platform/internal/hostexec" "github.com/carlosframework/platform/internal/rootparticipation" "github.com/carlosframework/platform/internal/rootstate" ) func rootExecutionRead(ctx context.Context, c *hostclaim.Claim) (execlease.ExecutionRecord, error) { return readRootExecution(ctx, nil, execlease.SystemClock{}, c) } func (h *ClaimLaunchRoot) readExecution(ctx context.Context, c *hostclaim.Claim) (execlease.ExecutionRecord, error) { return readRootExecution(ctx, h.executionState, h.Clock, c) } func readRootExecution(ctx context.Context, store rootstate.Store, clock execlease.Clock, c *hostclaim.Claim) (execlease.ExecutionRecord, error) { if c == nil || c.Holder == nil { return execlease.ExecutionRecord{}, execlease.ErrState } if store == nil { var err error store, err = rootstate.Open(rootparticipation.Namespace, false, false) if err != nil { return execlease.ExecutionRecord{}, err } defer store.Close() } q := execlease.ExecutionRequest{Host: c.Host, Incarnation: c.Holder.Incarnation, Stamp: c.Holder.Stamp, Session: c.Holder.Session, Op: c.Op.ID} return execlease.ReadRoot(ctx, store, clock, q, c.Op.Kind == hostclaim.KindServing) } func (p *productionClaimLocal) checkRootParticipation(ctx context.Context, actor hostbox.Actor, c *hostclaim.Claim) error { read := p.executionRead if read == nil { read = rootExecutionRead } r, err := read(ctx, c) if err != nil { return err } if c == nil || c.Holder == nil { return execlease.ErrState } if c.Op.Kind != hostclaim.KindServing && (r.Authority.Box != actor.Box || r.Authority.Enrollment != actor.Enrollment) { return execlease.ErrLost } return nil }