Skip to content

Commit 7113a67

Browse files
authored
Merge pull request #46 from HarrisChu/fix_timeout
fix timeout
2 parents ffbf0a9 + bb458b6 commit 7113a67

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pairs := darwin/amd64 linux/amd64 linux/arm64
55
GOPATH ?= ~/go
66
export GO111MODULE=on
77
K6_VERSION ?= v0.43.0
8+
XK6_VERSION ?= v0.9.2
89

910
fmt:
1011
find . -name '*.go' -exec gofmt -s -w {} +
@@ -13,13 +14,13 @@ lint :
1314
golangci-lint run --out-format=tab ./...
1415

1516
build:
16-
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
17+
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
1718
version=$(git describe --tags `git rev-list --tags --max-count=1`) \
18-
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@$(version);
19+
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@$(version) ;
1920

2021
build-all: build-arm-v7
2122

22-
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
23+
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
2324
for pair in $(pairs);do echo $$pair; \
2425
os=`echo $$pair | cut -d / -f 1 ` ;\
2526
arch=`echo $$pair | cut -d / -f 2 ` ;\
@@ -35,16 +36,19 @@ build-all: build-arm-v7
3536
done
3637

3738
build-arm-v7:
38-
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
39+
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
3940
GOOS=linux GOARCH=arm64 GOARM=7 $(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@$(VERSION);
4041
mv k6 k6-linux-arm64-v7
4142

4243
build-dev:
43-
go install github.com/k6io/xk6/cmd/[email protected]
44-
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@latest=${PWD}/../k6-plugin;
44+
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
45+
# if replace nebula-go, need to change nebula-go path
46+
# $(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@latest=${PWD}/../k6-plugin \
47+
# --replace github.com/vesoft-inc/nebula-go/v3=/home/Harris.chu/code/nebula-go;
48+
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@latest=${PWD}/../k6-plugin ;
4549

4650
build-dev-all:
47-
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
51+
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
4852
for pair in $(pairs);do echo $$pair; \
4953
os=`echo $$pair | cut -d / -f 1 ` ;\
5054
arch=`echo $$pair | cut -d / -f 2 ` ;\

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Then:
2626
1. Download `xk6`:
2727

2828
```bash
29-
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
29+
go install go.k6.io/xk6/cmd/xk6@v0.9.2
3030
```
3131

3232
2. Build the binary:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ go 1.16
55
require (
66
github.com/go-echarts/go-echarts/v2 v2.2.4
77
github.com/spf13/cobra v1.4.0
8-
github.com/vesoft-inc/nebula-go/v3 v3.4.0-1.0.20230412100133-fae48de712b6
8+
github.com/vesoft-inc/nebula-go/v3 v3.5.0
99
go.k6.io/k6 v0.43.0
1010
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso
332332
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
333333
github.com/vesoft-inc/nebula-go/v3 v3.4.0-1.0.20230412100133-fae48de712b6 h1:FOhQdJQixo6hd++kKwHHi3QN7MuwesLFkRnenPM/u7E=
334334
github.com/vesoft-inc/nebula-go/v3 v3.4.0-1.0.20230412100133-fae48de712b6/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
335+
github.com/vesoft-inc/nebula-go/v3 v3.5.0 h1:2ZSkoBxtIfs15AXJXqrAPDPd0Z9HrzKR7YKXPqlJcR0=
336+
github.com/vesoft-inc/nebula-go/v3 v3.5.0/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
335337
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
336338
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
337339
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

pkg/nebulagraph/client.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -329,20 +329,21 @@ func (gc *GraphClient) executeRetry(stmt string) (*graph.ResultSet, error) {
329329
)
330330
start := time.Now()
331331
for i := 0; i < gc.Pool.graphOption.RetryTimes+1; i++ {
332-
if gc.Pool.graphOption.RetryIntervalUs != 0 &&
333-
time.Since(start).Microseconds() > int64(gc.Pool.graphOption.RetryTimeoutUs) {
334-
return resp, err
335-
}
332+
336333
if gc.Client != nil {
337334
resp, err = gc.Client.Execute(stmt)
338335
} else {
339336
resp, err = gc.Pool.sessPool.Execute(stmt)
340337
}
341-
338+
if gc.Pool.graphOption.RetryIntervalUs != 0 &&
339+
time.Since(start).Microseconds() > int64(gc.Pool.graphOption.RetryTimeoutUs) {
340+
return resp, fmt.Errorf("retry timeout")
341+
}
342342
if err != nil {
343343
fmt.Println("execute error: ", err)
344344
continue
345345
}
346+
346347
graphErr := resp.GetErrorCode()
347348
if graphErr == graph.ErrorCode_SUCCEEDED {
348349
return resp, nil
@@ -394,22 +395,24 @@ func (gc *GraphClient) Execute(stmt string) (common.IGraphResponse, error) {
394395
return result, nil
395396
}
396397

397-
var fr []string
398-
columns := resp.GetColSize()
399-
if o.rows != 0 {
400-
r, err := resp.GetRowValuesByIndex(0)
401-
if err != nil {
402-
return nil, err
403-
}
404-
for i := 0; i < columns; i++ {
405-
v, err := r.GetValueByIndex(i)
398+
if resp != nil {
399+
var fr []string
400+
columns := resp.GetColSize()
401+
if o.rows != 0 {
402+
r, err := resp.GetRowValuesByIndex(0)
406403
if err != nil {
407404
return nil, err
408405
}
409-
fr = append(fr, v.String())
406+
for i := 0; i < columns; i++ {
407+
v, err := r.GetValueByIndex(i)
408+
if err != nil {
409+
return nil, err
410+
}
411+
fr = append(fr, v.String())
412+
}
410413
}
414+
o.firstRecord = strings.Join(fr, "|")
411415
}
412-
o.firstRecord = strings.Join(fr, "|")
413416

414417
select {
415418
case gc.Pool.OutputCh <- formatOutput(o):

0 commit comments

Comments
 (0)