func (w *hostWorkers) Init(db *content.DBrw, logger zap.Logger, baseHosts []string, cnt int) error { hostMng := &hostsManager{} err := hostMng.Init(db, baseHosts) if err != nil { return err } hosts := hostMng.GetHosts() w.workers = make([]*hostWorker, 0) cntPerHost := cnt / len(hosts) if cntPerHost < 1 { cntPerHost = 1 } for hostName, hostID := range hosts { worker := &hostWorker{Request: &request{hostMng: hostMng}} worker.Request.Init(logger.With(zap.String("host", hostName))) worker.Tasks, err = db.GetNewURLs(hostID, cntPerHost) if err != nil { return err } w.workers = append(w.workers, worker) } return nil }