Job History schema

This commit is contained in:
Alex Dadgar
2017-04-12 15:44:30 -07:00
parent 0e25ef9509
commit 4b244219f9

View File

@@ -20,6 +20,7 @@ func stateStoreSchema() *memdb.DBSchema {
nodeTableSchema,
jobTableSchema,
jobSummarySchema,
jobHistorySchema,
periodicLaunchTableSchema,
evalTableSchema,
allocTableSchema,
@@ -141,6 +142,37 @@ func jobSummarySchema() *memdb.TableSchema {
}
}
// jobHistorySchema returns the memdb schema for the job history table which
// keeps a historical view of jobs.
func jobHistorySchema() *memdb.TableSchema {
return &memdb.TableSchema{
Name: "job_histories",
Indexes: map[string]*memdb.IndexSchema{
"id": &memdb.IndexSchema{
Name: "id",
AllowMissing: false,
Unique: true,
// Use a compound index so the tuple of (JobID, Version) is
// uniquely identifying
Indexer: &memdb.CompoundIndex{
Indexes: []memdb.Indexer{
&memdb.StringFieldIndex{
Field: "JobID",
Lowercase: true,
},
// Will need to create a new indexer
&memdb.UintFieldIndex{
Field: "Version",
},
},
},
},
},
}
}
// jobIsGCable satisfies the ConditionalIndexFunc interface and creates an index
// on whether a job is eligible for garbage collection.
func jobIsGCable(obj interface{}) (bool, error) {