Skip to content

Commit

Permalink
Add timeout options for http and nebula graph connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu committed Apr 21, 2020
1 parent 976b908 commit 329c29e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package client

import (
"time"

nebula "github.com/vesoft-inc/nebula-go"
)

func NewNebulaConnection(addr, user, password string) (*nebula.GraphClient, error) {
client, err := nebula.NewClient(addr)
opts := nebula.WithTimeout(10 * time.Second)
client, err := nebula.NewClient(addr, opts)
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"strings"
"time"

"github.com/vesoft-inc/nebula-importer/pkg/base"
"github.com/vesoft-inc/nebula-importer/pkg/config"
Expand Down Expand Up @@ -92,7 +93,9 @@ func (r *FileReader) prepareDataFile() (*string, error) {
}
defer file.Close()

resp, err := http.Get(*r.File.Path)
client := http.Client{Timeout: 2 * time.Second}

resp, err := client.Get(*r.File.Path)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 329c29e

Please sign in to comment.