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

return an error from the saga store when deleting a saga if the instance can not be found #110

Merged
merged 1 commit into from
Aug 4, 2019
Merged
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
13 changes: 11 additions & 2 deletions gbus/tx/sagastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"database/sql"
"encoding/gob"
"errors"
"fmt"
"reflect"
"regexp"
Expand Down Expand Up @@ -116,8 +117,16 @@ func (store *SagaStore) RegisterSagaType(saga gbus.Saga) {
func (store *SagaStore) DeleteSaga(tx *sql.Tx, instance *saga.Instance) error {
tblName := store.GetSagatableName()
deleteSQL := `DELETE FROM ` + tblName + ` WHERE saga_id= ?`
_, err := tx.Exec(deleteSQL, instance.ID)
return err
result, err := tx.Exec(deleteSQL, instance.ID)
if err != nil {
return err
}
rowsEffected, e := result.RowsAffected()
if rowsEffected == 0 || e != nil {
return errors.New("couldn't delete saga, saga not found orr an error occurred")
}

return nil
}

//GetSagaByID implements interface method store.GetSagaByID
Expand Down