|
func getScheddsAndCollectorHostFromConfiguration(ctx context.Context, checkServiceConfigPath string) (string, []string, error) { |
Singleflight (https://pkg.go.dev/golang.org/x/sync/singleflight), maintained by the Go developers, allows us to only run things once. As this talk illustrates (https://www.youtube.com/watch?v=y2zc9gvIMPM&list=PLtoVuM73AmsJWvXYd_9rbYXcbv1UdzeLT&index=8), it works well for concurrent cache access, when the values are used more than once, and concurrently.
Right now, getScheddsAndCollectorHostFromConfiguration is implemented using a global cache, which in turn has access synchronized using a sync.Once and a sync.Mutex. It might be worth seeing if using singleflight makes the implementation easier.
managed-tokens/cmd/token-push/config.go
Line 166 in 1223767
Singleflight (https://pkg.go.dev/golang.org/x/sync/singleflight), maintained by the Go developers, allows us to only run things once. As this talk illustrates (https://www.youtube.com/watch?v=y2zc9gvIMPM&list=PLtoVuM73AmsJWvXYd_9rbYXcbv1UdzeLT&index=8), it works well for concurrent cache access, when the values are used more than once, and concurrently.
Right now,
getScheddsAndCollectorHostFromConfigurationis implemented using a global cache, which in turn has access synchronized using async.Onceand async.Mutex. It might be worth seeing if usingsingleflightmakes the implementation easier.