Log tweaks, typing fixed?

This commit is contained in:
Neil Alexander 2021-01-06 16:54:27 +00:00
parent 9ead2d96e2
commit a588f9061b
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
5 changed files with 21 additions and 14 deletions

View file

@ -79,6 +79,7 @@ func (p *PDUStreamProvider) CompleteSync(
return to return to
} }
req.Response.Rooms.Join[roomID] = *jr req.Response.Rooms.Join[roomID] = *jr
req.Rooms[roomID] = gomatrixserverlib.Join
} }
// Add peeked rooms. // Add peeked rooms.

View file

@ -16,7 +16,10 @@ func (p *TypingStreamProvider) CompleteSync(
ctx context.Context, ctx context.Context,
req *types.SyncRequest, req *types.SyncRequest,
) types.StreamPosition { ) types.StreamPosition {
return p.IncrementalSync(ctx, req, 0, p.LatestPosition(ctx)) // It isn't beneficial to send previous typing notifications
// after a complete sync, so just return the latest position
// and otherwise do nothing.
return p.LatestPosition(ctx)
} }
func (p *TypingStreamProvider) IncrementalSync( func (p *TypingStreamProvider) IncrementalSync(

View file

@ -25,6 +25,7 @@ import (
userapi "github.com/matrix-org/dendrite/userapi/api" userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util" "github.com/matrix-org/util"
"github.com/sirupsen/logrus"
) )
const defaultSyncTimeout = time.Duration(0) const defaultSyncTimeout = time.Duration(0)
@ -74,10 +75,20 @@ func newSyncRequest(req *http.Request, device userapi.Device, syncDB storage.Dat
} }
} }
} }
// TODO: Additional query params: set_presence, filter // TODO: Additional query params: set_presence, filter
logger := util.GetLogger(req.Context()).WithFields(logrus.Fields{
"user_id": device.UserID,
"device_id": device.ID,
"since": since,
"timeout": timeout,
"limit": timelineLimit,
})
return &types.SyncRequest{ return &types.SyncRequest{
Context: req.Context(), // Context: req.Context(), //
Log: logger, //
Device: &device, // Device: &device, //
Response: types.NewResponse(), // Populated by all streams Response: types.NewResponse(), // Populated by all streams
Filter: gomatrixserverlib.DefaultEventFilter(), // Filter: gomatrixserverlib.DefaultEventFilter(), //

View file

@ -35,7 +35,6 @@ import (
userapi "github.com/matrix-org/dendrite/userapi/api" userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/util" "github.com/matrix-org/util"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
) )
// RequestPool manages HTTP long-poll connections for /sync // RequestPool manages HTTP long-poll connections for /sync
@ -156,14 +155,6 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
} }
} }
logger := util.GetLogger(req.Context()).WithFields(log.Fields{
"user_id": device.UserID,
"device_id": device.ID,
"since": syncReq.Since,
"timeout": syncReq.Timeout,
"limit": syncReq.Limit,
})
activeSyncRequests.Inc() activeSyncRequests.Inc()
defer activeSyncRequests.Dec() defer activeSyncRequests.Dec()
@ -197,10 +188,10 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
case <-rp.deviceListStream.NotifyAfter(waitctx, syncReq.Since.DeviceListPosition): case <-rp.deviceListStream.NotifyAfter(waitctx, syncReq.Since.DeviceListPosition):
} }
logger.Println("Responding to sync after wakeup") syncReq.Log.Println("Responding to sync after wakeup")
waitcancel() waitcancel()
} else { } else {
logger.Println("Responding to sync immediately") syncReq.Log.Println("Responding to sync immediately")
} }
if syncReq.Since.IsEmpty() { if syncReq.Since.IsEmpty() {

View file

@ -6,10 +6,12 @@ import (
userapi "github.com/matrix-org/dendrite/userapi/api" userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
) )
type SyncRequest struct { type SyncRequest struct {
Context context.Context Context context.Context
Log *logrus.Entry
Device *userapi.Device Device *userapi.Device
Response *Response Response *Response
Filter gomatrixserverlib.EventFilter Filter gomatrixserverlib.EventFilter
@ -18,8 +20,7 @@ type SyncRequest struct {
Timeout time.Duration Timeout time.Duration
WantFullState bool WantFullState bool
// Below this line are items updated by the // Updated by the PDU stream.
// stream providers. Not thread-safe.
Rooms map[string]string Rooms map[string]string
} }