jobcodec

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 6 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 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 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 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