jobcodec

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package jobcodec encodes and decodes the JSON values a job row keeps beside its args and metadata: its errors, progress, logs and tags. Every engine stores them the same way, and reads them the same way: a value that a direct SQL write left in another form reads as what can be made of it, rather than failing the read, so that one such row fails neither the claim that takes it (whose update has committed by the time it is read) nor a listing or the rescuer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDependencies added in v0.11.0

func CheckDependencies(deps []driver.JobDependency, n int) ([]bool, error)

CheckDependencies checks a workflow's edges against its n jobs, and returns which jobs have dependencies, to insert pending. An edge given twice must be in the same group both times: the engines keep one row per pair, the first, while EdgesJSON records every edge given.

func DecodeDependencies added in v0.10.0

func DecodeDependencies(stored string) []driver.Dependency

DecodeDependencies reads a claim's JSON array of dependencies, or none if it is not one.

func DecodeEdges added in v0.11.0

func DecodeEdges(stored string) ([]driver.JobEdge, error)

DecodeEdges reads the edges EdgesJSON writes.

func DecodeErrors

func DecodeErrors(stored string) ([]driver.AttemptError, error)

DecodeErrors reads a job's errors, a JSON array of error records. An empty value reads as none.

func DecodeLogs

func DecodeLogs(stored string) []driver.AttemptLog

DecodeLogs reads a job's logs, skipping entries that are not in the form a finalize writes.

func DecodeProgress

func DecodeProgress(stored string) *driver.Progress

DecodeProgress reads a progress value, keeping what it can of one that is not in the form an engine writes: a value that is not an object reads as none.

func DecodeSteps added in v0.10.0

func DecodeSteps(stored string) map[driver.JobID]string

DecodeSteps reads the step names a workflow row stores, skipping what is not in the form StepsJSON writes.

func DecodeTags

func DecodeTags(stored string) []string

DecodeTags reads a tags value, a JSON array of strings: a value that is not an array reads as no tags, and elements that are not strings are skipped, as are empty strings and repeats.

func EdgePolicy added in v0.11.0

func EdgePolicy(d driver.JobDependency) string

EdgePolicy is what an edge stores as its on_failure: the dependent's policy, cancel by default, and for an edge of an any-of group, that policy prefixed with "any_". A group's edges never store "cancel", which cancels the dependent as soon as the one job fails, so an engine of a release before any-of groups, which knows only "cancel" and "ignore", leaves them alone, as edges of a dependent that runs once they have all finished.

func EdgesJSON added in v0.11.0

func EdgesJSON(deps []driver.JobDependency, ids []driver.JobID) ([]byte, error)

EdgesJSON returns a workflow's edges as the JSON array a workflow row stores for WorkflowGet: a pair of job IDs per edge, the dependent's first, and for an edge of an any-of group its group number after them, as a string. A reader of a release before any-of groups decodes the pair and drops the number.

func MarshalAttemptError

func MarshalAttemptError(e *driver.AttemptError) ([]byte, error)

MarshalAttemptError encodes an error record without its timestamp, which the engine fills in from database time, its text made storable.

func MarshalAttemptLog

func MarshalAttemptLog(f driver.JobFinalize) ([]byte, error)

MarshalAttemptLog encodes the log a finalize appends for result f, which a snooze marks Snoozed, its text made storable, or returns nil when there is none to keep (JobFinalize.KeepsLog).

func StepsJSON added in v0.10.0

func StepsJSON(steps []string, ids []driver.JobID) ([]byte, error)

StepsJSON checks a workflow's step names against its n jobs and returns them as the JSON object, keyed by job ID, that a workflow row stores, or nil if no step is named.

func StorableText

func StorableText(s string) string

StorableText replaces what a database may refuse in text and JSON strings, NUL and invalid UTF-8, so that one worker's text cannot fail the statement that finalizes a whole batch.

Types

This section is empty.

Jump to

Keyboard shortcuts

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