Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
polygon: astrid service to run inside bg components errgroup for shut…
…down wait (#13149) While working on Shutter, I decided to follow the same `Run(ctx)` pattern that we use in Astrid to initiate long running background goroutines which are ctx aware and do their own shutdown/cleanup logic as part of defers inside `Run(ctx)` so that when the parent ctx is cancelled each component with a Run manages its own shutdown logic. However, I noticed that when the `Ethereum.Close` function is called we do not wait for these `Run` functions of bg goroutines to finish before exiting the `Close` function. So I added a `bgComponentsEg` errgroup to the `Ethereum` object which is used in `Start` and `Close` to wait properly in the following Shutter PR https://github.com/erigontech/erigon/pull/13081/files#diff-9cc7046826ce92d9cc5432cf41ed4fc14bb6907da44f771e3932302c40e8dbc2R1640-R1643. This PR is to make a small change to `Ethereum.Start` to run the Astrid service `Run` bg goroutine as part of the same `bgComponentsEg` errgroup as well so that `Ethereum.Close` waits for it to finish its shutdown logic. This will also serve as a template for future bg components that use the `Run(ctx)` pattern.
- Loading branch information