Die API-Referenz stammt aus den Go-Doc-Kommentaren im Quellcode und ist auf Englisch verfasst.
package genjob
import "github.com/nsgo-dev/game/pkg/tooling/genjob"Übersicht
Package genjob is experimental: its API and documented formats may change in a minor release. See the API stability policy. defines the durable, versioned record for an asset generation request.
Index
Konstanten
Funktionen
func Encode(job *Job) ([]byte, error)Encode validates and writes deterministic two-space YAML.
func Validate(job *Job) errorValidate checks the version, lifecycle fields, identifiers and candidate metadata. Its errors are *loaderr.Error values naming the field at fault.
Typen
type Candidate struct {
FileName string `yaml:"file"`
MediaType string `yaml:"mediaType"`
Bytes int64 `yaml:"bytes"`
SHA256 string `yaml:"sha256"`
}Candidate records one validated output stored beside job.yaml.
type Job struct {
Version int `yaml:"version"`
RequestID string `yaml:"requestId"`
Generator string `yaml:"generator"`
Tool string `yaml:"tool"`
Kind string `yaml:"kind"`
Target string `yaml:"target"`
Parameters map[string]string `yaml:"parameters,omitempty"`
Fingerprint string `yaml:"fingerprint"`
State State `yaml:"state"`
Phase string `yaml:"phase"`
RemoteTask string `yaml:"remoteTask,omitempty"`
Error string `yaml:"error,omitempty"`
Candidates []Candidate `yaml:"candidates,omitempty"`
}Job is the canonical record stored at .game/generated/<request-id>/job.yaml.
func Parse(data []byte) (*Job, error)Parse decodes and validates one strict generation job YAML document, refusing unknown and duplicate fields and a second document. Its errors are *loaderr.Error values with the line and field at fault.
type State stringState is the lifecycle state of a generation job.
const (
// StateQueued is a request accepted but not started.
StateQueued State = "queued"
// StateRunning is a request the generator is working on.
StateRunning State = "running"
// StateCompleted is a request whose candidates are stored beside job.yaml.
StateCompleted State = "completed"
// StateCancelled is a request the editor or the person cancelled.
StateCancelled State = "cancelled"
// StateFailed is a request that failed; Error says why.
StateFailed State = "failed"
)The lifecycle states a job record holds.