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

updated statement execute to have retry logic #467

Merged
merged 1 commit into from
Mar 21, 2021
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
8 changes: 4 additions & 4 deletions pkg/api/cassandra_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ func (r *CassandraRepository) FindAll() ([]*Definition, error) {

var savedDef string

for iter.Scan(&savedDef) {
err := iter.ScanAndClose(func() bool {
var definition *Definition
err := json.Unmarshal([]byte(savedDef), &definition)
if err != nil {
log.Errorf("error trying to unmarshal definition json: %v", err)
return nil, err
return false
}
results = append(results, definition)
}
return true
}, &savedDef)

err := iter.Close()
if err != nil {
log.Errorf("error getting all definitions: %v", err)
}
Expand Down
13 changes: 5 additions & 8 deletions pkg/plugin/basic/cassandra_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func (r *CassandraRepository) FindAll() ([]*User, error) {
var username string
var password string

for iter.Scan(&username, &password) {
err := iter.ScanAndClose(func() bool {
var user User
user.Username = username
user.Password = password
results = append(results, &user)
}
return true
}, &username, &password)

err := iter.Close()
if err != nil {
log.Errorf("error getting all oauths: %v", err)
}
Expand All @@ -51,14 +51,11 @@ func (r *CassandraRepository) FindByUsername(username string) (*User, error) {

var user User

iter := r.session.GetSession().Query(
err := r.session.GetSession().Query(
"SELECT username, password " +
"FROM user " +
"WHERE username = ?",
username).Iter()

iter.Scan(&user.Username, &user.Password)
err := iter.Close()
username).Scan(&user.Username, &user.Password)

if err != nil {
log.Errorf("error selecting user %s: %v", username, err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/plugin/oauth2/cassandra_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ func (r *CassandraRepository) FindAll() ([]*OAuth, error) {

var savedOauth string

for iter.Scan(&savedOauth) {
err := iter.ScanAndClose(func() bool {
var oauth *OAuth
err := json.Unmarshal([]byte(savedOauth), &oauth)
if err != nil {
log.Errorf("error trying to unmarshal oauth json: %v", err)
return nil, err
return false
}
results = append(results, oauth)
}
return true
}, &savedOauth)

err := iter.Close()
if err != nil {
log.Errorf("error getting all oauths: %v", err)
}
Expand Down