Chronicle.Jobs (cratis_chronicle v1.0.1)

Copy Markdown View Source

Idiomatic API for working with Chronicle jobs.

Jobs represent long-running Chronicle operations such as replays and rebuilds. This module lets you inspect current jobs, inspect their steps, and control their lifecycle.

Usage

{:ok, jobs} = Chronicle.Jobs.all()
{:ok, job} = Chronicle.Jobs.get("8a6f5a0c-0fbf-42bd-8db0-a60f9a449b11")
:ok = Chronicle.Jobs.stop("8a6f5a0c-0fbf-42bd-8db0-a60f9a449b11")

Options

  • :client — the client name (default: Chronicle.Client)
  • :namespace — overrides the client's default namespace

Summary

Functions

Gets all jobs for the configured event store namespace.

Gets a single job by identifier.

Compatibility alias for get/2.

Compatibility alias for steps/2.

Compatibility alias for all/1.

Resumes a stopped job.

Gets all steps for a specific job.

Types

job_id()

@type job_id() :: String.t()

Functions

all(opts \\ [])

@spec all(keyword()) :: {:ok, [Chronicle.Jobs.Job.t()]} | {:error, term()}

Gets all jobs for the configured event store namespace.

delete(job_id, opts \\ [])

@spec delete(
  job_id(),
  keyword()
) :: :ok | {:error, term()}

Deletes a job.

get(job_id, opts \\ [])

@spec get(
  job_id(),
  keyword()
) :: {:ok, Chronicle.Jobs.Job.t() | nil} | {:error, term()}

Gets a single job by identifier.

Returns {:ok, nil} when the job does not exist.

get_job(job_id, opts \\ [])

@spec get_job(
  job_id(),
  keyword()
) :: {:ok, Chronicle.Jobs.Job.t() | nil} | {:error, term()}

Compatibility alias for get/2.

get_job_steps(job_id, opts \\ [])

@spec get_job_steps(
  job_id(),
  keyword()
) :: {:ok, [Chronicle.Jobs.JobStep.t()]} | {:error, term()}

Compatibility alias for steps/2.

get_jobs(opts \\ [])

@spec get_jobs(keyword()) :: {:ok, [Chronicle.Jobs.Job.t()]} | {:error, term()}

Compatibility alias for all/1.

resume(job_id, opts \\ [])

@spec resume(
  job_id(),
  keyword()
) :: :ok | {:error, term()}

Resumes a stopped job.

steps(job_id, opts \\ [])

@spec steps(
  job_id(),
  keyword()
) :: {:ok, [Chronicle.Jobs.JobStep.t()]} | {:error, term()}

Gets all steps for a specific job.

stop(job_id, opts \\ [])

@spec stop(
  job_id(),
  keyword()
) :: :ok | {:error, term()}

Stops a job.