Description
The current state of affairs
There’s some messiness in the API for determining Job
states, which boils down mainly to the following two things:
-
there’s no clear distinction between a failure and a cancellation of a
Job
. Everything is too blurred in that context. Hence it’s difficult to reason about things. -
the
isCompleted
property is for determining if aJob
has finished for whatever reason. But at the same time, theCompleted
state is solely for a successful finish (not also for a failure or a cancellation). Hence a contradiction.
The proposed state of affairs
For the sake of good order, everything has been implemented in the following way (or something along these lines):
-
the
isCompleted
property returnstrue
solely if theJob
has finished successfully (not also when it has failed or has been cancelled). Consequently, theCompleted
state represents solely such situations. -
the
isFailed
property returnstrue
if theJob
is failing / has failed. Consequently, theFailing
/Failed
states represent such situations. In addition to that, thefail
function replacescompleteExceptionally
. -
the
isCancelled
property returnstrue
solely if theJob
is being cancelled / has been cancelled (not also when it is being failed / has been failed). Consequently, theCancelling
/Cancelled
states represent solely such situations. -
the
isFailedOrCancelled
property returnstrue
ifisFailed
orisCancelled
returns true. -
the
isFinished
property returnstrue
ifisCompleted
orisFailed
orisCancelled
returns true.