This commit is contained in:
parent
bb07b9d61b
commit
df799e679a
@ -50,9 +50,12 @@ func main() {
|
||||
pusher.InitClient("pusher", client.WithHostPorts("pusher:8080"))
|
||||
|
||||
// 代理池
|
||||
pool := proxy.NewProxyPool(cfg.Proxy.Subscribes)
|
||||
pool, err := proxy.InitDefaultProxyPool()
|
||||
if err != nil {
|
||||
glog.Fatalf("初始化代理池失败:%v", err)
|
||||
}
|
||||
|
||||
go pool.CronUpdate(ctx, cfg.Proxy.Interval) //定时更新代理
|
||||
go pool.CronUpdate(ctx) //定时更新代理
|
||||
|
||||
// coach client
|
||||
cli := coach_client.USClient(pool)
|
||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.22.2
|
||||
toolchain go1.22.3
|
||||
|
||||
require (
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241203012724-2cc7b5cfb70a
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241204113257-ab2c85f42fe0
|
||||
gitea.timerzz.com/kedaya_haitao/pusher v0.0.0-20241129135359-c16e02a7eab0
|
||||
github.com/cloudwego/kitex v0.11.3
|
||||
github.com/gofiber/fiber/v3 v3.0.0-beta.3
|
||||
|
4
go.sum
4
go.sum
@ -1,6 +1,10 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241203012724-2cc7b5cfb70a h1:BfHVMbA29/0KLg4Nv0PQVnca1pwJp7EQqjsth6A0CBY=
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241203012724-2cc7b5cfb70a/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241204113022-f3d77b581683 h1:nYEQnTZ00MGP5RgfgYLj0GTJdFlMoLbcIVFH+FyYPwE=
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241204113022-f3d77b581683/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241204113257-ab2c85f42fe0 h1:ND9BfeFQVXXd14nzSuJuDGBIrTYPcMvWQVkZ/C2Wc6M=
|
||||
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241204113257-ab2c85f42fe0/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
|
||||
gitea.timerzz.com/kedaya_haitao/pusher v0.0.0-20241129135359-c16e02a7eab0 h1:WMNOErbI6At865VWI3sN74RMQaZ8ZhwsNSB9A4vg/6Q=
|
||||
gitea.timerzz.com/kedaya_haitao/pusher v0.0.0-20241129135359-c16e02a7eab0/go.mod h1:nRdxwOP3hhkUdH3PjHq3gt8SA+YEfR/d7Ig9DuQQZQY=
|
||||
github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08=
|
||||
|
@ -6,19 +6,11 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
|
||||
v2 "gitea.timerzz.com/kedaya_haitao/common/structs/v2"
|
||||
"github.com/golang/glog"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const (
|
||||
ProxyConfigEnv = "PROXY_CONFIG_PATH"
|
||||
DefaultProxyConfigPath = "/cfg/proxy.yaml"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Proxy proxy.Option `yaml:"proxy"`
|
||||
ProviderId v2.ProviderId `yaml:"provider_id"`
|
||||
WatchInterval time.Duration
|
||||
AtsInterval time.Duration
|
||||
@ -47,15 +39,5 @@ func LoadConfigs() (opt *Config, err error) {
|
||||
}
|
||||
|
||||
glog.Infof("加载watch interval %s\nats interval %s\nats threshold %d", opt.WatchInterval, opt.AtsInterval, opt.AtsThreshold)
|
||||
// 加载代理配置
|
||||
cfgPath := os.Getenv(ProxyConfigEnv)
|
||||
if cfgPath == "" {
|
||||
cfgPath = DefaultProxyConfigPath
|
||||
}
|
||||
f, err := os.Open(cfgPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
return opt, yaml.NewDecoder(f).Decode(&opt.Proxy)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user