Use the Transaction interface from common

This commit is contained in:
Mark Haines 2017-08-21 15:44:33 +01:00
parent 76c7f176e0
commit 5d785f038b

View file

@ -16,6 +16,7 @@
package types package types
import ( import (
"github.com/matrix-org/dendrite/common"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
) )
@ -135,14 +136,6 @@ type StateEntryList struct {
StateEntries []StateEntry StateEntries []StateEntry
} }
// A Transaction is something that can be committed or rolledback.
type Transaction interface {
// Commit the transaction
Commit() error
// Rollback the transaction.
Rollback() error
}
// A RoomRecentEventsUpdater is used to update the recent events in a room. // A RoomRecentEventsUpdater is used to update the recent events in a room.
// (On postgresql this wraps a database transaction that holds a "FOR UPDATE" // (On postgresql this wraps a database transaction that holds a "FOR UPDATE"
// lock on the row in the rooms table holding the latest events for the room.) // lock on the row in the rooms table holding the latest events for the room.)
@ -175,7 +168,7 @@ type RoomRecentEventsUpdater interface {
// It will share the same transaction as this updater. // It will share the same transaction as this updater.
MembershipUpdater(targetUserNID EventStateKeyNID) (MembershipUpdater, error) MembershipUpdater(targetUserNID EventStateKeyNID) (MembershipUpdater, error)
// Implements Transaction so it can be committed or rolledback // Implements Transaction so it can be committed or rolledback
Transaction common.Transaction
} }
// A MembershipUpdater is used to update the membership of a user in a room. // A MembershipUpdater is used to update the membership of a user in a room.
@ -200,7 +193,7 @@ type MembershipUpdater interface {
// Returns a list of invite event IDs that this state change retired. // Returns a list of invite event IDs that this state change retired.
SetToLeave(senderUserID string) (inviteEventIDs []string, err error) SetToLeave(senderUserID string) (inviteEventIDs []string, err error)
// Implements Transaction so it can be committed or rolledback. // Implements Transaction so it can be committed or rolledback.
Transaction common.Transaction
} }
// A MissingEventError is an error that happened because the roomserver was // A MissingEventError is an error that happened because the roomserver was