Update go-marathon
This commit is contained in:
parent
3142a4f4b3
commit
877770f7cf
24 changed files with 450 additions and 97 deletions
23
vendor/github.com/gambol99/go-marathon/cluster.go
generated
vendored
23
vendor/github.com/gambol99/go-marathon/cluster.go
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2014 Rohith All rights reserved.
|
||||
Copyright 2014 The go-marathon Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -39,6 +39,9 @@ type cluster struct {
|
|||
members []*member
|
||||
// the marathon HTTP client to ensure consistency in requests
|
||||
client *httpClient
|
||||
// healthCheckInterval is the interval by which we probe down nodes for
|
||||
// availability again.
|
||||
healthCheckInterval time.Duration
|
||||
}
|
||||
|
||||
// member represents an individual endpoint
|
||||
|
@ -94,8 +97,9 @@ func newCluster(client *httpClient, marathonURL string, isDCOS bool) (*cluster,
|
|||
}
|
||||
|
||||
return &cluster{
|
||||
client: client,
|
||||
members: members,
|
||||
client: client,
|
||||
members: members,
|
||||
healthCheckInterval: 5 * time.Second,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -130,20 +134,21 @@ func (c *cluster) markDown(endpoint string) {
|
|||
// healthCheckNode performs a health check on the node and when active updates the status
|
||||
func (c *cluster) healthCheckNode(node *member) {
|
||||
// step: wait for the node to become active ... we are assuming a /ping is enough here
|
||||
for {
|
||||
ticker := time.NewTicker(c.healthCheckInterval)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
req, err := c.client.buildMarathonRequest("GET", node.endpoint, "ping", nil)
|
||||
if err == nil {
|
||||
res, err := c.client.Do(req)
|
||||
if err == nil && res.StatusCode == 200 {
|
||||
// step: mark the node as active again
|
||||
c.Lock()
|
||||
node.status = memberStatusUp
|
||||
c.Unlock()
|
||||
break
|
||||
}
|
||||
}
|
||||
<-time.After(time.Duration(5 * time.Second))
|
||||
}
|
||||
// step: mark the node as active again
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
node.status = memberStatusUp
|
||||
}
|
||||
|
||||
// activeMembers returns a list of active members
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue