jobtype

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package jobtype carries Atlas's engine-wide job-type table: the one mapping from a job type's name to the integer index a job on disk carries.

It exists because the compiler interns strings *per compiled process* (ADR-0004), while the activatable-job index is engine-wide. Two definitions therefore disagree about what a given index means — measured on the tree that found this, `send-email` in one process and `charge-card` in another were both index 16 — so a worker subscribing by job type would be handed the wrong work. ADR-0007 names this table as the correctness prerequisite for the type-keyed pull, and ADR-0157 as step 1 of moving side-effecting work onto workers.

The table has two halves. The **reserved** half is the built-in job types (DMN, user task, the Worker Types, the script languages): their indices are compile-time constants that every builder reserves in order, so the registry seeds itself from compiler.ReservedJobTypes and never persists them — a stored copy could only drift from the constants. The **dynamic** half is the model-authored types (a `<zeebe:taskDefinition type>`), assigned from compiler.FirstDynamicJobTypeIndex upward and persisted, because nothing in the code remembers them.

An index, once issued, is permanent: jobs already on disk carry it, so the registry never recycles one, not even after a record is removed by hand.

Like the design-time stores it sits beside, a Registry does no locking of its own — it is owned by the server's run-loop goroutine, the single writer of deploy-time state (invariant I3).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collision

type Collision struct {
	// Name is the model-authored job type that was issued this index.
	Name string `json:"name"`
	// Index is the index it holds on disk, and that its jobs still carry.
	Index int32 `json:"index"`
	// NowMeans is the built-in job type that index stands for in this build.
	NowMeans string `json:"nowMeans"`
}

Collision is a stored assignment whose index the reserved range has since taken.

func Collisions

func Collisions(dir string) ([]Collision, error)

Collisions reports the stored assignments in dir whose index is now reserved, without opening a full registry. A directory that was never written is clean, not an error: a fresh server has no table yet.

type Entry

type Entry struct {
	Name  string `json:"name"`
	Index int32  `json:"index"`
}

Entry is one persisted assignment: a model-authored job type and the engine-wide index it was given. Reserved types have no Entry.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is the engine-wide job-type table. Build one with NewRegistry.

func NewRegistry

func NewRegistry(dir string) (*Registry, error)

NewRegistry opens (creating if needed) the directory backing the table, seeds the reserved half from the compiler's constants, and loads whatever dynamic assignments are already on disk.

func (*Registry) All

func (r *Registry) All() []Entry

All returns every job type the engine knows, reserved and dynamic alike, in index order — the whole table, which is what the Workers view lists so an operator sees the kinds nobody is serving as well as the ones being worked.

func (*Registry) Dropped

func (r *Registry) Dropped() []Collision

Dropped reports the assignments this registry could not load because the reserved range had grown over their indices. Empty for every healthy store.

A caller is expected to surface it — a server logs it at startup. The registry itself does not refuse, because refusing would take an instance down over a condition whose repair has not been decided yet, and a report that reaches an operator is what that decision needs.

func (*Registry) Index

func (r *Registry) Index(name string) (int32, bool)

Index reports the engine-wide index a job type already holds, without assigning one. Use it to read the table; use Registry.Intern to extend it.

func (*Registry) Intern

func (r *Registry) Intern(name string) (int32, error)

Intern returns the engine-wide index for a job type, assigning and persisting a new one the first time a name is seen. It is idempotent — the same name always comes back with the same index — which is what lets every deploy and every reload resolve their processes through it.

Its signature is the resolution seam compiler.CompiledProcess.ResolveJobTypes takes, so it can be passed there directly.

func (*Registry) Name

func (r *Registry) Name(index int32) (string, bool)

Name is the reverse direction: the job type an index stands for, which is what turns the number on a job record back into something an operator can read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL