Skip to content

Commit

Permalink
Merge pull request #46 from HarrisChu/fix_timeout
Browse files Browse the repository at this point in the history
fix timeout
  • Loading branch information
HarrisChu authored Aug 15, 2023
2 parents ffbf0a9 + bb458b6 commit 7113a67
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
18 changes: 11 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,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 ` ;\
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 7113a67

Please sign in to comment.