msg.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package internal
  2. import "time"
  3. // A StatusUpdateMsg represents a msg when
  4. // a worker has done syncing
  5. type StatusUpdateMsg struct {
  6. Name string `json:"name"`
  7. Worker string `json:"worker"`
  8. IsMaster bool `json:"is_master"`
  9. Status SyncStatus `json:"status"`
  10. LastUpdate time.Time `json:"last_update"`
  11. Upstream string `json:"upstream"`
  12. Size string `json:"size"`
  13. ErrorMsg string `json:"error_msg"`
  14. }
  15. // A WorkerInfoMsg is the information struct that describe
  16. // a worker, and sent from the manager to clients.
  17. type WorkerInfoMsg struct {
  18. ID string `json:"id"`
  19. }
  20. type CmdVerb uint8
  21. const (
  22. CmdStart CmdVerb = iota
  23. CmdStop // stop syncing keep the job
  24. CmdDisable // disable the job (stops goroutine)
  25. CmdRestart // restart syncing
  26. CmdPing // ensure the goroutine is alive
  27. )
  28. // A WorkerCmd is the command message send from the
  29. // manager to a worker
  30. type WorkerCmd struct {
  31. Cmd CmdVerb `json:"cmd"`
  32. MirrorID string `json:"mirror_id"`
  33. Args []string `json:"args"`
  34. }
  35. // A ClientCmd is the command message send from client
  36. // to the manager
  37. type ClientCmd struct {
  38. Cmd CmdVerb `json:"cmd"`
  39. MirrorID string `json:"mirror_id"`
  40. WorkerID string `json:"worker_id"`
  41. Args []string `json:"args"`
  42. }