mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -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.
|
// Set the state at an event.
|
||||||
SetState(eventNID types.EventNID, stateNID types.StateSnapshotNID) error
|
SetState(eventNID types.EventNID, stateNID types.StateSnapshotNID) error
|
||||||
// Lookup the latest events in a room in preparation for an update.
|
// 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.
|
// If this returns an error then no further action is required.
|
||||||
GetLatestEventsForUpdate(roomNID types.RoomNID) ([]types.StateAtEventAndReference, types.RoomRecentEventsUpdater, error)
|
GetLatestEventsForUpdate(roomNID types.RoomNID) ([]types.StateAtEventAndReference, types.RoomRecentEventsUpdater, error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ func updateLatestEvents(
|
||||||
// Commit if there wasn't an error.
|
// Commit if there wasn't an error.
|
||||||
// Set the returned err value if we encounter an error committing.
|
// Set the returned err value if we encounter an error committing.
|
||||||
// This only works because err is a named return.
|
// This only works because err is a named return.
|
||||||
err = updater.Close(true)
|
err = updater.Commit()
|
||||||
} else {
|
} else {
|
||||||
// Ignore any error we get rolling back since we don't want to
|
// Ignore any error we get rolling back since we don't want to
|
||||||
// clobber the current error
|
// 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)
|
return u.d.statements.updateLatestEventNIDs(u.txn, roomNID, eventNIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *roomRecentEventsUpdater) Close(commit bool) error {
|
func (u *roomRecentEventsUpdater) Commit() error {
|
||||||
if commit {
|
|
||||||
return u.txn.Commit()
|
return u.txn.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *roomRecentEventsUpdater) Rollback() error {
|
||||||
return u.txn.Rollback()
|
return u.txn.Rollback()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,8 @@ type RoomRecentEventsUpdater interface {
|
||||||
IsReferenced(eventReference gomatrixserverlib.EventReference) (bool, error)
|
IsReferenced(eventReference gomatrixserverlib.EventReference) (bool, error)
|
||||||
// Set the list of latest events for the room.
|
// Set the list of latest events for the room.
|
||||||
SetLatestEvents(roomNID RoomNID, latest []StateAtEventAndReference) error
|
SetLatestEvents(roomNID RoomNID, latest []StateAtEventAndReference) error
|
||||||
// Commit or Rollback the transaction.
|
// Commit the transaction
|
||||||
Close(commit bool) error
|
Commit() error
|
||||||
|
// Rollback the transaction.
|
||||||
|
Rollback() error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue