Skip to content

See if it makes sense to reimplement cmd.token-push.getScheddsAndCollectorHostFromConfiguration with a singleflight.Group #122

@shreyb

Description

@shreyb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions