prometheus icon indicating copy to clipboard operation
prometheus copied to clipboard

Why not make goroutine stoppable / cancellable?

Open afarbos opened this issue 2 years ago • 0 comments

Your Question

This library start multiple process without a way to stop them using the context.Context and/or a Finalize() / Close() function(s). Are there any reasons? Could this be added?

The document you expected this should be explained

I would expect every loop with goroutine to support context done, like:

select {
	case <-time.After(time.Duration(p.Config.RefreshInterval) * time.Second):
		// LOGIC
	case <-ctx.Done():
		return
}

And for the server to store it and expose the Close function.

Expected answer

Hopefully yes and I or someone else can do it.

afarbos avatar May 16 '22 16:05 afarbos