forked from lei.chen/myxce
38 lines
1,003 B
Go
38 lines
1,003 B
Go
package backend
|
|
|
|
import (
|
|
"apiserver/models"
|
|
"apiserver/store"
|
|
)
|
|
|
|
// DefaultHandler implements NotificationHandler by writing to stores.
|
|
type DefaultHandler struct{}
|
|
|
|
func (h *DefaultHandler) OnJobCreated(job *models.JobInfo) {
|
|
store.Jobs.Put(uint64(job.Unique_JobID), *job)
|
|
}
|
|
|
|
func (h *DefaultHandler) OnJobUpdated(job *models.JobInfo) {
|
|
store.Jobs.Put(uint64(job.Unique_JobID), *job)
|
|
}
|
|
|
|
func (h *DefaultHandler) OnJobDeleted(jobid uint64) {
|
|
store.Jobs.Delete(jobid)
|
|
}
|
|
|
|
func (h *DefaultHandler) OnQueueUpdated(queue *models.QueueInfo) {
|
|
store.Queues.Put(queue.QueueName, *queue)
|
|
}
|
|
|
|
func (h *DefaultHandler) OnHostUpdated(host *models.HostInfo) {
|
|
store.Hosts.Put(host.HostName, *host)
|
|
}
|
|
|
|
func (h *DefaultHandler) OnResourceUpdated(res *models.ResourceDefinitionInfo) {
|
|
store.Resources.Put(res.ResourceName, *res)
|
|
}
|
|
|
|
func (h *DefaultHandler) OnResourceLocationUpdated(res *models.ResourceDistributionInfo) {
|
|
key := res.ResourceName + ":" + res.Location
|
|
store.ResourceLocations.Put(key, *res)
|
|
}
|