entities.go 502 B

12345678910111213141516171819202122232425262728
  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. }
  19. type newNodeEvent struct {
  20. NodeID string `json:"node_id"`
  21. }