mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-25 21:21:35 +00:00
3a156a434a
* Bypass lazyLoadCache if we're doing an initial sync * Make the linter happy again? * Revert "Make the linter happy again?" This reverts commit 52a5691ba3c17c05698bcc6a13092090f27ace63. * Try that again * Invalidate LazyLoadCache on initial syncs * Remove unneeded check * Add TODO * Rename Invalite -> InvalidateLazyLoadedUser * Thanks IDE
96 lines
3.4 KiB
Go
96 lines
3.4 KiB
Go
package streams
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/matrix-org/dendrite/internal/caching"
|
|
keyapi "github.com/matrix-org/dendrite/keyserver/api"
|
|
rsapi "github.com/matrix-org/dendrite/roomserver/api"
|
|
"github.com/matrix-org/dendrite/syncapi/notifier"
|
|
"github.com/matrix-org/dendrite/syncapi/storage"
|
|
"github.com/matrix-org/dendrite/syncapi/types"
|
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
|
)
|
|
|
|
type Streams struct {
|
|
PDUStreamProvider types.StreamProvider
|
|
TypingStreamProvider types.StreamProvider
|
|
ReceiptStreamProvider types.StreamProvider
|
|
InviteStreamProvider types.StreamProvider
|
|
SendToDeviceStreamProvider types.StreamProvider
|
|
AccountDataStreamProvider types.StreamProvider
|
|
DeviceListStreamProvider types.StreamProvider
|
|
NotificationDataStreamProvider types.StreamProvider
|
|
PresenceStreamProvider types.StreamProvider
|
|
}
|
|
|
|
func NewSyncStreamProviders(
|
|
d storage.Database, userAPI userapi.SyncUserAPI,
|
|
rsAPI rsapi.SyncRoomserverAPI, keyAPI keyapi.SyncKeyAPI,
|
|
eduCache *caching.EDUCache, lazyLoadCache caching.LazyLoadCache, notifier *notifier.Notifier,
|
|
) *Streams {
|
|
streams := &Streams{
|
|
PDUStreamProvider: &PDUStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
lazyLoadCache: lazyLoadCache,
|
|
rsAPI: rsAPI,
|
|
notifier: notifier,
|
|
},
|
|
TypingStreamProvider: &TypingStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
EDUCache: eduCache,
|
|
},
|
|
ReceiptStreamProvider: &ReceiptStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
},
|
|
InviteStreamProvider: &InviteStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
},
|
|
SendToDeviceStreamProvider: &SendToDeviceStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
},
|
|
AccountDataStreamProvider: &AccountDataStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
userAPI: userAPI,
|
|
},
|
|
NotificationDataStreamProvider: &NotificationDataStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
},
|
|
DeviceListStreamProvider: &DeviceListStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
rsAPI: rsAPI,
|
|
keyAPI: keyAPI,
|
|
},
|
|
PresenceStreamProvider: &PresenceStreamProvider{
|
|
StreamProvider: StreamProvider{DB: d},
|
|
notifier: notifier,
|
|
},
|
|
}
|
|
|
|
streams.PDUStreamProvider.Setup()
|
|
streams.TypingStreamProvider.Setup()
|
|
streams.ReceiptStreamProvider.Setup()
|
|
streams.InviteStreamProvider.Setup()
|
|
streams.SendToDeviceStreamProvider.Setup()
|
|
streams.AccountDataStreamProvider.Setup()
|
|
streams.NotificationDataStreamProvider.Setup()
|
|
streams.DeviceListStreamProvider.Setup()
|
|
streams.PresenceStreamProvider.Setup()
|
|
|
|
return streams
|
|
}
|
|
|
|
func (s *Streams) Latest(ctx context.Context) types.StreamingToken {
|
|
return types.StreamingToken{
|
|
PDUPosition: s.PDUStreamProvider.LatestPosition(ctx),
|
|
TypingPosition: s.TypingStreamProvider.LatestPosition(ctx),
|
|
ReceiptPosition: s.ReceiptStreamProvider.LatestPosition(ctx),
|
|
InvitePosition: s.InviteStreamProvider.LatestPosition(ctx),
|
|
SendToDevicePosition: s.SendToDeviceStreamProvider.LatestPosition(ctx),
|
|
AccountDataPosition: s.AccountDataStreamProvider.LatestPosition(ctx),
|
|
NotificationDataPosition: s.NotificationDataStreamProvider.LatestPosition(ctx),
|
|
DeviceListPosition: s.DeviceListStreamProvider.LatestPosition(ctx),
|
|
PresencePosition: s.PresenceStreamProvider.LatestPosition(ctx),
|
|
}
|
|
}
|