Skip to content

Jobs

Jobs represent long-running operations the Chronicle Kernel performs in the background — replaying a projection, rebuilding a read model, and similar work that runs in steps over time rather than completing instantly. Use the jobs API to see what’s running, check progress, and stop, resume, or delete a job.

using Cratis.Chronicle;
using Cratis.Chronicle.Jobs;
public class JobsIndexListAll(IEventStore eventStore)
{
public async Task<IEnumerable<Job>> GetAllJobs() => await eventStore.Jobs.GetJobs();
}
using Cratis.Chronicle;
using Cratis.Chronicle.Jobs;
public class JobsIndexGetOne(IEventStore eventStore)
{
public async Task<Job?> GetJob(JobId jobId) => await eventStore.Jobs.GetJob(jobId);
}

A missing job resolves to nothing rather than an error — check for that before using the result.

A job is made up of one or more steps. Get them to see fine-grained progress:

using Cratis.Chronicle;
using Cratis.Chronicle.Jobs;
public class JobsIndexGetSteps(IEventStore eventStore)
{
public async Task<IEnumerable<JobStep>?> GetSteps(JobId jobId)
{
var job = await eventStore.Jobs.GetJob(jobId);
return job is null ? null : await job.GetJobSteps();
}
}
using Cratis.Chronicle;
using Cratis.Chronicle.Jobs;
public class JobsIndexStopResumeDelete(IEventStore eventStore)
{
public async Task StopJob(JobId jobId) => await eventStore.Jobs.Stop(jobId);
public async Task ResumeJob(JobId jobId) => await eventStore.Jobs.Resume(jobId);
public async Task DeleteJob(JobId jobId) => await eventStore.Jobs.Delete(jobId);
}

Kotlin and Java don’t currently have a jobs API — there’s no equivalent anywhere in the Kotlin client SDK yet.

  • Webhooks — pushing observed events to external HTTP endpoints, the other kernel-managed background concern.