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 ¶
- func DecodeDependencies(stored string) []driver.Dependency
- func DecodeErrors(stored string) ([]driver.AttemptError, error)
- func DecodeLogs(stored string) []driver.AttemptLog
- func DecodeProgress(stored string) *driver.Progress
- func DecodeSteps(stored string) map[driver.JobID]string
- func DecodeTags(stored string) []string
- func MarshalAttemptError(e *driver.AttemptError) ([]byte, error)
- func MarshalAttemptLog(f driver.JobFinalize) ([]byte, error)
- func StepsJSON(steps []string, ids []driver.JobID) ([]byte, error)
- func StorableText(s string) string
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 ¶
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
DecodeSteps reads the step names a workflow row stores, skipping what is not in the form StepsJSON writes.
func DecodeTags ¶
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
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 ¶
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.