mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-13 13:42:29 +08:00
up
This commit is contained in:
@@ -2,7 +2,9 @@ package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"project/pb"
|
||||
"project/util"
|
||||
"project/zj"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -10,6 +12,7 @@ import (
|
||||
|
||||
type row struct {
|
||||
hash [16]byte
|
||||
hr *http.Request
|
||||
req *pb.Req
|
||||
rsp []byte
|
||||
err error
|
||||
@@ -25,7 +28,10 @@ func (pr *row) run() {
|
||||
s := fmt.Sprintf(`%x, %s`, pr.hash, pr.t.Format(`2006-01-02 15:04:05`))
|
||||
zj.J(`new`, s)
|
||||
|
||||
pr.rsp = []byte(s)
|
||||
pr.rsp, pr.err = fetchRemote(pr.req)
|
||||
go pr.saveFile()
|
||||
go pr.metrics()
|
||||
|
||||
pr.done = true
|
||||
pr.mux.Unlock()
|
||||
}
|
||||
@@ -36,3 +42,14 @@ func (pr *row) wait() {
|
||||
pr.mux.RUnlock()
|
||||
}
|
||||
}
|
||||
|
||||
func (pr *row) saveFile() {
|
||||
rspFile := util.CacheName(pr.req.Hash()) + `-rsp.json`
|
||||
if !util.FileExists(rspFile) {
|
||||
util.WriteFile(rspFile, pr.rsp)
|
||||
zj.J(rspFile)
|
||||
}
|
||||
}
|
||||
|
||||
func (pr *row) metrics() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user