Skip to content

Commit 70f808c

Browse files
authored
Merge pull request apache#20 from wangtuanjie/wtj
Wtj
2 parents c9dfe1d + 36cb649 commit 70f808c

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

go/src/pili.qiniu.com/api/flume.v1/client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,24 @@ type Client struct {
7070
var ErrNoInstance = errors.New("no instance")
7171

7272
func (p Client) Call(xl *xlog.Logger, urlPath string, events []Event) (err error) {
73+
7374
if len(events) == 0 {
7475
return
7576
} else if len(events) > MaxBatchSize {
7677
return ErrTooManyEvents
7778
}
78-
pr, pw := io.Pipe()
79-
go func() {
80-
err := json.NewEncoder(pw).Encode(events)
81-
pw.CloseWithError(err)
82-
}()
8379

8480
hidx, obj := p.hosts.Select(xl)
8581
if obj == nil {
8682
return ErrNoInstance
8783
}
8884

85+
pr, pw := io.Pipe()
86+
go func() {
87+
err := json.NewEncoder(pw).Encode(events)
88+
pw.CloseWithError(err)
89+
}()
90+
8991
defer func() {
9092
if err != nil {
9193
p.hosts.OnFailure(hidx)

go/src/pili.qiniu.com/app/pili-dsync/main.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,28 @@ package main
22

33
import (
44
"flag"
5+
"net/http"
6+
_ "net/http/pprof"
57
"runtime"
68

9+
"github.com/qiniu/log.v1"
710
"pili.qiniu.com/dsync.v1"
811
)
912

1013
func main() {
1114

12-
runtime.GOMAXPROCS(2)
1315
c := flag.String("f", "pili-dsync.conf", "<config file>")
16+
pprof := flag.String("pprof", "", "<pprof addr>")
17+
18+
flag.Parse()
19+
20+
if *pprof != "" {
21+
log.Info("pprof running at:", *pprof)
22+
go func() {
23+
log.Println(http.ListenAndServe(*pprof, nil))
24+
}()
25+
}
26+
27+
runtime.GOMAXPROCS(2)
1428
dsync.Main(*c)
1529
}

0 commit comments

Comments
 (0)