FIFO ordering of input events (#1386)

* Initial FIFOing of roomserver inputs

* Remove EventID response from api.InputRoomEventsResponse

* Don't send back event ID unnecessarily

* Fix ordering hopefully

* Reduce copies, use buffered task channel to reduce contention on other rooms

* Fix error handling
This commit is contained in:
Neil Alexander 2020-09-03 15:22:16 +01:00 committed by GitHub
parent 74743ac8ae
commit 6150de6cb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 99 additions and 46 deletions

View file

@ -83,5 +83,4 @@ type InputRoomEventsRequest struct {
// InputRoomEventsResponse is a response to InputRoomEvents
type InputRoomEventsResponse struct {
EventID string `json:"event_id"`
}

View file

@ -26,7 +26,7 @@ import (
func SendEvents(
ctx context.Context, rsAPI RoomserverInternalAPI, events []gomatrixserverlib.HeaderedEvent,
sendAsServer gomatrixserverlib.ServerName, txnID *TransactionID,
) (string, error) {
) error {
ires := make([]InputRoomEvent, len(events))
for i, event := range events {
ires[i] = InputRoomEvent{
@ -77,19 +77,16 @@ func SendEventWithState(
StateEventIDs: stateEventIDs,
})
_, err = SendInputRoomEvents(ctx, rsAPI, ires)
return err
return SendInputRoomEvents(ctx, rsAPI, ires)
}
// SendInputRoomEvents to the roomserver.
func SendInputRoomEvents(
ctx context.Context, rsAPI RoomserverInternalAPI, ires []InputRoomEvent,
) (eventID string, err error) {
) error {
request := InputRoomEventsRequest{InputRoomEvents: ires}
var response InputRoomEventsResponse
err = rsAPI.InputRoomEvents(ctx, &request, &response)
eventID = response.EventID
return
return rsAPI.InputRoomEvents(ctx, &request, &response)
}
// SendInvite event to the roomserver.