Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix timeout #46

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 {} +
@@ -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 ` ;\
@@ -35,16 +36,19 @@ 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/xk6@v0.4.1
$(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}
# if replace nebula-go, need to change nebula-go path
# $(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;
$(GOPATH)/bin/xk6 build $(K6_VERSION) --with github.com/vesoft-inc/k6-plugin@latest=${PWD}/../k6-plugin ;

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 ` ;\
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
@@ -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=
35 changes: 19 additions & 16 deletions pkg/nebulagraph/client.go
Original file line number Diff line number Diff line change
@@ -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
@@ -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):