package console import ( "context" "time" "github.com/carlosframework/platform/internal/hostclaim" "github.com/carlosframework/platform/internal/hostops" ) // NewProductionWakeRetryReset selects the bucket protocol. ConfigureClaimRuntime // supplies the guarded stores and console authority before serving any requests. func NewProductionWakeRetryReset() *WakeRetryResetDoor { return &WakeRetryResetDoor{production: true} } func productionWakeRetryReset(a *hostops.ProductionAuthority) *WakeRetryResetDoor { transport := hostops.WakeResetTransport{Store: a.Store, Directory: a.Directory, Now: a.Now} return &WakeRetryResetDoor{production: true, Claims: a.Store, NewID: claimOperationID, Authority: func(ctx context.Context) error { return transport.Authority(ctx, a.ConsoleID, a.Enrollment, a.Namespace) }, StopAttempt: func(ctx context.Context, o hostclaim.Observed, attempt hostclaim.WakeRetryAttempt) error { request, err := a.Control.RequestWakeReset(ctx, transport, a.Signer, a.ConsoleID, a.Enrollment, a.Namespace, o, attempt) if err != nil { return err } err = transport.Wait(ctx, request, 250*time.Millisecond) if err != nil { cleanup, done := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) defer done() // This only closes future dispatch. A concurrent root stop may already // have happened; return the uncertain result and keep the claim intact. _ = a.Control.CancelWakeReset(cleanup, transport, a.Signer, request) } return err }, } }