2021-01-08 16:59:06 +00:00
|
|
|
package streams
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-03-29 12:14:35 +00:00
|
|
|
"github.com/matrix-org/dendrite/internal/caching"
|
2021-01-08 16:59:06 +00:00
|
|
|
keyapi "github.com/matrix-org/dendrite/keyserver/api"
|
|
|
|
rsapi "github.com/matrix-org/dendrite/roomserver/api"
|
2022-04-06 11:11:19 +00:00
|
|
|
"github.com/matrix-org/dendrite/syncapi/notifier"
|
2021-01-08 16:59:06 +00:00
|
|
|
"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 {
|
2022-03-03 11:40:53 +00:00
|
|
|
PDUStreamProvider types.StreamProvider
|
|
|
|
TypingStreamProvider types.StreamProvider
|
|
|
|
ReceiptStreamProvider types.StreamProvider
|
|
|
|
InviteStreamProvider types.StreamProvider
|
|
|
|
SendToDeviceStreamProvider types.StreamProvider
|
|
|
|
AccountDataStreamProvider types.StreamProvider
|
|
|
|
DeviceListStreamProvider types.StreamProvider
|
|
|
|
NotificationDataStreamProvider types.StreamProvider
|
2022-04-06 11:11:19 +00:00
|
|
|
PresenceStreamProvider types.StreamProvider
|
2021-01-08 16:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewSyncStreamProviders(
|
2022-05-05 08:56:03 +00:00
|
|
|
d storage.Database, userAPI userapi.SyncUserAPI,
|
|
|
|
rsAPI rsapi.SyncRoomserverAPI, keyAPI keyapi.SyncKeyAPI,
|
2022-05-06 13:33:34 +00:00
|
|
|
eduCache *caching.EDUCache, lazyLoadCache caching.LazyLoadCache, notifier *notifier.Notifier,
|
2021-01-08 16:59:06 +00:00
|
|
|
) *Streams {
|
|
|
|
streams := &Streams{
|
|
|
|
PDUStreamProvider: &PDUStreamProvider{
|
|
|
|
StreamProvider: StreamProvider{DB: d},
|
2022-04-19 08:46:45 +00:00
|
|
|
lazyLoadCache: lazyLoadCache,
|
2022-04-26 08:53:17 +00:00
|
|
|
rsAPI: rsAPI,
|
2022-08-05 12:27:27 +00:00
|
|
|
notifier: notifier,
|
2021-01-08 16:59:06 +00:00
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
2022-03-03 11:40:53 +00:00
|
|
|
NotificationDataStreamProvider: &NotificationDataStreamProvider{
|
|
|
|
StreamProvider: StreamProvider{DB: d},
|
|
|
|
},
|
2021-01-08 16:59:06 +00:00
|
|
|
DeviceListStreamProvider: &DeviceListStreamProvider{
|
2022-01-20 15:26:45 +00:00
|
|
|
StreamProvider: StreamProvider{DB: d},
|
|
|
|
rsAPI: rsAPI,
|
|
|
|
keyAPI: keyAPI,
|
2021-01-08 16:59:06 +00:00
|
|
|
},
|
2022-04-06 11:11:19 +00:00
|
|
|
PresenceStreamProvider: &PresenceStreamProvider{
|
|
|
|
StreamProvider: StreamProvider{DB: d},
|
|
|
|
notifier: notifier,
|
|
|
|
},
|
2021-01-08 16:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
streams.PDUStreamProvider.Setup()
|
|
|
|
streams.TypingStreamProvider.Setup()
|
|
|
|
streams.ReceiptStreamProvider.Setup()
|
|
|
|
streams.InviteStreamProvider.Setup()
|
|
|
|
streams.SendToDeviceStreamProvider.Setup()
|
|
|
|
streams.AccountDataStreamProvider.Setup()
|
2022-03-03 11:40:53 +00:00
|
|
|
streams.NotificationDataStreamProvider.Setup()
|
2021-01-08 16:59:06 +00:00
|
|
|
streams.DeviceListStreamProvider.Setup()
|
2022-04-06 11:11:19 +00:00
|
|
|
streams.PresenceStreamProvider.Setup()
|
2021-01-08 16:59:06 +00:00
|
|
|
|
|
|
|
return streams
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Streams) Latest(ctx context.Context) types.StreamingToken {
|
|
|
|
return types.StreamingToken{
|
2022-03-03 11:40:53 +00:00
|
|
|
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),
|
2022-04-06 11:11:19 +00:00
|
|
|
PresencePosition: s.PresenceStreamProvider.LatestPosition(ctx),
|
2021-01-08 16:59:06 +00:00
|
|
|
}
|
|
|
|
}
|