config.go 618 B

1234567891011121314151617181920212223242526
  1. package policy
  2. import (
  3. "time"
  4. )
  5. func (s *Second) Duration() time.Duration {
  6. return time.Second * time.Duration(s.Value)
  7. }
  8. func (p *Policy) OverrideWith(another *Policy) {
  9. if another.Timeout != nil {
  10. if another.Timeout.Handshake != nil {
  11. p.Timeout.Handshake = another.Timeout.Handshake
  12. }
  13. if another.Timeout.ConnectionIdle != nil {
  14. p.Timeout.ConnectionIdle = another.Timeout.ConnectionIdle
  15. }
  16. if another.Timeout.UplinkOnly != nil {
  17. p.Timeout.UplinkOnly = another.Timeout.UplinkOnly
  18. }
  19. if another.Timeout.DownlinkOnly != nil {
  20. p.Timeout.DownlinkOnly = another.Timeout.DownlinkOnly
  21. }
  22. }
  23. }