fermitools / managed-tokens

Managed Tokens service for FIFE Experiments at Fermilab
Apache License 2.0
0 stars 0 forks source link

Replace scheddCollection caching with singleflight group? #41

Closed shreyb closed 1 year ago

shreyb commented 1 year ago

https://github.com/shreyb/managed-tokens/blob/c6d2e0e65fad52f68ab573e193870626a37f1325/internal/cmdUtils/cmdUtils.go#L130

I think this whole caching mechanism can be replaced by a singleflight.Do, where the key is the collectorHost.

Package documentation: https://pkg.go.dev/golang.org/x/sync/singleflight Helpful article: https://encore.dev/blog/advanced-go-concurrency#package-singleflight

shreyb commented 1 year ago

@retzkek pointed out to me that this package does not do what I think it does. Keeping things as is.