Documentation
¶
Index ¶
- Constants
- Variables
- func CheckJobHasTask(ctx context.Context, w world.WorldState, jobKey, taskKey string) (bool, error)
- func CheckJobType(ctx context.Context, ws world.WorldState, objKey string) error
- func CollectJobTasks(ctx context.Context, ws world.WorldState, jobObjectKeys ...string) ([]*forge_task.Task, []string, error)
- func CompletionResult(tasks []*forge_task.Task, taskKeys []string) *forge_value.Result
- func CreateJobWithTasks(ctx context.Context, ws world.WorldState, sender peer.ID, objKey string, ...) (world.ObjectState, *bucket.ObjectRef, error)
- func EnsureJobHasTask(ctx context.Context, w world.WorldState, jobKey, taskKey string) error
- func ListJobTasks(ctx context.Context, w world.WorldState, jobKeys ...string) ([]string, error)
- func NewJobBlock() block.Block
- func NewJobTaskKey(jobKey, taskName string) string
- func NewJobToTaskQuad(jobObjKey, taskObjKey string) world.GraphQuad
- type Job
- func LookupJob(ctx context.Context, ws world.WorldState, objKey string) (*Job, world.ObjectState, error)
- func LookupJobBody(ctx context.Context, ws world.WorldState, objKey string) (*Job, error)
- func UnmarshalJob(ctx context.Context, bcs *block.Cursor) (*Job, error)
- func WaitJobComplete(ctx context.Context, le *logrus.Entry, ws world.WorldState, ...) (*Job, error)
- func (e *Job) ApplySubBlock(id uint32, next block.SubBlock) error
- func (m *Job) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Job) CloneVT() *Job
- func (this *Job) EqualMessageVT(thatMsg any) bool
- func (this *Job) EqualVT(that *Job) bool
- func (x *Job) GetJobState() State
- func (x *Job) GetPlacement() *worker.Placement
- func (x *Job) GetResult() *value.Result
- func (e *Job) GetSubBlockCtor(id uint32) block.SubBlockCtor
- func (e *Job) GetSubBlocks() map[uint32]block.SubBlock
- func (x *Job) GetTimestamp() *timestamppb.Timestamp
- func (e *Job) IsComplete() bool
- func (e *Job) MarshalBlock() ([]byte, error)
- func (x *Job) MarshalJSON() ([]byte, error)
- func (x *Job) MarshalProtoJSON(s *json.MarshalState)
- func (x *Job) MarshalProtoText() string
- func (m *Job) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Job) MarshalToVT(dAtA []byte) (int, error)
- func (m *Job) MarshalVT() (dAtA []byte, err error)
- func (*Job) ProtoMessage()
- func (x *Job) Reset()
- func (m *Job) SizeVT() (n int)
- func (x *Job) String() string
- func (e *Job) UnmarshalBlock(data []byte) error
- func (x *Job) UnmarshalJSON(b []byte) error
- func (x *Job) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Job) UnmarshalVT(dAtA []byte) error
- func (e *Job) Validate() error
- type State
- func (s State) EnsureMatches(sts ...State) error
- func (x State) Enum() *State
- func (x State) MarshalJSON() ([]byte, error)
- func (x State) MarshalProtoJSON(s *json.MarshalState)
- func (x State) MarshalProtoText() string
- func (x State) MarshalText() ([]byte, error)
- func (x State) String() string
- func (x *State) UnmarshalJSON(b []byte) error
- func (x *State) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (x *State) UnmarshalText(b []byte) error
- func (s State) Validate(allowUnknown bool) error
Constants ¶
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 ¶
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.
var ErrUnknownState = errors.New("unexpected or unhandled state")
ErrUnknownState is returned if the state was unknown/unhandled.
Functions ¶
func CheckJobHasTask ¶
CheckJobHasTask checks if the job is linked to a task.
func CheckJobType ¶
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 ¶
EnsureJobHasTask checks if the job has the task and returns an error otherwise.
func ListJobTasks ¶
ListJobTasks lists all Execution object keys that are linked to by the Job.
func NewJobTaskKey ¶
NewJobTaskKey creates a key for a task on a job with a name.
func NewJobToTaskQuad ¶
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
LookupJobBody looks up a Job body in the world.
func UnmarshalJob ¶
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 ¶
ApplySubBlock applies a sub-block change with a field id.
func (*Job) CloneMessageVT ¶
func (m *Job) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Job) EqualMessageVT ¶
func (*Job) GetJobState ¶
func (*Job) GetPlacement ¶
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 ¶
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 ¶
IsComplete checks if the job is in the COMPLETE state.
func (*Job) MarshalBlock ¶
MarshalBlock marshals the block to binary.
func (*Job) MarshalJSON ¶
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 (*Job) ProtoMessage ¶
func (*Job) ProtoMessage()
func (*Job) UnmarshalBlock ¶
UnmarshalBlock unmarshals the block to the object.
func (*Job) UnmarshalJSON ¶
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 ¶
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 ¶
EnsureMatches checks if the state matches or returns an error.
func (State) MarshalJSON ¶
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 (State) MarshalText ¶
MarshalText marshals the State to text.
func (*State) UnmarshalJSON ¶
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 ¶
UnmarshalText unmarshals the State from text.