config.go 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. package config
  2. // 全局配置
  3. type Config struct {
  4. ConnectTimeout int // 没有收到数据包的连接超时时间(ms)
  5. PingInterval int // 发送ping包的时间间隔,前提是没有收到数据包(ms)
  6. WriteWait int // 写入网络数据等待最长时间(ms)
  7. ReadWait int // 获取命令数据超时时间 (ms)
  8. LongReadWait int // 长时间等待读取数据的超时时间(ms)
  9. CleanDeadConnectWait int // 清理异常的连接(ms)
  10. PrintPing bool // 打印连接ping包
  11. PrintMsg bool // 打印数据包
  12. ProxyTimeout int // 客户端检测是否使用代理连接,如果是则进行直连尝试(ms)
  13. ConnectCheck int // 客户端重连检测周期(ms)
  14. }
  15. // 获取实例好的配置
  16. func NewConfig() *Config {
  17. // 配置基础的数据
  18. return &Config{
  19. ConnectTimeout: 30 * 1000,
  20. PingInterval: 61 * 1000,
  21. WriteWait: 60 * 1000,
  22. ReadWait: 30 * 1000,
  23. LongReadWait: 150 * 1000,
  24. CleanDeadConnectWait: 3600 * 1000,
  25. PrintPing: false,
  26. PrintMsg: true,
  27. ProxyTimeout: 3600 * 1000,
  28. ConnectCheck: 600 * 1000,
  29. }
  30. }