Help us shape the future of Go! Take the 2026 Go Developer Survey

forge_job

package
v0.57.21 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// JobTypeID is the type identifier for a Job.
	JobTypeID = "forge/job"

	// PredJobToTask is the predicate linking Job to a Task.
	PredJobToTask = quad.IRI("forge/job-task")
)

Variables

View Source
var (
	State_name = map[int32]string{
		0: "JobState_UNKNOWN",
		1: "JobState_PENDING",
		2: "JobState_RUNNING",
		3: "JobState_COMPLETE",
	}
	State_value = map[string]int32{
		"JobState_UNKNOWN":  0,
		"JobState_PENDING":  1,
		"JobState_RUNNING":  2,
		"JobState_COMPLETE": 3,
	}
)

Enum value maps for State.

View Source
var ErrUnknownState = errors.New("unexpected or unhandled state")

ErrUnknownState is returned if the state was unknown/unhandled.

Functions

func CheckJobHasTask

func CheckJobHasTask(ctx context.Context, w world.WorldState, jobKey, taskKey string) (bool, error)

CheckJobHasTask checks if the job is linked to a task.

func CheckJobType

func CheckJobType(ctx context.Context, ws world.WorldState, objKey string) error

CheckJobType checks the type graph quad for a job.

func CollectJobTasks

func CollectJobTasks(
	ctx context.Context,
	ws world.WorldState,
	jobObjectKeys ...string,
) ([]*forge_task.Task, []string, error)

CollectJobTasks collects all Tasks linked to by the Job. If any of the linked tasks are invalid, returns an error.

func CompletionResult

func CompletionResult(tasks []*forge_task.Task, taskKeys []string) *forge_value.Result

CompletionResult aggregates completed tasks in their supplied order. It returns nil while any task is incomplete. taskKeys must correspond to tasks, as returned by CollectJobTasks. The first failed task determines the failure summary.

func CreateJobWithTasks

func CreateJobWithTasks(
	ctx context.Context,
	ws world.WorldState,
	sender peer.ID,
	objKey string,
	tasks map[string]*forge_target.Target,
	tasksPeer peer.ID,
	placement *forge_worker.Placement,
	ts *timestamp.Timestamp,
) (world.ObjectState, *bucket.ObjectRef, error)

CreateJobWithTasks creates a pending Job object in the world.

TasksPeer sets the peer ID to set on the tasks. Can be empty. Placement selects the Worker and authenticated Device peer for every Task.

func EnsureJobHasTask

func EnsureJobHasTask(ctx context.Context, w world.WorldState, jobKey, taskKey string) error

EnsureJobHasTask checks if the job has the task and returns an error otherwise.

func ListJobTasks

func ListJobTasks(ctx context.Context, w world.WorldState, jobKeys ...string) ([]string, error)

ListJobTasks lists all Execution object keys that are linked to by the Job.

func NewJobBlock

func NewJobBlock() block.Block

NewJobBlock constructs a new Job block.

func NewJobTaskKey

func NewJobTaskKey(jobKey, taskName string) string

NewJobTaskKey creates a key for a task on a job with a name.

func NewJobToTaskQuad

func NewJobToTaskQuad(jobObjKey, taskObjKey string) world.GraphQuad

NewJobToTaskQuad creates a quad linking a Job to a Task.

Types

type Job

type Job struct {

	// JobState is the current state of the job.
	JobState State `protobuf:"varint,1,opt,name=job_state,json=jobState,proto3" json:"jobState,omitempty"`
	// Result is information about the outcome of a completed Job.
	Result *value.Result `protobuf:"bytes,2,opt,name=result,proto3" json:"result,omitempty"`
	// Timestamp is the time the Job was created.
	// Used as a reference timestamp to make all ops deterministic.
	// For example: all unixfs timestamps will be set to this value.
	// Must be set.
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// Placement is the immutable Worker and Device peer selected when this Job was created.
	Placement *worker.Placement `protobuf:"bytes,4,opt,name=placement,proto3" json:"placement,omitempty"`
	// contains filtered or unexported fields
}

Job contains state for running a set of Tasks.

The Job is complete when all Task are in the completed (terminal) state, or when a fatal error occurs.

World graph links:

  • parent: usually the Cluster which created the Job.
  • forge/job-task: all active Task instances for the Job.

Incoming links:

  • parent: any Tasks created specifically for the Job

func LookupJob

func LookupJob(ctx context.Context, ws world.WorldState, objKey string) (*Job, world.ObjectState, error)

LookupJob looks up a Job in the world.

func LookupJobBody added in v0.52.0

func LookupJobBody(ctx context.Context, ws world.WorldState, objKey string) (*Job, error)

LookupJobBody looks up a Job body in the world.

func UnmarshalJob

func UnmarshalJob(ctx context.Context, bcs *block.Cursor) (*Job, error)

UnmarshalJob unmarshals a Job block from the cursor.

func WaitJobComplete

func WaitJobComplete(
	ctx context.Context,
	le *logrus.Entry,
	ws world.WorldState,
	jobObjectKey string,
) (*Job, error)

WaitJobComplete waits until the Job is in the COMPLETE state.

func (*Job) ApplySubBlock

func (e *Job) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Job) CloneMessageVT

func (m *Job) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Job) CloneVT

func (m *Job) CloneVT() *Job

func (*Job) EqualMessageVT

func (this *Job) EqualMessageVT(thatMsg any) bool

func (*Job) EqualVT

func (this *Job) EqualVT(that *Job) bool

func (*Job) GetJobState

func (x *Job) GetJobState() State

func (*Job) GetPlacement

func (x *Job) GetPlacement() *worker.Placement

func (*Job) GetResult

func (x *Job) GetResult() *value.Result

func (*Job) GetSubBlockCtor

func (e *Job) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Job) GetSubBlocks

func (e *Job) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Job) GetTimestamp

func (x *Job) GetTimestamp() *timestamppb.Timestamp

func (*Job) IsComplete

func (e *Job) IsComplete() bool

IsComplete checks if the job is in the COMPLETE state.

func (*Job) MarshalBlock

func (e *Job) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary.

func (*Job) MarshalJSON

func (x *Job) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Job to JSON.

func (*Job) MarshalProtoJSON

func (x *Job) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Job message to JSON.

func (*Job) MarshalProtoText

func (x *Job) MarshalProtoText() string

func (*Job) MarshalToSizedBufferVT

func (m *Job) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Job) MarshalToVT

func (m *Job) MarshalToVT(dAtA []byte) (int, error)

func (*Job) MarshalVT

func (m *Job) MarshalVT() (dAtA []byte, err error)

func (*Job) ProtoMessage

func (*Job) ProtoMessage()

func (*Job) Reset

func (x *Job) Reset()

func (*Job) SizeVT

func (m *Job) SizeVT() (n int)

func (*Job) String

func (x *Job) String() string

func (*Job) UnmarshalBlock

func (e *Job) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object.

func (*Job) UnmarshalJSON

func (x *Job) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Job from JSON.

func (*Job) UnmarshalProtoJSON

func (x *Job) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Job message from JSON.

func (*Job) UnmarshalVT

func (m *Job) UnmarshalVT(dAtA []byte) error

func (*Job) Validate

func (e *Job) Validate() error

Validate performs cursory checks of the Job object.

type State

type State int32

State contains the possible Job states.

const (
	// JobState_UNKNOWN is the unknown type.
	State_JobState_UNKNOWN State = 0
	// JobState_PENDING indicates the job is queued for execution.
	// Transitions to RUNNING state when the scheduler starts the job.
	State_JobState_PENDING State = 1
	// JobState_RUNNING is the state when the job is underway.
	//
	// If the job is returned to PENDING, all ongoing Pass are canceled, and
	// replaced with new Pass in PENDING state.
	State_JobState_RUNNING State = 2
	// JobState_COMPLETE is the normal terminal state of the job.
	// This includes both success and failure termination states.
	State_JobState_COMPLETE State = 3
)

func (State) EnsureMatches

func (s State) EnsureMatches(sts ...State) error

EnsureMatches checks if the state matches or returns an error.

func (State) Enum

func (x State) Enum() *State

func (State) MarshalJSON

func (x State) MarshalJSON() ([]byte, error)

MarshalJSON marshals the State to JSON.

func (State) MarshalProtoJSON

func (x State) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the State to JSON.

func (State) MarshalProtoText

func (x State) MarshalProtoText() string

func (State) MarshalText

func (x State) MarshalText() ([]byte, error)

MarshalText marshals the State to text.

func (State) String

func (x State) String() string

func (*State) UnmarshalJSON

func (x *State) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the State from JSON.

func (*State) UnmarshalProtoJSON

func (x *State) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the State from JSON.

func (*State) UnmarshalText

func (x *State) UnmarshalText(b []byte) error

UnmarshalText unmarshals the State from text.

func (State) Validate

func (s State) Validate(allowUnknown bool) error

Validate checks the execution state is within known values.

Jump to

Keyboard shortcuts

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