# `Que.Job`
[🔗](https://github.com/sheharyarn/que/blob/main/lib/que/job.ex#L1)

Module to manage a Job's state and execute the worker's callbacks.

Defines a `Que.Job` struct an keeps track of the Job's worker, arguments,
status and more. Meant for internal usage, so you shouldn't use this
unless you absolutely know what you're doing.

# `status`

```elixir
@type status() :: atom()
```

One of the atoms in `[:queued, :started, :failed, :completed]`

# `t`

```elixir
@type t() :: %Que.Job{
  arguments: term(),
  created_at: term(),
  id: term(),
  pid: term(),
  ref: term(),
  status: term(),
  updated_at: term(),
  worker: term()
}
```

A `Que.Job` struct

# `handle_failure`

```elixir
@spec handle_failure(job :: t(), error :: term()) :: t()
```

Handles Job Failure, Calls appropriate worker method and updates the job
status to :failed

# `handle_success`

```elixir
@spec handle_success(job :: t()) :: t()
```

Handles Job Success, Calls appropriate worker method and updates the job
status to :completed

# `new`

```elixir
@spec new(worker :: Que.Worker.t(), args :: list()) :: t()
```

Returns a new Job struct with defaults

# `perform`

```elixir
@spec perform(job :: t()) :: t()
```

Updates the Job struct with new status and spawns & monitors a new Task
under the TaskSupervisor which executes the perform method with supplied
arguments

# `set_status`

```elixir
@spec set_status(job :: t(), status :: status()) :: t()
```

Update the Job status to one of the predefined values in `@statuses`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
