예제 #1
0
func ResponseFromProto(ptr *o.ProtoTaskResponse) (r *TaskResponse) {
	r = new(TaskResponse)

	switch *(ptr.Status) {
	case o.ProtoTaskResponse_JOB_INPROGRESS:
		r.State = RESP_RUNNING
	case o.ProtoTaskResponse_JOB_SUCCESS:
		r.State = RESP_FINISHED
	case o.ProtoTaskResponse_JOB_FAILED:
		r.State = RESP_FAILED
	case o.ProtoTaskResponse_JOB_HOST_FAILURE:
		r.State = RESP_FAILED_HOST_ERROR
	case o.ProtoTaskResponse_JOB_UNKNOWN:
		r.State = RESP_FAILED_UNKNOWN_SCORE
	case o.ProtoTaskResponse_JOB_UNKNOWN_FAILURE:
		fallthrough
	default:
		r.State = RESP_FAILED_UNKNOWN
	}

	r.id = *(ptr.Id)
	r.Response = o.MapFromProtoJobParameters(ptr.Response)

	return r
}
예제 #2
0
/* Map a wire task to an internal Task Request.
 */
func TaskFromProto(ptr *o.ProtoTaskRequest) (t *TaskRequest) {
	t = NewTaskRequest()

	t.Score = *(ptr.Jobname)
	t.Id = *(ptr.Id)
	t.Params = o.MapFromProtoJobParameters(ptr.Parameters)

	return t
}