mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-08 06:41:56 +00:00
add keep alive support
This commit is contained in:
parent
4d14a93b88
commit
926fb144f2
@ -10,9 +10,19 @@ type ResourcePool struct {
|
||||
nodes map[string]NodeStatus
|
||||
|
||||
history []PoolStatus
|
||||
|
||||
heartBeat map[string]time.Time
|
||||
}
|
||||
|
||||
func (pool *ResourcePool) start() {
|
||||
/* check dead nodes */
|
||||
for k, v := range pool.heartBeat {
|
||||
if v.Add(time.Second * 30).Before(time.Now()) {
|
||||
delete(pool.nodes, k)
|
||||
}
|
||||
}
|
||||
|
||||
/* save pool status periodically */
|
||||
go func() {
|
||||
/* waiting for data */
|
||||
pool.history = []PoolStatus{}
|
||||
@ -79,6 +89,7 @@ func (pool *ResourcePool) update(node NodeStatus) {
|
||||
}
|
||||
}
|
||||
pool.nodes[node.ClientID] = node
|
||||
pool.heartBeat[node.ClientID] = time.Now()
|
||||
|
||||
//log.Println(pool.nodes)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user