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: connection timeout #376

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or u can use const.


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