broadcast.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package broadcast
  2. import (
  3. wardensvr "go-common/app/service/main/broadcast/api/grpc/v1"
  4. )
  5. type ServerListReply struct {
  6. Domain string `json:"domain,omitempty"`
  7. TCPPort int32 `json:"tcp_port,omitempty"`
  8. WsPort int32 `json:"ws_port,omitempty"`
  9. WssPort int32 `json:"wss_port,omitempty"`
  10. Heartbeat int32 `json:"heartbeat,omitempty"`
  11. HeartbeatMax int32 `json:"heartbeat_max,omitempty"`
  12. Nodes []string `json:"nodes,omitempty"`
  13. Backoff *Backoff `json:"backoff,omitempty"`
  14. }
  15. type Backoff struct {
  16. MaxDelay int32 `json:"max_delay,omitempty"`
  17. BaseDelay int32 `json:"base_delay,omitempty"`
  18. Factor float32 `json:"factor,omitempty"`
  19. Jitter float32 `json:"jitter,omitempty"`
  20. }
  21. func (l *ServerListReply) ServerListChange(w *wardensvr.ServerListReply) {
  22. l.Domain = w.Domain
  23. l.TCPPort = w.TcpPort
  24. l.WsPort = w.WsPort
  25. l.WssPort = w.WssPort
  26. l.Heartbeat = w.Heartbeat
  27. l.HeartbeatMax = w.HeartbeatMax
  28. if len(w.Nodes) > 0 {
  29. l.Nodes = w.Nodes
  30. }
  31. if w.Backoff != nil {
  32. l.Backoff = &Backoff{
  33. MaxDelay: w.Backoff.MaxDelay,
  34. BaseDelay: w.Backoff.BaseDelay,
  35. Factor: w.Backoff.Factor,
  36. Jitter: w.Backoff.Jitter,
  37. }
  38. }
  39. }