1
0
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:
Newnius 2019-06-04 11:15:12 +08:00
parent fda4a7674b
commit 6045e91cca

View File

@ -16,12 +16,18 @@ type ResourcePool struct {
func (pool *ResourcePool) start() { func (pool *ResourcePool) start() {
/* check dead nodes */ /* check dead nodes */
pool.heartBeat = map[string]time.Time{} go func() {
for k, v := range pool.heartBeat { pool.heartBeat = map[string]time.Time{}
if v.Add(time.Second * 30).Before(time.Now()) {
delete(pool.nodes, k) for {
for k, v := range pool.heartBeat {
if v.Add(time.Second * 30).Before(time.Now()) {
delete(pool.nodes, k)
}
}
time.Sleep(time.Second * 10)
} }
} }()
/* save pool status periodically */ /* save pool status periodically */
go func() { go func() {