Hive.Outcome

hive · API reference

Completion state shared by workers, tasks and supervisors.

The result of joining a finished unit of work.

Copied from Cats Effect's Outcome: supervisors and callers consult it to decide restarts and error handling.

type 'a t = 
  | Completed of 'a (* Finished normally with a value. *)
  | Failed of exn (* Terminated by an uncaught exception. *)
  | Cancelled (* Cancelled before completion (e.g. switch shutdown). *)
val map : ('a -> 'b) -> 'a t -> 'b t

map f o applies f to the value of a Completed outcome.

Failed and Cancelled pass through unchanged:

ocaml]
Hive.Outcome.map String.length (Hive.Outcome.Completed "ok")
= Hive.Outcome.Completed 2
val value : 'a t -> 'a option

value o is Some v iff o is Completed v.

val is_completed : _ t -> bool

true for Completed _.

val is_failed : _ t -> bool

true for Failed _.

val is_cancelled : _ t -> bool

true for Cancelled.