-
Notifications
You must be signed in to change notification settings - Fork 32
/
done.go
executable file
·47 lines (41 loc) · 931 Bytes
/
done.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"time"
"strconv"
"github.com/henrylee2cn/surfer"
)
var notice = make(chan string, 10000)
func loopDoneNotice() {
for {
select {
case temp := <-notice:
resp, err := surfer.Download(&surfer.Request{
Url: temp,
//DownloaderID: 1,
})
if err != nil {
time.Sleep(time.Second)
notice <- temp
}
resp.Body.Close()
}
}
}
func (self *data) done() {
u := dataNotice + strconv.Itoa(self.Type) + "/" + strconv.Itoa(self.Issue)
resp, err := surfer.Download(&surfer.Request{
Url: u,
//DownloaderID: 1,
})
if err != nil {
fmt.Println("done() 22:", err)
time.Sleep(time.Second)
notice <- u
return
}
defer resp.Body.Close()
defer surfer.DestroyJsFiles()
redisClient.Set("Client_"+strconv.Itoa(self.Type)+"_"+strconv.Itoa(self.Issue), self.Data, time.Minute*30)
fmt.Println(time.Now(), " 成功入库:", " ", self.Type, self.Issue, " ", self.Data)
}