40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package job
|
|
|
|
type Job struct {
|
|
id string
|
|
name string // descriptive name for job, helps consumers to identify job
|
|
consumerId string // defined at job creation
|
|
workerId string // defined when job assigned to worker
|
|
imageName string // Name from DockerHub, e.g. "postgres" or "chainguard/jdk"
|
|
environmentVariables map[string]string // e.g. {"POSTGRES_DB": "test_db", ...}
|
|
status JobStatus
|
|
standardOutput string
|
|
|
|
createdAt int64 // for priority -> first come first serve
|
|
// Unix timestamps in milliseconds, needed to calculate estimated CO2 equivalent:
|
|
startedAt int64
|
|
finishedAt int64
|
|
|
|
// needed for calculating the diff between executing job at worker and consumer location
|
|
ConsumerLongitude float64
|
|
ConsumerLatitude float64
|
|
Co2EquivalentEmissionConsumer float64 // emission of the consumer location (the current emission when job is scheduled)
|
|
|
|
WorkerLongitude float64
|
|
WorkerLatitude float64
|
|
Co2EquivalentEmissionWorker float64 // emission of the worker location (the current emission when job is scheduled)
|
|
|
|
// final co2 equivalent of the finished job
|
|
estimatedCo2Equivalent float64
|
|
}
|
|
|
|
type JobStatus string
|
|
|
|
const (
|
|
CREATED JobStatus = "CREATED" // job created, but not assigned to worker yet
|
|
PENDING JobStatus = "PENDING" // assigned to worker, but not running yet
|
|
RUNNING JobStatus = "RUNNING"
|
|
FINISHED JobStatus = "FINISHED"
|
|
FAILED JobStatus = "FAILED"
|
|
)
|