go-pmtiles icon indicating copy to clipboard operation
go-pmtiles copied to clipboard

Make pmtiles.Extract(...) cancellable with own context

Open marcogerstmann opened this issue 3 months ago • 2 comments

Hi, we are calling pmtiles.Extract() in our Go service and need the possibility to cancel the currently running extraction. For this we would like to be able to pass our own context to the method.

marcogerstmann avatar Sep 26 '25 07:09 marcogerstmann

Do you just want to pass in a Context to Extract instead of using context.Background ?

bdon avatar Sep 30 '25 03:09 bdon

Yes, because I want to be able to cancel a running extraction when I get a new request for an extraction in my Go service, which make the currently running extraction obsolete. What I am doing currently is to run the binary of go-pmtiles in a exec.CommandContext(), so that it runs in a process that I can entirely kill, so that this process can't occupy resources anymore.

Ideally I am able to use pmtiles.Extract() with a context I can create myself, like context.WithCancel(context.Background()), instead of calling a binary from my Go code.

This would of course imply that the current usage of context in pmtiles.Extract() is making use of the context in all meaningful places that should be cancellable.

marcogerstmann avatar Sep 30 '25 05:09 marcogerstmann