msg.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. LastOnline time.Time `json:"last_online"`
  20. }
  21. type CmdVerb uint8
  22. const (
  23. CmdStart CmdVerb = iota
  24. CmdStop // stop syncing keep the job
  25. CmdDisable // disable the job (stops goroutine)
  26. CmdRestart // restart syncing
  27. CmdPing // ensure the goroutine is alive
  28. )
  29. // A WorkerCmd is the command message send from the
  30. // manager to a worker
  31. type WorkerCmd struct {
  32. Cmd CmdVerb `json:"cmd"`
  33. MirrorID string `json:"mirror_id"`
  34. Args []string `json:"args"`
  35. }
  36. // A ClientCmd is the command message send from client
  37. // to the manager
  38. type ClientCmd struct {
  39. Cmd CmdVerb `json:"cmd"`
  40. MirrorID string `json:"mirror_id"`
  41. WorkerID string `json:"worker_id"`
  42. Args []string `json:"args"`
  43. }