msg.go 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. }
  14. // A WorkerInfoMsg is
  15. type WorkerInfoMsg struct {
  16. Name string `json:"name"`
  17. }
  18. type CmdVerb uint8
  19. const (
  20. CmdStart CmdVerb = iota
  21. CmdStop // stop syncing keep the job
  22. CmdDisable // disable the job (stops goroutine)
  23. CmdRestart // restart syncing
  24. CmdPing // ensure the goroutine is alive
  25. )
  26. type WorkerCmd struct {
  27. Cmd CmdVerb `json:"cmd"`
  28. Args []string `json:"args"`
  29. }
  30. type ClientCmd struct {
  31. Cmd CmdVerb `json:"cmd"`
  32. MirrorID string `json:"mirror_id"`
  33. WorkerID string `json:"worker_id"`
  34. Args []string `json:"args"`
  35. }