Oban.Job

oban · API reference

Describe and inspect durable work.

type id
val id_to_int64 : id -> int64
type queue
val parse_queue : 
  string ->
  (queue,
    [> `Empty_queue
    | `Invalid_queue_utf8
    | `Queue_contains_null
    | `Queue_too_long of int ])
    result

Parse non-empty UTF-8 without U+0000, bounded by Limits.max_name_bytes.

val queue_to_string : queue -> string
type worker_name
val parse_worker_name : 
  string ->
  (worker_name,
    [> `Empty_worker
    | `Invalid_worker_utf8
    | `Worker_contains_null
    | `Worker_too_long of int ])
    result

Parse non-empty UTF-8 without U+0000, bounded by Limits.max_name_bytes.

val worker_name_to_string : worker_name -> string
type tag
val parse_tag : 
  string ->
  (tag,
    [> `Empty_tag
    | `Invalid_tag_utf8
    | `Tag_contains_null
    | `Tag_too_long of int ])
    result

Parse non-empty UTF-8 without U+0000, bounded by Limits.max_tag_bytes. Tags are case-sensitive.

val tag_to_string : tag -> string
type metadata
val parse_metadata : 
  Simdjsont.Json.t ->
  (metadata, [> `Invalid_metadata | `Metadata_too_large of int ]) result

Parse a JSON object bounded by Limits.max_metadata_bytes.

val metadata_to_json : metadata -> Simdjsont.Json.t
type priority
val parse_priority : int -> (priority, [> `Invalid_priority of int ]) result

Parse a priority from Limits.min_priority (highest) through Limits.max_priority.

val priority_to_int : priority -> int
type state = 
  | Available
  | Executing
  | Completed
  | Cancelled
  | Discarded
val state_to_string : state -> string
val state_of_string : string -> (state, [> `Invalid_state of string ]) result
type available
type executing
type error_entry = {
  at : Ptime.t;
  attempt : int;
  kind : string;
  message : string;
}
type spec

An unpersisted job description.

type 'state t

A persisted job indexed by its lifecycle state.

type packed = 
  | Pack : 'state t -> packed (* A persisted job whose state is known at runtime. *)
type snapshot = {
  id : id;
  state : state;
  queue : queue;
  worker : worker_name;
  args : Simdjsont.Json.t;
  metadata : metadata;
  tags : tag list;
  attempt : int;
  max_attempts : int;
  priority : priority;
  errors : error_entry list;
  inserted_at : Ptime.t;
  scheduled_at : Ptime.t;
  unique_key : string option;
  attempted_at : Ptime.t option;
  finalized_at : Ptime.t option;
  revision : int64;
  attempted_by : string option;
}
val create : 
  ?queue:queue ->
  ?metadata:metadata ->
  ?tags:tag list ->
  ?max_attempts:int ->
  ?priority:priority ->
  ?scheduled_at:Ptime.t ->
  now:Ptime.t ->
  worker:worker_name ->
  args:Simdjsont.Json.t ->
  unit ->
  (spec,
    [> `Args_too_large of int
    | `Invalid_args
    | `Invalid_max_attempts of int
    | `Scheduled_in_past
    | `Too_many_tags of int ])
    result

Create a spec within Limits. Tags are sorted and deduplicated.

val view : 'state t -> snapshot
val inspect : packed -> snapshot
val pack : 'state t -> packed