Skip to content

The API for determining Job states is a bit messy #2087

Open
@taras-i-fedyk

Description

@taras-i-fedyk

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 a Job has finished for whatever reason. But at the same time, the Completed 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 returns true solely if the Job has finished successfully (not also when it has failed or has been cancelled). Consequently, the Completed state represents solely such situations.

  • the isFailed property returns true if the Job is failing / has failed. Consequently, the Failing / Failed states represent such situations. In addition to that, the fail function replaces completeExceptionally.

  • the isCancelled property returns true solely if the Job is being cancelled / has been cancelled (not also when it is being failed / has been failed). Consequently, the Cancelling / Cancelled states represent solely such situations.

  • the isFailedOrCancelled property returns true if isFailed or isCancelled returns true.

  • the isFinished property returns true if isCompleted or isFailed or isCancelled returns true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions