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

Support retry times sessionpool #353

Closed
Closed
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
8 changes: 8 additions & 0 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ func WithHandshakeKey(handshakeKey string) SessionPoolConfOption {
conf.handshakeKey = handshakeKey
}
}
func WithRetryTimes(retryTimes int) SessionPoolConfOption {
if retryTimes < 0 {
retryTimes = 0
}
return func(conf *SessionPoolConf) {
conf.retryGetSessionTimes = retryTimes
}
}

func (conf *SessionPoolConf) checkMandatoryFields() error {
// Check mandatory fields
Expand Down
8 changes: 7 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ func (cn *connection) executeWithParameter(sessionID int64, stmt string,
return resp, nil
}

func (cn *connection) executeWithParameterTimeout(sessionID int64, stmt string, params map[string]*nebula.Value, timeoutMs int64) (*graph.ExecutionResponse, error) {
return cn.graph.ExecuteWithTimeout(sessionID, []byte(stmt), params, timeoutMs)
}

func (cn *connection) executeJson(sessionID int64, stmt string) ([]byte, error) {
return cn.ExecuteJsonWithParameter(sessionID, stmt, map[string]*nebula.Value{})
}
Expand Down Expand Up @@ -228,5 +232,7 @@ func (cn *connection) release() {

// Close transport
func (cn *connection) close() {
cn.graph.Close()
if cn.graph.IsOpen() {
cn.graph.Close()
}
}
Loading
Loading