Give the execution lease to the composition root and the Worker - #312
Merged
Merged
Conversation
cmd/server acquires the execution lease and passes it, with the store execution writer built on it, to execution.StartWorker as an execution.Owner. The Worker owns cleanup from that call: a failed start closes the lease, and Run closes it after cancelling and draining. Store borrows the lease and no longer acquires, checks, cancels or closes it for execution. Store integration tests start the Worker through one startWorker helper and pass the fixtureDB that built their Store to publicHandler, so later cutovers change only the helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1 (store layering), foundation PR 1f. The composition root now owns the execution lease, and store tests get one fixture value to build adapters from.
Execution lease
execution.Owner{Lease, Store}andOwnership, which*pgunit.Leaseimplements.cmd/serveracquires the lease withpgunit.AcquireLeaseand passes the same pointer tostore.NewExecution(s, lease)and toexecution.StartWorker(ctx, dispatcher, owner).StartWorkertakes over the lease as soon as it is called. A failed start closes it exactly once, and a started Worker closes it afterRundrains. Each close gets its own bounded context.RunEnvironmentInput.CheckExecutionOwnership,CancelExecutionOperations,CloseExecution, and store's own lease acquisition.Store test harness
fixtureDB{pool, cipher}holds the pool and cipher each test's Store was built from.startWorkerandstartWorkerErrdo exactly whatcmd/serverdoes, and everyStartWorkersite uses them.publicHandler(t, s, db, keys, engine, …)takes the fixture at all 71 call sites. Later domain cutovers add their adapter inside the fixture without changing call sites.IMPLEMENTATION.mdrecords the composition and cleanup rule.Behaviour changes
AcquireLeasebefore it builds a Worker.Checks
go build ./...,go vet ./services/core/...,gofmt -l,scripts/check-names.pypersistence/...execution/...Runcloses it after drainingcmd/...sandbox/providers/...The 12 skips need a native daemon or opt-in large storage.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.