Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Context support #229

Closed
bkeroackdsc opened this issue Jul 17, 2020 · 5 comments
Closed

Context support #229

bkeroackdsc opened this issue Jul 17, 2020 · 5 comments

Comments

@bkeroackdsc
Copy link

What would you like to have changed?

Consider adding ...WithContext() functions/methods for long-running operations to allow cancellation by callers.

Example:

ArchiveWithContext(ctx context.Context, sources []string, destination string) error

This would allow cancellation without breaking API compatibility.

Internally, the implementation could (for example) check for context cancellation before/after each file is written (or read) to/from an archive and abort if the context is cancelled.

Why is this feature a useful, necessary, and/or important addition to this project?

Archiving/unarchiving in particular can be long-running operations. It would be useful to allow a cancellation/timeout mechanism for callers.

What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

There is no alternative currently, other than performing the long-running operation in a separate goroutine and then ignoring or throwing away the results if the caller cancelled and is no longer interested.

@mholt
Copy link
Owner

mholt commented Jul 17, 2020

Yeah, this would be good in a v4 rewrite. I would rather do that, considering all the open issues, than litter the API with a bunch of Context alternatives.

@ilyapashuk
Copy link

and also some kind of progress monitoring can be useful, for example with callbacks.

@s3rj1k
Copy link

s3rj1k commented Sep 27, 2021

@mholt Any progress on that, also interested in context support.
@bkeroackdsc Care to share an example of work around?

@bkeroackdsc
Copy link
Author

@s3rj1k the wrapper pattern, for example

@mholt
Copy link
Owner

mholt commented Jan 2, 2022

Done in #302, the v4 rewrite.

@mholt mholt closed this as completed Jan 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants