Skip to content

Commit

Permalink
fix: connection timeout (#376) (#381)
Browse files Browse the repository at this point in the history
Co-authored-by: Xiaolong Lu <[email protected]>
  • Loading branch information
github-actions[bot] and huaxiabuluo authored Nov 30, 2022
1 parent 5041ae7 commit ec43b20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion server/api/studio/pkg/auth/authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula"
"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/dao"
"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/pool"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/config"
Expand Down Expand Up @@ -38,6 +39,8 @@ type (
}
)

var GraphServiceConnectTimeout = 5 * time.Second

func CreateToken(authData *AuthData, config *config.Config) (string, error) {
now := time.Now()
expiresAt := now.Add(time.Duration(config.Auth.AccessExpire) * time.Second).Unix()
Expand Down Expand Up @@ -105,7 +108,8 @@ func ParseConnectDBParams(params *types.ConnectDBParams, config *config.Config)
}

username, password := loginInfo[0], loginInfo[1]
clientInfo, err := dao.Connect(params.Address, params.Port, username, password)
// set Graph Service connect timeout 5s, which is 0s default(means no timeout)
clientInfo, err := dao.Connect(params.Address, params.Port, username, password, nebula.WithGraphTimeout(GraphServiceConnectTimeout))
if err != nil {
return "", nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/samber/lo v1.28.2
github.com/vesoft-inc/go-pkg v0.0.0-20220714021138-c5edb9946837
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221114094653-748b8f063bb6
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221130062253-8ae8bd95d139
github.com/vesoft-inc/nebula-importer v1.0.1-0.20220719030708-8e376665042e
github.com/zeromicro/go-zero v1.3.3
)
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ github.com/vesoft-inc/go-pkg v0.0.0-20220714021138-c5edb9946837/go.mod h1:HCAXRh
github.com/vesoft-inc/nebula-go/v3 v3.0.0-20220425030225-cdb52399b40a/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
github.com/vesoft-inc/nebula-go/v3 v3.2.0 h1:f0IW6W5f91O6FyXAi+kFq1D2bNFXtPtkb/H9WywFGmM=
github.com/vesoft-inc/nebula-go/v3 v3.2.0/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221114094653-748b8f063bb6 h1:y4H+PmtU9JnmFw7KmaFb3Ha8B2EuG2HdQnoG0RbcKNo=
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221114094653-748b8f063bb6/go.mod h1:sFEvE+cY4TgwqWx6H6msOqAUzRhsEHHKaaMgIZENHuQ=
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221130062253-8ae8bd95d139 h1:wzIe4IyCZ4+BwM2F4wdJoERxjZf4/pVLJcMhMqgaRys=
github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20221130062253-8ae8bd95d139/go.mod h1:sFEvE+cY4TgwqWx6H6msOqAUzRhsEHHKaaMgIZENHuQ=
github.com/vesoft-inc/nebula-importer v1.0.1-0.20220719030708-8e376665042e h1:Xj3N5lfKv+mG59Fh2GoWZ/89kWEwQtW/W4EiKkD2yI0=
github.com/vesoft-inc/nebula-importer v1.0.1-0.20220719030708-8e376665042e/go.mod h1:8xAQi6KI2qe40Dop/GqDXmBEurt7qGp5Pjd1MESAVNA=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
Expand Down

0 comments on commit ec43b20

Please sign in to comment.