init.go 787 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package hook
  2. import (
  3. "github.com/imroc/req/v3"
  4. "time"
  5. )
  6. type Hook struct {
  7. ServerIp string
  8. AdminPort string
  9. WxPort string
  10. Client *req.Client
  11. }
  12. func NewHook(serverIp string, adminPort string, WxPort string) *Hook {
  13. client := req.C().DevMode()
  14. client.SetCommonRetryCount(2).
  15. SetCommonRetryBackoffInterval(1*time.Second, 5*time.Second).
  16. SetCommonRetryFixedInterval(2 * time.Second).SetTimeout(30 * time.Second)
  17. return &Hook{
  18. ServerIp: serverIp,
  19. AdminPort: adminPort,
  20. WxPort: WxPort,
  21. Client: req.C().DevMode(),
  22. }
  23. }
  24. func (h *Hook) setServerIp(ip string) *Hook {
  25. h.ServerIp = ip
  26. return h
  27. }
  28. func (h *Hook) setAdminPort(port string) *Hook {
  29. h.AdminPort = port
  30. return h
  31. }
  32. func (h *Hook) setWxPort(port string) *Hook {
  33. h.WxPort = port
  34. return h
  35. }