Skip to content

Commit

Permalink
fix timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisChu committed Jul 26, 2023
1 parent ffbf0a9 commit faed551
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pairs := darwin/amd64 linux/amd64 linux/arm64
GOPATH ?= ~/go
export GO111MODULE=on
K6_VERSION ?= v0.43.0
XK6_VERSION ?= v0.9.2

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

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

build-all: build-arm-v7

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

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

build-dev:
go install github.com/k6io/xk6/cmd/[email protected]
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@latest=${PWD}/../k6-plugin;
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@latest=${PWD}/../k6-plugin \
--replace github.com/vesoft-inc/nebula-go/v3=/home/Harris.chu/code/nebula-go;

build-dev-all:
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
go install go.k6.io/xk6/cmd/xk6@${XK6_VERSION}
for pair in $(pairs);do echo $$pair; \
os=`echo $$pair | cut -d / -f 1 ` ;\
arch=`echo $$pair | cut -d / -f 2 ` ;\
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Then:
1. Download `xk6`:

```bash
go install github.com/k6io/xk6/cmd/xk6@v0.4.1
go install go.k6.io/xk6/cmd/xk6@v0.9.2
```

2. Build the binary:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.16
require (
github.com/go-echarts/go-echarts/v2 v2.2.4
github.com/spf13/cobra v1.4.0
github.com/vesoft-inc/nebula-go/v3 v3.4.0-1.0.20230412100133-fae48de712b6
github.com/vesoft-inc/nebula-go/v3 v3.5.0
go.k6.io/k6 v0.43.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhso
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/vesoft-inc/nebula-go/v3 v3.4.0-1.0.20230412100133-fae48de712b6 h1:FOhQdJQixo6hd++kKwHHi3QN7MuwesLFkRnenPM/u7E=
github.com/vesoft-inc/nebula-go/v3 v3.4.0-1.0.20230412100133-fae48de712b6/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
github.com/vesoft-inc/nebula-go/v3 v3.5.0 h1:2ZSkoBxtIfs15AXJXqrAPDPd0Z9HrzKR7YKXPqlJcR0=
github.com/vesoft-inc/nebula-go/v3 v3.5.0/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
35 changes: 19 additions & 16 deletions pkg/nebulagraph/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,21 @@ func (gc *GraphClient) executeRetry(stmt string) (*graph.ResultSet, error) {
)
start := time.Now()
for i := 0; i < gc.Pool.graphOption.RetryTimes+1; i++ {
if gc.Pool.graphOption.RetryIntervalUs != 0 &&
time.Since(start).Microseconds() > int64(gc.Pool.graphOption.RetryTimeoutUs) {
return resp, err
}

if gc.Client != nil {
resp, err = gc.Client.Execute(stmt)
} else {
resp, err = gc.Pool.sessPool.Execute(stmt)
}

if gc.Pool.graphOption.RetryIntervalUs != 0 &&
time.Since(start).Microseconds() > int64(gc.Pool.graphOption.RetryTimeoutUs) {
return resp, fmt.Errorf("retry timeout")
}
if err != nil {
fmt.Println("execute error: ", err)
continue
}

graphErr := resp.GetErrorCode()
if graphErr == graph.ErrorCode_SUCCEEDED {
return resp, nil
Expand Down Expand Up @@ -394,22 +395,24 @@ func (gc *GraphClient) Execute(stmt string) (common.IGraphResponse, error) {
return result, nil
}

var fr []string
columns := resp.GetColSize()
if o.rows != 0 {
r, err := resp.GetRowValuesByIndex(0)
if err != nil {
return nil, err
}
for i := 0; i < columns; i++ {
v, err := r.GetValueByIndex(i)
if resp != nil {
var fr []string
columns := resp.GetColSize()
if o.rows != 0 {
r, err := resp.GetRowValuesByIndex(0)
if err != nil {
return nil, err
}
fr = append(fr, v.String())
for i := 0; i < columns; i++ {
v, err := r.GetValueByIndex(i)
if err != nil {
return nil, err
}
fr = append(fr, v.String())
}
}
o.firstRecord = strings.Join(fr, "|")
}
o.firstRecord = strings.Join(fr, "|")

select {
case gc.Pool.OutputCh <- formatOutput(o):
Expand Down

0 comments on commit faed551

Please sign in to comment.