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: fix the problem of session #98

Merged
merged 1 commit into from
Apr 13, 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
5 changes: 5 additions & 0 deletions ccore/nebula/client_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type (
Close() error
Factory() Factory
Version() Version
GetTimezoneInfo() types.TimezoneInfo
}

defaultGraphClient defaultClient
Expand All @@ -34,6 +35,10 @@ func NewGraphClient(endpoints []string, username, password string, opts ...Optio
return c.Graph(), nil
}

func (c *defaultGraphClient) GetTimezoneInfo() types.TimezoneInfo {
return c.graph.GetTimezoneInfo()
}

func (c *defaultGraphClient) Open() error {
return c.defaultClient().initDriver(func(driver types.Driver) error {
return c.graph.open(driver)
Expand Down
8 changes: 7 additions & 1 deletion ccore/nebula/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type (
username string
password string
sessionId int64
timezone types.TimezoneInfo
}

driverMeta struct {
Expand Down Expand Up @@ -105,13 +106,18 @@ func (d *driverGraph) open(driver types.Driver) error {
panic("sessionId can not be nil after authenticate")
}
d.sessionId = *sessionId

d.timezone = resp.GetTimezoneInfo()
d.GraphClientDriver = graphClientDriver
return nil
}

func (d *driverGraph) GetTimezoneInfo() types.TimezoneInfo {
return d.timezone
Copy link
Contributor

@kqzh kqzh Apr 13, 2022

Choose a reason for hiding this comment

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

set d.timezone in func open()? now there is don't have it

}

func (d *driverGraph) close() error {
if d.GraphClientDriver != nil {
d.GraphClientDriver.Signout(d.sessionId)
if err := d.GraphClientDriver.Close(); err != nil {
return err
}
Expand Down
17 changes: 3 additions & 14 deletions ccore/nebula/gateway/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Client struct {
updateTime int64
parameterMap types.ParameterMap
account *Account
timezone types.TimezoneInfo
}

type ClientInfo struct {
Expand Down Expand Up @@ -239,6 +240,7 @@ func NewClient(address string, port int, username string, password string, opts
username: username,
password: password,
},
timezone: c.GetTimezoneInfo(),
}
clientPool[ncid] = client
currentClientNum++
Expand Down Expand Up @@ -286,19 +288,6 @@ func handleRequest(ncid string) {
}

if len(request.Gql) > 0 {
// use auth response to get timezone info
authResp, err := client.graphClient.Authenticate(client.account.username, client.account.password)
if err != nil {
if isThriftProtoError(err) || isThriftTransportError(err) {
err = fmt.Errorf("%s. %s.\n", err.Error(), InterruptError.Error())
}
request.ResponseChannel <- ChannelResponse{
Result: nil,
Error: err,
}
return
}

execResponse, err := client.graphClient.ExecuteWithParameter([]byte(request.Gql), client.parameterMap)
if err != nil {
if isThriftProtoError(err) || isThriftTransportError(err) {
Expand All @@ -311,7 +300,7 @@ func handleRequest(ncid string) {
return
}

res, err := wrapper.GenResultSet(execResponse, client.graphClient.Factory(), authResp.GetTimezoneInfo())
res, err := wrapper.GenResultSet(execResponse, client.graphClient.Factory(), client.timezone)
if err != nil {
err = fmt.Errorf("%s. %s.\n", err.Error(), InterruptError.Error())
}
Expand Down