func WTaskConf2() { // 纠正协程数 if Input.ThreadNum == 0 { Input.ThreadNum = 1 } cache.Task.ThreadNum = Input.ThreadNum cache.Task.BaseSleeptime = Input.BaseSleeptime cache.Task.RandomSleepPeriod = Input.RandomSleepPeriod //随机暂停最大增益时长 cache.Task.OutType = Input.OutType cache.Task.DockerCap = Input.DockerCap //分段转储容器容量 // 选填项 cache.Task.MaxPage = Input.MaxPage cache.AutoDockerQueueCap() }
// 设置全局参数 func (self *Logic) SetAppConf(k string, v interface{}) App { defer func() { if err := recover(); err != nil { logs.Log.Error(fmt.Sprintf("%v", err)) } }() if k == "Limit" && v.(int64) <= 0 { v = int64(spider.LIMIT) } acv := reflect.ValueOf(self.AppConf).Elem() key := strings.Title(k) if acv.FieldByName(key).CanSet() { acv.FieldByName(key).Set(reflect.ValueOf(v)) } if k == "DockerCap" { cache.AutoDockerQueueCap() } return self }
func (self *Logic) SetDockerCap(dockerCap uint) App { cache.Task.DockerCap = dockerCap cache.AutoDockerQueueCap() return self }