-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Deprecate and remove Job.cancel(cause) #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Job.cancel(cause)
After discussion with @LouisCAD I've found at least one use-case which is hard to workaround: external callback-based API working as parent/owner of the job. An example may be found here. Workaround without |
It's worth noting that the use case shown above uses
That may be a good thing since doing so with a If anyone uses |
@elizarov I have read the issue you linked thoroughly, and I agree on merging the failed state into the cancelled state, makes it easier to reason about. However, you are talking about replacing BTW, I think all these changes should appear in the same release to allow "one shot" migration. |
@elizarov note that IMO having |
Job.cancel(any exception)
is a cumbersome API:cancel(cause)
can returntrue
more than once for the sake of exception handling)cancel
can returnfalse
, forcing a user to handle an exception on the callsite anywayAs for implementation, it complicates
Job
exception handling a lot and has a lot of maintenance burden as opposed toJob.cancel()
orJob.cancel(message: String)
We can remove
cancel(cause)
from public API and move it toattachChild
machinery (e.g. by introducingParentHandle
instead ofDisposableHandle
).It should make parent-child communication (-> cancellation and exception handling) much simpler and open a door for state machine optimizations.
If someone has a use-case which cannot be reasonably implemented without cancellation with a custom exception, let's discuss it here.
The text was updated successfully, but these errors were encountered: