github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/model/v1beta1/joblocaleventtype.go (about) 1 package v1beta1 2 3 import "fmt" 4 5 //go:generate stringer -type=JobLocalEventType --trimprefix=JobLocalEvent 6 type JobLocalEventType int 7 8 const ( 9 jobLocalEventUnknown JobLocalEventType = iota // must be first 10 11 // compute node 12 // this means "we have selected this job" 13 // used to avoid calling external selection hooks 14 // where capacity manager says we can't quite run 15 // the job yet but we will want to bid when there 16 // is space 17 JobLocalEventSelected 18 // compute node 19 // this means "we have bid" on a job where "we" 20 // is the compute node 21 JobLocalEventBid 22 // requester node 23 // used to avoid race conditions with the requester 24 // node knowing which bids it's already responded to 25 JobLocalEventBidAccepted 26 JobLocalEventBidRejected 27 28 // requester node 29 // flag a job as having already had it's verification done 30 JobLocalEventVerified 31 32 jobLocalEventDone // must be last 33 ) 34 35 func ParseJobLocalEventType(str string) (JobLocalEventType, error) { 36 for typ := jobLocalEventUnknown + 1; typ < jobLocalEventDone; typ++ { 37 if equal(typ.String(), str) { 38 return typ, nil 39 } 40 } 41 42 return jobLocalEventDone, fmt.Errorf( 43 "executor: unknown job event type '%s'", str) 44 } 45 46 func JobLocalEventTypes() []JobLocalEventType { 47 var res []JobLocalEventType 48 for typ := jobLocalEventUnknown + 1; typ < jobLocalEventDone; typ++ { 49 res = append(res, typ) 50 } 51 52 return res 53 } 54 55 func (jle JobLocalEventType) MarshalText() ([]byte, error) { 56 return []byte(jle.String()), nil 57 } 58 59 func (jle *JobLocalEventType) UnmarshalText(text []byte) (err error) { 60 name := string(text) 61 *jle, err = ParseJobLocalEventType(name) 62 return 63 }