From 75454c59ea4261e4528cc52c4ad58495d0a71825 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 21 Feb 2017 13:22:18 +0000 Subject: [PATCH] Rename Close to Commit and Rollback --- .../matrix-org/dendrite/roomserver/input/events.go | 2 +- .../dendrite/roomserver/input/latest_events.go | 4 ++-- .../matrix-org/dendrite/roomserver/storage/storage.go | 9 +++++---- .../matrix-org/dendrite/roomserver/types/types.go | 6 ++++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/events.go b/src/github.com/matrix-org/dendrite/roomserver/input/events.go index 4a0c82ec9..e146d5734 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/events.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/events.go @@ -35,7 +35,7 @@ type RoomEventDatabase interface { // Set the state at an event. SetState(eventNID types.EventNID, stateNID types.StateSnapshotNID) error // Lookup the latest events in a room in preparation for an update. - // The RoomRecentEventsUpdater must be closed if this doesn't return an error. + // The RoomRecentEventsUpdater must have Commit or Rollback called on it if this doesn't return an error. // If this returns an error then no further action is required. GetLatestEventsForUpdate(roomNID types.RoomNID) ([]types.StateAtEventAndReference, types.RoomRecentEventsUpdater, error) } diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go b/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go index 7a3c995f5..06c6ef2cf 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/latest_events.go @@ -19,11 +19,11 @@ func updateLatestEvents( // Commit if there wasn't an error. // Set the returned err value if we encounter an error committing. // This only works because err is a named return. - err = updater.Close(true) + err = updater.Commit() } else { // Ignore any error we get rolling back since we don't want to // clobber the current error - updater.Close(false) + updater.Rollback() } }() diff --git a/src/github.com/matrix-org/dendrite/roomserver/storage/storage.go b/src/github.com/matrix-org/dendrite/roomserver/storage/storage.go index fbd8490ff..a49d0d84f 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/storage/storage.go +++ b/src/github.com/matrix-org/dendrite/roomserver/storage/storage.go @@ -248,9 +248,10 @@ func (u *roomRecentEventsUpdater) SetLatestEvents(roomNID types.RoomNID, latest return u.d.statements.updateLatestEventNIDs(u.txn, roomNID, eventNIDs) } -func (u *roomRecentEventsUpdater) Close(commit bool) error { - if commit { - return u.txn.Commit() - } +func (u *roomRecentEventsUpdater) Commit() error { + return u.txn.Commit() +} + +func (u *roomRecentEventsUpdater) Rollback() error { return u.txn.Rollback() } diff --git a/src/github.com/matrix-org/dendrite/roomserver/types/types.go b/src/github.com/matrix-org/dendrite/roomserver/types/types.go index bdc85bf9b..e1f5e65cb 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/types/types.go +++ b/src/github.com/matrix-org/dendrite/roomserver/types/types.go @@ -136,6 +136,8 @@ type RoomRecentEventsUpdater interface { IsReferenced(eventReference gomatrixserverlib.EventReference) (bool, error) // Set the list of latest events for the room. SetLatestEvents(roomNID RoomNID, latest []StateAtEventAndReference) error - // Commit or Rollback the transaction. - Close(commit bool) error + // Commit the transaction + Commit() error + // Rollback the transaction. + Rollback() error }