entities.go 440 B

123456789101112131415161718192021222324
  1. package cluster
  2. import "time"
  3. type ip struct {
  4. Address string `json:"address"`
  5. Votes []vote `json:"vote"`
  6. }
  7. type vote struct {
  8. NodeID string `json:"node_id"`
  9. VotedAt int64 `json:"voted_at"`
  10. Failed bool `json:"failed"`
  11. }
  12. type node struct {
  13. Ips []ip `json:"ips"`
  14. LastPingAt int64 `json:"last_ping_at"`
  15. }
  16. func (c *node) available() bool {
  17. return time.Since(time.Unix(c.LastPingAt, 0)) < NODE_DISCONNECTED_TIMEOUT
  18. }