diff --git a/Makefile b/Makefile index 4f6ca28..92ea21a 100644 --- a/Makefile +++ b/Makefile @@ -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 ` ;\ diff --git a/README.md b/README.md index cc90578..447bc8d 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/go.mod b/go.mod index 0432a3b..80de94f 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index e2b64aa..2f6b6f3 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/nebulagraph/client.go b/pkg/nebulagraph/client.go index 2b340d2..5ebbd9f 100644 --- a/pkg/nebulagraph/client.go +++ b/pkg/nebulagraph/client.go @@ -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):