mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 14:33:10 -06:00
Rename Close to Commit and Rollback
This commit is contained in:
parent
d4563ef6d3
commit
75454c59ea
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue