Close immediate channel after writing to it to close wait group in merge logic
This commit is contained in:
parent
9794808333
commit
aa98f85e9d
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- [#483](https://github.com/XenitAB/spegel/pull/483) Update errcheck linter configuration and fix errors.
|
||||
- [#487](https://github.com/XenitAB/spegel/pull/487) Move mirror metrics code to mirror handler.
|
||||
- [#488](https://github.com/XenitAB/spegel/pull/488) Update existing registry errors and add more detail.
|
||||
- [#490](https://github.com/XenitAB/spegel/pull/490) Close immediate channel after writing to it to close wait group in merge logic.
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
@ -20,16 +20,17 @@ func Track(ctx context.Context, ociClient oci.Client, router routing.Router, res
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
immediate := make(chan time.Time, 1)
|
||||
immediate <- time.Now()
|
||||
immediateCh := make(chan time.Time, 1)
|
||||
immediateCh <- time.Now()
|
||||
close(immediateCh)
|
||||
expirationTicker := time.NewTicker(routing.KeyTTL - time.Minute)
|
||||
defer expirationTicker.Stop()
|
||||
ticker := channel.Merge(immediate, expirationTicker.C)
|
||||
tickerCh := channel.Merge(immediateCh, expirationTicker.C)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-ticker:
|
||||
case <-tickerCh:
|
||||
log.Info("running scheduled image state update")
|
||||
if err := all(ctx, ociClient, router, resolveLatestTag); err != nil {
|
||||
log.Error(err, "received errors when updating all images")
|
||||
|
Loading…
x
Reference in New Issue
Block a user